use of org.apache.jena.sparql.sse.ItemList in project jena by apache.
the class BuilderNode method buildVarList.
public static List<Var> buildVarList(Item item) {
BuilderLib.checkList(item);
ItemList list = item.getList();
return buildVarList(list);
}
use of org.apache.jena.sparql.sse.ItemList in project jena by apache.
the class BuilderNode method buildNodeList.
public static List<Node> buildNodeList(Item item) {
BuilderLib.checkList(item);
ItemList list = item.getList();
return buildNodeList(list);
}
use of org.apache.jena.sparql.sse.ItemList in project jena by apache.
the class Stats method format.
private static Item format(Map<Node, Integer> predicates, Map<Node, Integer> types, long count) {
Item stats = Item.createList();
ItemList statsList = stats.getList();
statsList.add("stats");
Item meta = createTagged(StatsMatcher.META);
addPair(meta.getList(), "timestamp", NodeFactoryExtra.nowAsDateTime());
addPair(meta.getList(), "run@", DateTimeUtils.nowAsString());
if (count >= 0)
addPair(meta.getList(), StatsMatcher.COUNT, NodeFactoryExtra.intToNode((int) count));
statsList.add(meta);
for (Entry<Node, Integer> entry : types.entrySet()) {
Node type = entry.getKey();
addTypeTriple(statsList, type, NodeFactoryExtra.intToNode(entry.getValue()));
}
for (Entry<Node, Integer> entry : predicates.entrySet()) {
Node node = entry.getKey();
// Skip these - they just clog things up!
if (node.getURI().startsWith("http://www.w3.org/1999/02/22-rdf-syntax-ns#_"))
continue;
addPair(statsList, node, NodeFactoryExtra.intToNode(entry.getValue()));
}
// Add a default rule.
addPair(statsList, StatsMatcher.OTHER, ZERO);
return stats;
}
use of org.apache.jena.sparql.sse.ItemList in project jena by apache.
the class ParseHandlerPlain method listStart.
@Override
public void listStart(int line, int column) {
ItemList list = new ItemList(line, column);
pushList(list);
setCurrentItem(Item.createList(list));
}
use of org.apache.jena.sparql.sse.ItemList in project jena by apache.
the class BuilderExpr method buildItem.
public Expr buildItem(Item item) {
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 buildItem(item);
}
return buildKnownFunction(list);
}
throw new ARQInternalErrorException();
}
if (item.isNode()) {
if (Var.isVar(item.getNode()))
return new ExprVar(Var.alloc(item.getNode()));
return NodeValue.makeNode(item.getNode());
}
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;
}
Aggregations