Search in sources :

Example 11 with ItemList

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);
}
Also used : ItemList(org.apache.jena.sparql.sse.ItemList)

Example 12 with ItemList

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);
}
Also used : ItemList(org.apache.jena.sparql.sse.ItemList)

Example 13 with ItemList

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;
}
Also used : Item(org.apache.jena.sparql.sse.Item) ItemList(org.apache.jena.sparql.sse.ItemList) Node(org.apache.jena.graph.Node)

Example 14 with ItemList

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));
}
Also used : ItemList(org.apache.jena.sparql.sse.ItemList)

Example 15 with ItemList

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;
}
Also used : Item(org.apache.jena.sparql.sse.Item) ItemList(org.apache.jena.sparql.sse.ItemList) ARQInternalErrorException(org.apache.jena.sparql.ARQInternalErrorException)

Aggregations

ItemList (org.apache.jena.sparql.sse.ItemList)18 Item (org.apache.jena.sparql.sse.Item)10 Node (org.apache.jena.graph.Node)4 Var (org.apache.jena.sparql.core.Var)4 DatasetGraph (org.apache.jena.sparql.core.DatasetGraph)2 Binding (org.apache.jena.sparql.engine.binding.Binding)2 ArrayList (java.util.ArrayList)1 Graph (org.apache.jena.graph.Graph)1 ARQException (org.apache.jena.sparql.ARQException)1 ARQInternalErrorException (org.apache.jena.sparql.ARQInternalErrorException)1 Op (org.apache.jena.sparql.algebra.Op)1 Table (org.apache.jena.sparql.algebra.Table)1 Quad (org.apache.jena.sparql.core.Quad)1 QueryIterator (org.apache.jena.sparql.engine.QueryIterator)1 ResultSetStream (org.apache.jena.sparql.engine.ResultSetStream)1 BindingMap (org.apache.jena.sparql.engine.binding.BindingMap)1 QueryIterPlainWrapper (org.apache.jena.sparql.engine.iterator.QueryIterPlainWrapper)1