Search in sources :

Example 16 with ItemList

use of org.apache.jena.sparql.sse.ItemList in project jena by apache.

the class BuilderExec method exec.

public static void exec(Item item) {
    if (item.isNode())
        BuilderLib.broken(item, "Attempt to build evaluation from a plain node");
    if (item.isSymbol())
        BuilderLib.broken(item, "Attempt to build evaluation from a bare symbol");
    if (!item.isTagged(Tags.tagExec))
        throw new BuildException("Wanted (" + Tags.tagExec + "...) : got: " + item.shortString());
    ItemList list = item.getList();
    BuilderLib.checkLength(3, list, item.shortString() + " does not have 2 components");
    DatasetGraph dsg = BuilderGraph.buildDataset(list.get(1));
    Op op = BuilderOp.build(list.get(2));
    QueryExecUtils.execute(op, dsg, ResultsFormat.FMT_TEXT);
}
Also used : Op(org.apache.jena.sparql.algebra.Op) ItemList(org.apache.jena.sparql.sse.ItemList) DatasetGraph(org.apache.jena.sparql.core.DatasetGraph)

Example 17 with ItemList

use of org.apache.jena.sparql.sse.ItemList in project jena by apache.

the class ParseHandlerForm method listAdd.

@Override
protected void listAdd(Item item) {
    // Always add to the current list, even for (base...) and (prefix...)
    // Then change the result list later.
    super.listAdd(item);
    ItemList list = super.currentList();
    if (list == null)
        // Top level is outside a list.  Can't be a form.
        return;
    Frame lastFrame = frameStack.getCurrent();
    if (!inDecl && /*! sameAsLast &&*/
    list.size() == 1 && isForm(list.getFirst())) {
        startForm(list);
        Frame f = new Frame(list);
        frameStack.push(f);
        inDecl = true;
        return;
    }
    if (inDecl) {
        // Only trigger form operations when items at the top of the form are seen.
        boolean atTopOfDecl = (lastFrame != null && lastFrame.listItem == list);
        if (!atTopOfDecl)
            return;
        declItem(list, item);
        if (endOfDecl(list, item)) {
            inDecl = false;
            // Already added.
            return;
        }
    }
}
Also used : ItemList(org.apache.jena.sparql.sse.ItemList)

Example 18 with ItemList

use of org.apache.jena.sparql.sse.ItemList in project jena by apache.

the class ParseHandlerForm method listFinish.

@Override
public void listFinish(int line, int column) {
    ItemList list = currentList();
    if (!frameStack.isCurrent(list)) {
        // Nothing special - proceed as normal.
        super.listFinish(line, column);
        return;
    }
    if (inDecl)
        throwException("Inconsistent form: Still in DECL at end of the form", line, column);
    // For later: no exception: ensure this is cleared.
    inDecl = false;
    finishForm(list);
    // Frame
    Frame f = frameStack.pop();
    // Drop the form list.
    popList();
    //setCurrentItem(null) ;  // Clear, in case top level item is a form of nothing.
    // Form output skipped if no result registered.
    Item item = f.result;
    // If all forms at least evaluate to nil.
    //        if ( item == null )
    //            item = Item.createNil(list.getLine(), list.getColumn()) ;
    // And emit a result as a listAdd.
    // Must go through our listAdd() here to handle nested forms.
    // item==null : remove nil code above to allow forms that have no output.
    //        if ( item != null )
    listAdd(item);
}
Also used : Item(org.apache.jena.sparql.sse.Item) ItemList(org.apache.jena.sparql.sse.ItemList)

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