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) ; }
private static void testGraphListMember(Node s, Node...expected) { Node list = listOf(graph, s) ; Iterator<Triple> iter = GraphList.listMember(graph, list, Node.ANY) ; Iterator<Node> x = GLib.triple2object(iter) ; List<Node> z = Iter.toList(x) ; check(z, expected) ; }
/** Calculate ?s list:member ?o as if it were a graph.find */ public static Iterator<Triple> listMember(Graph graph, final Node s, Node o) { if ( isAny(s) ) { Set<Node> x = findAllLists(graph) ; IteratorConcat<Triple> iterConcat = new IteratorConcat<>() ; for ( Node s2 : x ) { Iterator<Triple> iter = listMember(graph, s2, o) ; if ( iter.hasNext() ) iterConcat.add(iter); } return iterConcat ; } GNode gn = new GNode(graph, s) ; if ( ! isAny(o) ) { if ( contains(gn, o) ) return Iter.singleton(Triple.create(s, ListPFunction.nListMember, o)) ; else return Iter.nullIterator() ; } List<Node> x = members(gn) ; return Iter.map(x.iterator(), t -> Triple.create(s, ListPFunction.nListMember, t)) ; }