1 19 20 package com.hp.hpl.jena.reasoner.dig; 23 24 25 import org.w3c.dom.Document ; 28 import org.w3c.dom.Element ; 29 30 import com.hp.hpl.jena.rdf.model.Model; 31 import com.hp.hpl.jena.reasoner.TriplePattern; 32 import com.hp.hpl.jena.util.iterator.ExtendedIterator; 33 34 35 43 public class DIGQueryEquivalentsTranslator 44 extends DIGQueryTranslator 45 { 46 49 52 55 56 protected boolean m_subjectFree; 57 58 59 62 67 public DIGQueryEquivalentsTranslator( String predicate, boolean subjectFree ) { 68 super( null, predicate, null ); 69 m_subjectFree = subjectFree; 70 } 71 72 73 76 79 public Document translatePattern( TriplePattern pattern, DIGAdapter da ) { 80 DIGConnection dc = da.getConnection(); 81 Document query = dc.createDigVerb( DIGProfile.ASKS, da.getProfile() ); 82 83 Element equivalents = da.createQueryElement( query, DIGProfile.EQUIVALENTS ); 84 da.addClassDescription( equivalents, m_subjectFree ? pattern.getObject() : pattern.getSubject() ); 85 86 return query; 87 } 88 89 90 93 public ExtendedIterator translateResponseHook( Document response, TriplePattern query, DIGAdapter da ) { 94 return translateConceptSetResponse( response, query, !m_subjectFree, da ); 95 } 96 97 public Document translatePattern( TriplePattern pattern, DIGAdapter da, Model premises ) { 98 return null; 100 } 101 102 103 public boolean checkSubject( com.hp.hpl.jena.graph.Node subject, DIGAdapter da, Model premises ) { 104 return (m_subjectFree && !subject.isConcrete()) || da.isConcept( subject, premises ); 105 } 106 107 public boolean checkObject( com.hp.hpl.jena.graph.Node object, DIGAdapter da, Model premises ) { 108 return (!m_subjectFree && !object.isConcrete()) || da.isConcept( object, premises ); 109 } 110 111 public boolean checkTriple( TriplePattern pattern, DIGAdapter da, Model premises ) { 112 return super.checkTriple( pattern, da, premises ) && 113 (!pattern.getSubject().isConcrete() || !pattern.getObject().isConcrete()); 114 115 } 116 117 120 124 } 125 126 127 153 | Popular Tags |