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.reasoner.TriplePattern; 31 import com.hp.hpl.jena.util.iterator.*; 32 33 34 35 48 public class DIGQueryRoleAncestorsTranslator 49 extends DIGQueryTranslator 50 { 51 52 55 58 61 62 protected boolean m_ancestors; 63 64 65 68 73 public DIGQueryRoleAncestorsTranslator( String predicate, boolean ancestors ) { 74 super( (ancestors ? null : ALL), predicate, (ancestors ? ALL : null) ); 75 m_ancestors = ancestors; 76 } 77 78 79 82 83 86 public Document translatePattern( TriplePattern pattern, DIGAdapter da ) { 87 DIGConnection dc = da.getConnection(); 88 Document query = dc.createDigVerb( DIGProfile.ASKS, da.getProfile() ); 89 90 if (m_ancestors) { 91 Element parents = da.createQueryElement( query, DIGProfile.RANCESTORS ); 92 da.addClassDescription( parents, pattern.getSubject() ); 93 } 94 else { 95 Element descendants = da.createQueryElement( query, DIGProfile.RDESCENDANTS ); 96 da.addClassDescription( descendants, pattern.getObject() ); 97 } 98 99 return query; 100 } 101 102 103 106 public ExtendedIterator translateResponseHook( Document response, TriplePattern query, DIGAdapter da ) { 107 return translateRoleSetResponse( response, query, m_ancestors ); 109 } 110 111 112 public Document translatePattern( TriplePattern pattern, DIGAdapter da, Model premises ) { 113 return null; 115 } 116 117 public boolean checkSubject( com.hp.hpl.jena.graph.Node subject, DIGAdapter da, Model premises ) { 118 return !m_ancestors || da.isRole( subject, premises ); 119 } 120 121 public boolean checkObject( com.hp.hpl.jena.graph.Node object, DIGAdapter da, Model premises ) { 122 return m_ancestors || da.isRole( object, premises ); 123 } 124 125 126 129 133 } 134 135 136 162 | Popular Tags |