use of org.apache.jena.sparql.sse.Item in project jena by apache.
the class StatsMatcher method addAbbreviation.
private void addAbbreviation(Item elt) {
Item predicateTerm = elt.getList().get(0);
// Single node - it's a predicate abbreviate.
double numProp = elt.getList().get(1).getDouble();
if (count < 100)
addPatternsSmall(predicateTerm, numProp);
else
addPatterns(predicateTerm, numProp);
}
use of org.apache.jena.sparql.sse.Item in project jena by apache.
the class BuilderExpr method buildExpr.
public static Expr buildExpr(Item item) {
// Before testing for a list because of RDF terms that are lists: (qtriple).
if (item.isNode())
return ExprLib.nodeToExpr(item.getNode());
Expr expr = null;
if (item.isList()) {
ItemList list = item.getList();
if (list.size() == 0)
BuilderLib.broken(item, "Empty list for expression");
Item head = list.get(0);
if (head.isNode()) {
if (head.getNode().isVariable() && list.size() == 1)
// The case of (?z)
return new ExprVar(Var.alloc(head.getNode()));
return buildFunctionCall(list);
} else if (head.isList())
BuilderLib.broken(item, "Head is a list");
else if (head.isSymbol()) {
if (item.isTagged(Tags.tagExpr)) {
BuilderLib.checkLength(2, list, "Wrong length: " + item.shortString());
item = list.get(1);
return buildExpr(item);
}
return buildExpr(list);
}
throw new ARQInternalErrorException();
}
if (item.isSymbolIgnoreCase(Tags.tagTrue))
return NodeValue.TRUE;
if (item.isSymbolIgnoreCase(Tags.tagFalse))
return NodeValue.FALSE;
BuilderLib.broken(item, "Not a list or a node or recognized symbol: " + item);
return null;
}
use of org.apache.jena.sparql.sse.Item in project jena by apache.
the class BuilderExpr method buildExprListUntagged.
private static ExprList buildExprListUntagged(ItemList list, int idx) {
ExprList exprList = new ExprList();
for (int i = idx; i < list.size(); i++) {
Item item = list.get(i);
exprList.add(buildExpr(item));
}
return exprList;
}
use of org.apache.jena.sparql.sse.Item in project jena by apache.
the class BuilderExpr method buildExpr.
public static Expr buildExpr(ItemList list) {
if (list.size() == 0)
BuilderLib.broken(list, "Empty list for expression");
Item item = list.get(0);
String tag = item.getSymbol();
if (tag == null)
BuilderLib.broken(item, "Null tag");
Build b = findBuild(tag);
if (b == null)
BuilderLib.broken(item, "No known symbol for " + tag);
return b.make(list);
}
Aggregations