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);
}
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;
}
}
}
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);
}
Aggregations