public static Collection<Node> containerMembers(Graph graph, Node container) { return containerMembers(graph, container, null) ; }
public static int countContainerMember(Graph graph, Node container, Node containerType, Node member) { return countContainerMember(graph, container, containerType, member, false) ; }
public static boolean isContainer(Graph graph, Node container, Node containerType) { // if ( container.isLiteral() ) // return false ; if ( containerType == null ) return isContainer(graph, container, BAG) || isContainer(graph, container, ALT) || isContainer(graph, container, SEQ) ; return graph.contains(container, RDFtype, containerType) ; }
public static Collection<Node> containerMembers(Graph graph, Node container, Node containerType) { if ( ! isContainer(graph, container, containerType) ) return null ; ExtendedIterator<Triple> iter = graph.find(container, Node.ANY, Node.ANY) ; SortedMap<Integer, Node> triples = new TreeMap<>(order) ; try { for ( ; iter.hasNext() ; ) { Triple t = iter.next() ; int index = getIndex(t) ; if ( index == NOT_FOUND ) continue ; // Insert triples.put(new Integer(index), t.getObject()) ; } } finally { iter.close() ; } return triples.values() ; }
private /*static*/ Iterator<Triple> graphFind(Graph graph, Node s, Node p, Node o, Context context) { // This is the only place this is called. // It means we can add property functions here. // Fast-path common cases. if ( doingRDFSmember && RDFSmember.equals(p) ) return GraphContainerUtils.rdfsMember(graph, s, o) ; if ( doingListMember && ListMember.equals(p) ) return GraphList.listMember(graph, s, o) ; // Potentially just allow the cases above. //return graph.find(s, p, o) ; return graphFind2(graph, s, p, o, context) ; }
static private Collection<Node> findContainingContainers(Graph graph, Node typeNode, Node member) { Collection<Node> acc = new HashSet<>() ; // Index off the object ExtendedIterator<Triple> iter = graph.find(Node.ANY, Node.ANY, member) ; while(iter.hasNext()) { Triple t = iter.next(); Node containerNode = t.getSubject() ; // Candidate if ( GraphContainerUtils.isContainer(graph, containerNode, typeNode) ) acc.add(containerNode) ; } return acc ; } }
public static boolean isContainerMember(Graph graph, Node container, Node containerType, Node member) { return countContainerMember(graph, container, containerType, member, true) != 0 ; }
private QueryIterator members(Binding binding, Node containerNode, Var memberVar, ExecutionContext execCxt) { // Not necessarily very efficient Collection<Node> x = GraphContainerUtils.containerMembers(execCxt.getActiveGraph(), containerNode, typeNode) ; if ( x == null ) // Wrong type. return IterLib.noResults(execCxt) ; List<Binding> bindings = new ArrayList<>() ; for ( Node n : x ) { Binding b = BindingFactory.binding( binding, memberVar, n ); bindings.add( b ); } // Turn into a QueryIterator of extra bindings. return new QueryIterPlainWrapper(bindings.iterator(), execCxt) ; }
if ( ! isContainer(graph, container, containerType) ) return 0 ;
private QueryIterator verify(Binding binding, Node containerNode, Node member, ExecutionContext execCxt) { int count = GraphContainerUtils.countContainerMember(execCxt.getActiveGraph(), containerNode, typeNode, member) ; return new QueryIterYieldN(count, binding, execCxt) ; }
if ( ! GraphContainerUtils.isContainer(execCxt.getActiveGraph(), containerNode, typeNode) ) return IterLib.noResults(execCxt) ; return oneContainer(binding, containerNode, member, execCxt) ;