/** * Returns a iterator containing all subjects of the triples where this * graph node is the object and has the specified property. The subjects * are returned as <code>GraphNode</code>s. * * @param property * @return */ public Iterator<GraphNode> getSubjectNodes(IRI property) { final Iterator<BlankNodeOrIRI> subjects = this.getSubjects(property); return new Iterator<GraphNode>() { @Override public boolean hasNext() { return subjects.hasNext(); } @Override public GraphNode next() { RDFTerm object = subjects.next(); return new GraphNode(object, graph); } @Override public void remove() { subjects.remove(); } }; }
/** * Returns a iterator containing all subjects of the triples where this * graph node is the object and has the specified property. The subjects * are returned as <code>GraphNode</code>s. * * @param property * @return */ public Iterator<GraphNode> getSubjectNodes(IRI property) { final Iterator<BlankNodeOrIRI> subjects = this.getSubjects(property); return new Iterator<GraphNode>() { @Override public boolean hasNext() { return subjects.hasNext(); } @Override public GraphNode next() { RDFTerm object = subjects.next(); return new GraphNode(object, graph); } @Override public void remove() { subjects.remove(); } }; }
private void followInversePaths(Resource resource, List<UriRef> pathToIndexedResource, List<Resource> list) { if (pathToIndexedResource.isEmpty()) { list.add(resource); } else { GraphNode node = new GraphNode(resource, this.baseGraph); Lock lock = node.readLock(); lock.lock(); try { Iterator<NonLiteral> predecessors = node.getSubjects(pathToIndexedResource.get(0)); List<UriRef> tail = pathToIndexedResource.subList(1, pathToIndexedResource.size()); while (predecessors.hasNext()) { followInversePaths(predecessors.next(), tail, list); } } finally { lock.unlock(); } //throw new RuntimeException("modification of indirect properties not yet supported") } }
Iterator<BlankNodeOrIRI> subjects = node.getSubjects(property); while (subjects.hasNext()) { ExpandedNode childNode = new ExpandedNode(subjects.next());