1 10 package com.hp.hpl.jena.reasoner.rdfsReasoner1; 11 12 import com.hp.hpl.jena.reasoner.*; 13 import com.hp.hpl.jena.reasoner.rulesys.Util; 14 import com.hp.hpl.jena.reasoner.transitiveReasoner.*; 15 import com.hp.hpl.jena.rdf.model.*; 16 import com.hp.hpl.jena.graph.*; 17 import com.hp.hpl.jena.vocabulary.RDFS; 18 import com.hp.hpl.jena.vocabulary.ReasonerVocabulary; 19 20 40 public class RDFSReasoner extends TransitiveReasoner implements Reasoner { 41 42 public static Node domainP; 43 44 45 public static Node rangeP; 46 47 48 protected boolean scanProperties = true; 49 50 static { 52 domainP = RDFS.domain.getNode(); 53 rangeP = RDFS.range.getNode(); 54 } 55 56 57 public RDFSReasoner() { 58 super(); 59 } 60 61 68 public RDFSReasoner(Resource configuration) { 69 super(); 70 if (configuration != null) { 71 Boolean flag = checkBinaryPredicate(RDFSReasonerFactory.scanProperties, configuration); 72 if (flag != null) scanProperties = flag.booleanValue(); 73 } 74 } 75 76 80 protected RDFSReasoner(Finder tbox, 81 TransitiveGraphCache subClassCache, 82 TransitiveGraphCache subPropertyCache, 83 boolean scanProperties) { 84 super(tbox, subClassCache, subPropertyCache); 85 this.scanProperties = scanProperties; 86 } 87 88 95 public boolean supportsProperty(Property property) { 96 ReasonerFactory rf = RDFSReasonerFactory.theInstance(); 97 Model caps = rf.getCapabilities(); 98 Resource root = caps.getResource(rf.getURI()); 99 return caps.contains(root, ReasonerVocabulary.supportsP, property); 100 } 101 102 109 private Boolean checkBinaryPredicate(Property predicate, Resource configuration) { 110 StmtIterator i = configuration.listProperties(predicate); 111 if (i.hasNext()) { 112 return new Boolean (i.nextStatement().getObject().toString().equalsIgnoreCase("true")); 113 } else { 114 return null; 115 } 116 } 117 118 127 public Reasoner bindSchema(Graph tbox) throws ReasonerException { 128 if (this.tbox != null) { 129 throw new ReasonerException("Attempt to bind multiple rulesets - disallowed for now"); 130 } 131 FGraph ftbox = new FGraph(tbox); 132 TransitiveGraphCache sCc = new TransitiveGraphCache(directSubClassOf, subClassOf); 133 TransitiveGraphCache sPc = new TransitiveGraphCache(directSubPropertyOf, subPropertyOf); 134 TransitiveEngine.cacheSubPropUtility(ftbox, sPc); 135 TransitiveEngine.cacheSubClassUtility(ftbox, sPc, sCc); 136 sPc.setCaching(true); 137 return new RDFSReasoner(ftbox, sCc, sPc, scanProperties); 138 } 139 140 141 151 public InfGraph bind(Graph data) throws ReasonerException { 152 return new RDFSInfGraph(this, data); 153 } 154 155 163 public void setDerivationLogging(boolean logOn) { 164 } 166 167 179 public void setParameter(Property parameter, Object value) { 180 if (parameter.equals(RDFSReasonerFactory.scanProperties)) { 181 scanProperties = Util.convertBooleanPredicateArg(parameter, value); 182 } else { 183 throw new IllegalParameterException(parameter.toString()); 184 } 185 } 186 187 } 188 189 218 219 | Popular Tags |