/** * Apply the selector to the context node passed as argument and return the collection * of selected nodes in appropriate order. * * @param context the node where to start the selection * @param path the path leading to but not including the context node in the current evaluation of LDPath; may be null, * in which case path tracking is disabled * @param resultPaths a map where each of the result nodes maps to a path leading to the result node in the LDPath evaluation; * if null, path tracking is disabled and the path argument is ignored * @return the collection of selected nodes */ @Override public Collection<Node> select(RDFBackend<Node> rdfBackend, Node context, List<Node> path, Map<Node, List<Node>> resultPaths) { if(rdfBackend.isURI(context) || rdfBackend.isBlank(context)) { if(path != null && resultPaths != null) { Collection<Node> results = rdfBackend.listSubjects(property, context); for(Node n :results) { resultPaths.put(n, new ImmutableList.Builder<Node>().addAll(path).add(context).add(n).build()); } return results; } else { return rdfBackend.listSubjects(property, context); } } else { return Collections.emptyList(); } }
/** * Apply the selector to the context node passed as argument and return the collection * of selected nodes in appropriate order. * * @param context the node where to start the selection * @param path the path leading to but not including the context node in the current evaluation of LDPath; may be null, * in which case path tracking is disabled * @param resultPaths a map where each of the result nodes maps to a path leading to the result node in the LDPath evaluation; * if null, path tracking is disabled and the path argument is ignored * @return the collection of selected nodes */ @Override public Collection<Node> select(RDFBackend<Node> rdfBackend, Node context, List<Node> path, Map<Node, List<Node>> resultPaths) { if(rdfBackend.isURI(context) || rdfBackend.isBlank(context)) { if(path != null && resultPaths != null) { Collection<Node> results = rdfBackend.listSubjects(property, context); for(Node n :results) { resultPaths.put(n, new ImmutableList.Builder<Node>().addAll(path).add(context).add(n).build()); } return results; } else { return rdfBackend.listSubjects(property, context); } } else { return Collections.emptyList(); } }