1 19 20 package com.hp.hpl.jena.reasoner.dig; 23 24 25 import org.w3c.dom.*; 28 29 import com.hp.hpl.jena.rdf.model.Model; 30 import com.hp.hpl.jena.rdf.model.Resource; 31 import com.hp.hpl.jena.reasoner.TriplePattern; 32 import com.hp.hpl.jena.util.iterator.*; 33 import com.hp.hpl.jena.vocabulary.*; 34 import com.hp.hpl.jena.vocabulary.RDF; 35 36 37 38 50 public class DIGQueryRoleFillersTranslator 51 extends DIGQueryTranslator 52 { 53 54 57 60 63 64 67 70 public DIGQueryRoleFillersTranslator() { 71 super( null, null, ALL ); 72 } 73 74 75 78 79 82 public Document translatePattern( TriplePattern pattern, DIGAdapter da ) { 83 DIGConnection dc = da.getConnection(); 84 Document query = dc.createDigVerb( DIGProfile.ASKS, da.getProfile() ); 85 86 Element instances = da.createQueryElement( query, DIGProfile.ROLE_FILLERS ); 87 da.addNamedElement( instances, DIGProfile.INDIVIDUAL, da.getNodeID( pattern.getSubject() ) ); 88 da.addNamedElement( instances, DIGProfile.RATOM, da.getNodeID( pattern.getPredicate() ) ); 89 90 return query; 91 } 92 93 94 97 public ExtendedIterator translateResponseHook( Document response, TriplePattern query, DIGAdapter da ) { 98 return translateIndividualSetResponse( response, query, true ); 100 } 101 102 103 public Document translatePattern( TriplePattern pattern, DIGAdapter da, Model premises ) { 104 return null; 106 } 107 108 public boolean checkSubject( com.hp.hpl.jena.graph.Node subject, DIGAdapter da, Model premises ) { 109 return subject.isConcrete() && da.isIndividual( subject ); 110 } 111 112 public boolean checkPredicate( com.hp.hpl.jena.graph.Node predicate, DIGAdapter da, Model premises ) { 113 if (predicate.isConcrete()) { 115 Resource p = (Resource) da.m_sourceData.getRDFNode( predicate ); 116 String pNS = p.getNameSpace(); 117 return !(da.m_sourceData.contains( p, RDF.type, da.m_sourceData.getProfile().DATATYPE_PROPERTY() ) || 118 RDFS.getURI().equals( pNS ) || 119 RDF.getURI().equals( pNS ) || 120 OWL.getURI().equals( pNS )); 121 } 122 else { 123 return false; 124 } 125 } 126 127 128 131 135 } 136 137 138 164 | Popular Tags |