private static final Node replaceVarNodeByNodeAny(Node node) { if (node.isVariable()) { return Node.ANY; } return node; }
private static Node replaceVarNodeByConstant(Node node) { if (node.isVariable()) { return PublishSubscribeConstants.SUBSCRIPTION_VARIABLE_NODE; } return node; }
private static Node tripleNode(Node node) { if ( node.isVariable() ) return Node.ANY ; return node ; }
/** * Compare two patterns and return true if arg is a more * specific (more grounded) version of this one. * Does not handle functors. */ public boolean subsumes(TriplePattern arg) { return (subject.isVariable() || subject.equals(arg.subject)) && (predicate.isVariable() || predicate.equals(arg.predicate)) && (object.isVariable() || object.equals(arg.object)); }
public static boolean isVar(Node node) { if ( node instanceof Var ) return true ; if ( node != null && node.isVariable() ) throw new NotAVariableException("Node_variable (not a Var) found") ; return false ; }
protected void addVar(Node n) { if (n!=null && n.isVariable()) { vars.add(Var.alloc(n)); } } protected void addVars(Triple t) {
private static Node resolve(Binding b, Node n) { if ( ! n.isVariable() ) return n ; return b.get(Var.alloc(n)) ; }
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) ; }
public static Expr nodeToExpr(Node n) { if ( n.isVariable() ) return new ExprVar(n) ; return NodeValue.makeNode(n) ; }
public ElementService(Node n, Element el, boolean silent) { if ( ! n.isURI() && ! n.isVariable() ) Log.fatal(this, "Must be a URI (or variable which will be bound) for a service endpoint") ; this.serviceNode = n ; this.element = el ; this.silent = silent ; }
public void addOrderBy(Node var, int direction) { if ( ! var.isVariable() ) throw new QueryException("Not a variable: "+var) ; SortCondition sc = new SortCondition(var, direction) ; addOrderBy(sc) ; }
public void addResultVar(Node v) { if ( !v.isVariable() ) throw new QueryException("Not a variable: "+v) ; _addResultVar(v.getName()) ; }
/** Evaluate a path in the forward direction */ //static public static private Iterator<Node> eval(Graph graph, Node node, Path path) { if ( node == null ) Log.fatal(PathEval_ARQ.class, "PathEval.eval applied to a null node") ; if ( node.isVariable() ) Log.warn(PathEval_ARQ.class, "PathEval.eval applied to a variable: "+node) ; return eval(graph, node, path, true) ; }
private QueryIterator oneContainer(Binding binding, Node containerNode, Node member, ExecutionContext execCxt) { // containerNode is a fixed term if ( member.isVariable() ) return members(binding, containerNode, Var.alloc(member), execCxt) ; else return verify(binding, containerNode, member, execCxt) ; }
/** Evaluate a path in the forward direction */ static public Iterator<Node> eval(Graph graph, Node node, Path path) { if ( node == null ) Log.fatal(PathEval.class, "PathEval.eval applied to a null node") ; if ( node.isVariable() ) Log.warn(PathEval.class, "PathEval.eval applied to a variable: "+node) ; return eval(graph, node, path, true) ; }
/** Evaluate a path starting at the end of the path */ static public Iterator<Node> evalInverse(Graph g, Node node, Path path) { if ( node == null ) Log.fatal(PathEval.class, "PathEval.eval applied to a null node") ; if ( node.isVariable() ) Log.warn(PathEval.class, "PathEval.eval applied to a variable: "+node) ; return eval(g, node, path, false) ; }
private static Node getBoundValue(Binding binding, Node node) { if (node.isVariable()) { return binding.get(Var.alloc(node.getName())); } else { return node; } }
public void addOrderBy(Node var, int direction) { if ( ! var.isVariable() ) throw new QueryException("Not a variable: "+var) ; SortCondition sc = new SortCondition(var, direction) ; addOrderBy(sc) ; }
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) ; } } }
private static Coordinate<SemanticElement> replaceVariablesByNull(AtomicQuery query) { SemanticElement[] tab = new SemanticElement[P2PStructuredProperties.CAN_NB_DIMENSIONS.getValue()]; for (int i = 0; i < P2PStructuredProperties.CAN_NB_DIMENSIONS.getValue(); i++) { if (query.getNode(i) != null && !query.getNode(i).equals(Node.ANY) && !query.getNode(i).isVariable()) { tab[i] = new SemanticElement(query.getNode(i)); } } return new Coordinate<SemanticElement>(tab); }