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 49 public class DIGQueryDifferentFromTranslator 50 extends DIGQueryTranslator 51 { 52 53 56 59 62 65 69 public DIGQueryDifferentFromTranslator( String predicate ) { 70 super( null, predicate, null ); 71 } 72 73 74 77 80 public Document translatePattern( TriplePattern pattern, DIGAdapter da ) { 81 DIGConnection dc = da.getConnection(); 82 Document query = dc.createDigVerb( DIGProfile.ASKS, da.getProfile() ); 83 Element disjoint = da.createQueryElement( query, DIGProfile.DISJOINT ); 84 85 Element ind = da.addElement( disjoint, DIGProfile.ISET ); 86 da.addNamedElement( ind, DIGProfile.INDIVIDUAL, da.getNodeID( pattern.getSubject() ) ); 87 88 ind = da.addElement( disjoint, DIGProfile.ISET ); 89 da.addNamedElement( ind, DIGProfile.INDIVIDUAL, da.getNodeID( pattern.getObject() ) ); 90 91 return query; 92 } 93 94 95 98 public ExtendedIterator translateResponseHook( Document response, TriplePattern query, DIGAdapter da ) { 99 List answer = new ArrayList(); 100 if (isTrue( response )) { 101 answer.add( query.asTriple() ); 103 } 104 105 return WrappedIterator.create( answer.iterator() ); 106 } 107 108 public Document translatePattern( TriplePattern pattern, DIGAdapter da, Model premises ) { 109 return translatePattern( pattern, da ); 111 } 112 113 public boolean checkSubject( com.hp.hpl.jena.graph.Node subject, DIGAdapter da, Model premises ) { 114 return da.isIndividual( subject ); 115 } 116 117 public boolean checkObject( com.hp.hpl.jena.graph.Node object, DIGAdapter da, Model premises ) { 118 return da.isIndividual( object ); 119 } 120 121 122 125 129 } 130 131 132 158 | Popular Tags |