1 6 7 package com.hp.hpl.jena.mem; 8 9 import com.hp.hpl.jena.graph.Node; 10 import com.hp.hpl.jena.graph.query.SimpleQueryHandler; 11 import com.hp.hpl.jena.util.iterator.*; 12 13 20 public class GraphMemQueryHandler extends SimpleQueryHandler 21 { 22 GraphMemQueryHandler( GraphMem graph ) 23 { 24 super( graph ); 25 } 26 27 public ExtendedIterator objectsFor( Node p, Node o ) 28 { return bothANY( p, o ) ? findObjects() : super.objectsFor( p, o ); } 29 30 public ExtendedIterator predicatesFor( Node s, Node o ) 31 { return bothANY( s, o ) ? findPredicates() : super.predicatesFor( s, o ); } 32 33 public ExtendedIterator subjectsFor( Node p, Node o ) 34 { return bothANY( p, o ) ? findSubjects() : super.subjectsFor( p, o ); } 35 36 40 private boolean bothANY( Node a, Node b ) 41 { return (a == null || a.equals( Node.ANY )) && (b == null || b.equals( Node.ANY )); } 42 43 public ExtendedIterator findPredicates() 44 { return ((GraphMem) graph).store.listPredicates(); } 45 46 public ExtendedIterator findObjects() 47 { return ((GraphMem) graph).store.listObjects(); } 48 49 public ExtendedIterator findSubjects() 50 { return ((GraphMem) graph).store.listSubjects(); } 51 } 52 53 | Popular Tags |