1 19 20 package com.hp.hpl.jena.reasoner.dig; 23 24 import java.util.*; 25 import java.util.List ; 26 27 import org.w3c.dom.*; 28 import org.w3c.dom.Document ; 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.*; 33 import com.hp.hpl.jena.util.iterator.ExtendedIterator; 34 35 36 39 47 public class DIGQueryDisjointTranslator 48 extends DIGQueryTranslator 49 { 50 51 54 57 60 63 67 public DIGQueryDisjointTranslator( String predicate ) { 68 super( null, predicate, null ); 69 } 70 71 72 75 78 public Document translatePattern( TriplePattern pattern, DIGAdapter da ) { 79 DIGConnection dc = da.getConnection(); 80 Document query = dc.createDigVerb( DIGProfile.ASKS, da.getProfile() ); 81 Element disjoint = da.createQueryElement( query, DIGProfile.DISJOINT ); 82 da.addClassDescription( disjoint, pattern.getObject() ); 83 da.addClassDescription( disjoint, pattern.getSubject() ); 84 85 return query; 86 } 87 88 89 92 public ExtendedIterator translateResponseHook( Document response, TriplePattern query, DIGAdapter da ) { 93 List answer = new ArrayList(); 94 if (isTrue( response )) { 95 answer.add( query.asTriple() ); 97 } 98 99 return WrappedIterator.create( answer.iterator() ); 100 } 101 102 public Document translatePattern( TriplePattern pattern, DIGAdapter da, Model premises ) { 103 return translatePattern( pattern, da ); 104 } 105 106 public boolean checkSubject( com.hp.hpl.jena.graph.Node subject, DIGAdapter da, Model premises ) { 107 return da.isConcept( subject, premises ); 108 } 109 110 public boolean checkObject( com.hp.hpl.jena.graph.Node object, DIGAdapter da, Model premises ) { 111 return da.isConcept( object, premises ); 112 } 113 114 115 118 122 } 123 124 125 151 | Popular Tags |