1 18 19 package com.hp.hpl.jena.ontology.daml.impl; 22 23 24 import java.util.*; 27 28 import com.hp.hpl.jena.rdf.model.*; 29 import com.hp.hpl.jena.enhanced.*; 30 import com.hp.hpl.jena.graph.*; 31 import com.hp.hpl.jena.ontology.*; 32 import com.hp.hpl.jena.ontology.daml.*; 33 import com.hp.hpl.jena.ontology.impl.*; 34 import com.hp.hpl.jena.util.iterator.*; 35 import com.hp.hpl.jena.vocabulary.*; 36 37 38 48 public class DAMLCommonImpl 49 extends OntResourceImpl 50 implements DAMLCommon 51 { 52 55 56 57 60 65 public static Implementation factory = new Implementation() { 66 public EnhNode wrap( Node n, EnhGraph eg ) { 67 if (canWrap( n, eg )) { 68 return new DAMLCommonImpl( n, eg ); 69 } 70 else { 71 throw new ConversionException( "Cannot convert node " + n.toString() + " to DAMLCommon"); 72 } 73 } 74 75 public boolean canWrap( Node node, EnhGraph eg ) { 76 return node.isURI() || node.isBlank(); 78 } 79 }; 80 81 82 85 86 private LiteralAccessor m_propLabel = new LiteralAccessorImpl( getVocabulary().label(), this ); 87 88 89 private LiteralAccessor m_propComment = new LiteralAccessorImpl( getVocabulary().comment(), this ); 90 91 92 private PropertyAccessor m_propEquivalentTo = null; 93 94 95 private DAMLVocabulary m_vocabulary = null; 96 97 98 private PropertyAccessor m_propType = null; 99 100 101 102 105 106 113 public DAMLCommonImpl( Node n, EnhGraph g ) 114 { 115 super( n, g ); 116 } 117 118 119 120 123 128 public DAMLModel getDAMLModel() { 129 return (DAMLModel) getModel(); 130 } 131 132 133 145 public void setRDFType( Resource rdfClass, boolean replace ) { 146 if (replace) { 147 setRDFType( rdfClass ); 148 } 149 else { 150 addRDFType( rdfClass ); 151 } 152 } 153 154 155 169 public ExtendedIterator getRDFTypes( boolean complete ) { 170 return listRDFTypes( !complete ); 171 } 172 173 174 180 public DAMLVocabulary getVocabulary() { 181 if (m_vocabulary == null) { 182 m_vocabulary = VocabularyManager.getVocabulary( this ); 184 } 185 186 return m_vocabulary; 187 } 188 189 190 201 public ExtendedIterator getEquivalentValues() { 202 List me = new LinkedList(); 204 me.add( this ); 205 206 return UniqueExtendedIterator.create( WrappedIterator.create( me.iterator() ) 207 .andThen( listPropertyValues( getProfile().SAME_AS() ) ) ); 208 } 209 210 211 219 public ExtendedIterator getEquivalenceSet() { 220 Set s = new HashSet(); 221 222 s.add( this ); 223 for (Iterator i = getEquivalentValues(); i.hasNext(); s.add( i.next() ) ); 224 s.remove( this ); 225 226 return WrappedIterator.create( s.iterator() ); 227 } 228 229 230 233 239 public LiteralAccessor prop_label() { 240 return m_propLabel; 241 } 242 243 244 250 public LiteralAccessor prop_comment() { 251 return m_propComment; 252 } 253 254 255 262 public PropertyAccessor prop_equivalentTo() { 263 if (m_propEquivalentTo == null) { 264 m_propEquivalentTo = new PropertyAccessorImpl( getVocabulary().equivalentTo(), this ); 265 } 266 267 return m_propEquivalentTo; 268 } 269 270 271 272 277 public PropertyAccessor prop_type() { 278 if (m_propType == null) { 279 m_propType = new PropertyAccessorImpl( RDF.type, this ); 280 } 281 282 return m_propType; 283 } 284 285 286 287 290 291 292 296 297 298 } 299 300 301 302 331 332 | Popular Tags |