use of org.apache.jena.sparql.sse.Item in project jena by apache.
the class ParseHandlerPlain method emitIRI.
@Override
public void emitIRI(int line, int column, String iriStr) {
Node n = NodeFactory.createURI(iriStr);
Item item = Item.createNode(n, line, column);
listAdd(item);
}
use of org.apache.jena.sparql.sse.Item in project jena by apache.
the class BuilderExpr method buildFunctionCall.
protected static Expr buildFunctionCall(ItemList list) {
Item head = list.get(0);
Node node = head.getNode();
if (node.isBlank())
BuilderLib.broken(head, "Blank node for function call!");
if (node.isLiteral())
BuilderLib.broken(head, "Literal node for function call!");
ExprList args = buildExprListUntagged(list, 1);
// Args
return new E_Function(node.getURI(), args);
}
use of org.apache.jena.sparql.sse.Item in project jena by apache.
the class BuilderExpr method buildKnownFunction.
protected Expr buildKnownFunction(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);
}
use of org.apache.jena.sparql.sse.Item in project jena by apache.
the class BuilderGraph method buildDataset.
public static DatasetGraph buildDataset(DatasetGraph dsg, ItemList list) {
BuilderLib.checkTag(list, Tags.tagDataset);
list = list.cdr();
for (Item item : list) {
if (!item.isTagged(Tags.tagGraph)) {
// Not (graph ...) so it's (quad), short form quad or an error.
Quad q = BuilderGraph.buildQuad(item.getList(), "Expected (graph ...) or a quad () as elements of a dataset");
dsg.add(q);
continue;
}
Node name = null;
ItemList graphContent = item.getList().cdr();
if (!graphContent.isEmpty() && graphContent.car().isNode()) {
name = graphContent.car().getNode();
graphContent = graphContent.cdr();
}
Graph g;
if (name == null) {
g = dsg.getDefaultGraph();
if (g == null) {
g = GraphFactory.createDefaultGraph();
dsg.setDefaultGraph(g);
}
} else {
g = dsg.getGraph(name);
if (g == null) {
g = GraphFactory.createDefaultGraph();
dsg.addGraph(name, g);
}
}
BuilderGraph.buildGraph(g, graphContent);
}
return dsg;
}
use of org.apache.jena.sparql.sse.Item in project jena by apache.
the class BuilderBinding method buildBinding.
private static Binding buildBinding(ItemList list) {
// (row or (binding
if (list.size() == 0)
BuilderLib.broken(list, "Empty list");
Item head = list.get(0);
if (!head.isSymbolIgnoreCase(Tags.tagRow) && !head.isSymbolIgnoreCase(Tags.tagBinding))
BuilderLib.broken(list, "Does not start (" + Tags.tagRow + " ...) or (" + Tags.tagBinding + " ...)", head);
BindingMap binding = BindingFactory.create();
for (int i = 1; i < list.size(); i++) {
Item item = list.get(i);
BuilderLib.checkList(item, "Attempt to build a binding pair from non-list: " + item);
ItemList pair = item.getList();
BuilderLib.checkLength(2, pair, "Need a pair for a binding");
Var v = BuilderNode.buildVar(pair.get(0));
Item cdr = pair.get(1);
// undef
if (cdr.isSymbolIgnoreCase(Tags.tagUndef) || cdr.isSymbolIgnoreCase(Tags.tagNull))
continue;
BuilderLib.checkNode(cdr);
Node node = BuilderNode.buildNode(item.getList().get(1));
if (node == null)
BuilderLib.broken(item.getList().get(1), "Null node from " + item.getList().get(1));
if (node.isVariable())
BuilderLib.broken(item.getList().get(1), "No variables as table values: " + FmtUtils.stringForNode(node));
if (!node.isConcrete())
BuilderLib.broken(item.getList().get(1), "Ony concrete nodes as table values: " + FmtUtils.stringForNode(node));
binding.add(v, node);
}
return binding;
}
Aggregations