1 10 package com.hp.hpl.jena.reasoner.rdfsReasoner1; 11 12 import com.hp.hpl.jena.reasoner.*; 13 import com.hp.hpl.jena.graph.*; 14 import com.hp.hpl.jena.vocabulary.*; 15 import com.hp.hpl.jena.util.iterator.*; 16 17 import java.util.*; 18 19 26 public class PropertyBRWRule extends BRWRule { 27 28 31 public PropertyBRWRule() { 32 super(new TriplePattern(Node.createVariable("p"), RDF.type.getNode(), RDF.Property.getNode()), 33 new TriplePattern(null, Node.createVariable("s"), null)); 34 } 35 36 48 public ExtendedIterator execute(TriplePattern query, InfGraph infGraph, Finder data, HashSet firedRules) { 49 RDFSInfGraph bRr = (RDFSInfGraph) infGraph; 50 Node prop = query.getSubject(); 51 if (bRr.getScanProperties()) { 52 return NullIterator.instance; 56 } else { 57 TriplePattern pattern = instantiate(body, query); 59 return new RewriteIterator(bRr.findRawWithContinuation(body, data), this); 60 } 61 } 62 63 67 static class PropertyNodeIterator extends UniqueExtendedIterator { 68 69 74 public PropertyNodeIterator(Iterator underlying) { 75 super(underlying); 76 } 77 78 84 protected Object nextIfNew() { 85 Node prop = (Node)super.next(); 86 if (seen.add(prop)) { 87 return new Triple(prop, RDF.type.getNode(), RDF.Property.getNode()); 88 } else { 89 return null; 90 } 91 } 92 93 } 95 } 96 97 126 | Popular Tags |