/** * Apply the function to the list of nodes passed as arguments and return the result as type T. * Throws IllegalArgumentException if the function cannot be applied to the nodes passed as argument * or the number of arguments is not correct. * * @return */ @Override public boolean accept(RDFBackend<Node> rdfBackend, Node context, Node candidate) throws IllegalArgumentException { if (rdfBackend.isURI(candidate) || rdfBackend.isBlank(candidate)) { Collection<Node> testResult = path.select(rdfBackend, candidate,null,null); return testResult.size() > 0; } else { return false; } }
/** * Apply the function to the list of nodes passed as arguments and return the result as type T. * Throws IllegalArgumentException if the function cannot be applied to the nodes passed as argument * or the number of arguments is not correct. * * @return */ @Override public boolean accept(RDFBackend<Node> rdfBackend, Node context, Node candidate) throws IllegalArgumentException { if (rdfBackend.isURI(candidate) || rdfBackend.isBlank(candidate)) { Collection<Node> testResult = path.select(rdfBackend, candidate,null,null); return testResult.size() > 0; } else { return false; } }
/** * 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.listObjects(context,property); for(Node n : results) { resultPaths.put(n, new ImmutableList.Builder<Node>().addAll(path).add(context).add(n).build()); } return results; } else { return rdfBackend.listObjects(context,property); } } 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(); } }
/** * 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.listObjects(context,property); for(Node n : results) { resultPaths.put(n, new ImmutableList.Builder<Node>().addAll(path).add(context).add(n).build()); } return results; } else { return rdfBackend.listObjects(context,property); } } 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(); } }