/** * Convert any Node_RuleVariable wildcards to null. This loses * the variable named but is used when converting a singleton * pattern to a TripleMtch */ private static Node toMatch(Node node) { return node.isVariable() ? null : node; }
public static Node termOrAny(Node node) { if ( node == null || node.isVariable() ) return Node.ANY; return node; }
public static void addVar(Collection<Var> acc, Node n) { if (n == null) return ; if (n.isVariable()) acc.add(Var.alloc(n)) ; }
/** * Test if the pattern is ground, contains no variables. */ public boolean isGround() { if (subject.isVariable() || predicate.isVariable() || object.isVariable()) return false; if (Functor.isFunctor(object)) { return ((Functor)object.getLiteralValue()).isGround(); } return true; }
public static void addVar(Collection<Var> acc, Node n) { if ( n == null ) return; if ( n.isVariable() ) acc.add(Var.alloc(n)); }
private Node valueMap( Node n ) { if (n.isVariable()) { Var v = Var.alloc(n); Node n2 = values.get( n ); return n2==null?n:n2; } return n; }
private Node mapValue( Node n, Map<Var, Node> values) { Node retval = null; if (n.isVariable()) { final Var v = Var.alloc(n); retval = values.get(v); } return retval==null?n:retval; }
public ExprVar(Node n) { if ( ! n.isVariable() ) throw new ARQInternalErrorException("Attempt to create a NodeVar from a non variable Node: "+n) ; varNode = Var.alloc(n) ; }
protected final NodeId idForNode(Node node) { if ( node == null || node == Node.ANY ) return NodeId.NodeIdAny ; if ( node.isVariable() ) throw new TDBException("Can't pass variables to NodeTupleTable.find*") ; return nodeTable.getNodeIdForNode(node) ; }
protected final NodeId idForNode(Node node) { if (node == null || node == Node.ANY) return NodeId.NodeIdAny ; if (node.isVariable()) throw new TDBException("Can't pass variables to NodeTupleTable.find*") ; return nodeTable.getNodeIdForNode(node) ; }
public ElementService(Node n, Element el, boolean silent) { if ( ! n.isURI() && ! n.isVariable() ) Log.error(this, "Must be a URI (or variable which will be bound) for a service endpoint") ; this.serviceNode = n ; this.element = el ; this.silent = silent ; }
private static void check(Collection<Var> scope, ElementService el) { if ( ARQ.isStrictMode() && el.getServiceNode().isVariable() ) { Var var = Var.alloc(el.getServiceNode()) ; if ( ! scope.contains(var) ) throw new QueryParseException("SERVICE: Variable not already in-scope: "+var+" in "+el, -1 , -1) ; } } }
@Override public void visit(OpPropFunc opPropFunc) { for (Node subjArg : opPropFunc.getSubjectArgs().getArgList()) { if (subjArg.isVariable()) action(subjArg.getName()); } for (Node objArg : opPropFunc.getObjectArgs().getArgList()) { if (objArg.isVariable()) action(objArg.getName()); } }
@Override public void visit(OpDatasetNames dsNames) { if (dsNames.getGraphNode().isVariable()) action(dsNames.getGraphNode().getName()); }
@Override public Expr copySubstitute(Binding binding) { Var v = varNode ; if ( binding == null || !binding.contains(v) ) return new ExprVar(v) ; Node v2 = binding.get(v); return v2.isVariable() ? new ExprVar(v2) : eval(binding, null) ; }
@Override public void visit(ExprVar nv) { Node n = changeNode(nv.asVar()); if (n.isVariable()) { push(new ExprVar(n)); } else { push(NodeValue.makeNode(n)); } }
public boolean check(Node node, long line, long col) { // NodeVisitor? if ( node.isURI() ) return checkIRI(node, line, col) ; else if ( node.isBlank() ) return checkBlank(node, line, col) ; else if ( node.isLiteral() ) return checkLiteral(node, line, col) ; else if ( node.isVariable() ) return checkVar(node, line, col) ; handler.warning("Not a recognized node: ", line, col) ; return false ; }
public void testCreateVariable() { String V = "wobbly"; Node v = NodeCreateUtils.create( "?" + V ); assertTrue( "must be a variable", v.isVariable() ); assertEquals( "name must be correct", V, v.getName() ); }
public void testBlanks() { assertTrue( "anonymous nodes are blank", NodeFactory.createBlankNode().isBlank() ); assertFalse( "anonymous nodes aren't literal", NodeFactory.createBlankNode().isLiteral() ); assertFalse( "anonymous nodes aren't URIs", NodeFactory.createBlankNode().isURI() ); assertFalse( "anonymous nodes aren't variables", NodeFactory.createBlankNode().isVariable() ); assertEquals( "anonymous nodes have the right id", NodeFactory.createBlankNode(A).getBlankNodeId(), A ); }
public void testVariables() { assertFalse( "variable nodes aren't blank", NodeFactory.createVariable( N ).isBlank() ); assertFalse( "variable nodes aren't literal", NodeFactory.createVariable( N ).isLiteral() ); assertFalse( "variable nodes aren't URIs", NodeFactory.createVariable( N ).isURI() ); assertTrue( "variable nodes are variable", NodeFactory.createVariable( N ).isVariable() ); assertEquals( "variable nodes keep their name", N, NodeFactory.createVariable( N ).getName() ); assertEquals( "variable nodes keep their name", N + "x", NodeFactory.createVariable( N + "x" ).getName() ); }