1 18 19 package com.hp.hpl.jena.ontology.daml.impl; 22 23 24 import java.util.*; 27 28 import com.hp.hpl.jena.enhanced.*; 29 import com.hp.hpl.jena.graph.*; 30 import com.hp.hpl.jena.ontology.*; 31 import com.hp.hpl.jena.ontology.daml.*; 32 import com.hp.hpl.jena.ontology.impl.*; 33 import com.hp.hpl.jena.rdf.model.*; 34 import com.hp.hpl.jena.util.iterator.*; 35 import com.hp.hpl.jena.vocabulary.*; 36 37 38 48 public class DAMLPropertyImpl 49 extends OntPropertyImpl 50 implements DAMLProperty 51 { 52 55 56 59 64 public static Implementation factory = new Implementation() { 65 public EnhNode wrap( Node n, EnhGraph eg ) { 66 if (canWrap( n, eg )) { 67 return new DAMLPropertyImpl( n, eg ); 68 } 69 else { 70 throw new ConversionException( "Cannot convert node " + n.toString() + " to DAMLProperty" ); 71 } 72 } 73 74 public boolean canWrap( Node node, EnhGraph eg ) { 75 return hasType( node, eg, DAML_OIL.Property ) || 76 hasType( node, eg, DAML_OIL.DatatypeProperty ) || 77 hasType( node, eg, DAML_OIL.ObjectProperty ); 78 } 79 }; 80 81 82 85 86 private DAMLVocabulary m_vocabulary = VocabularyManager.getDefaultVocabulary(); 87 88 89 private PropertyAccessor m_propDomain = new PropertyAccessorImpl( getVocabulary().domain(), this ); 90 91 92 private PropertyAccessor m_propRange = new PropertyAccessorImpl( getVocabulary().range(), this ); 93 94 95 private PropertyAccessor m_propSubPropertyOf = new PropertyAccessorImpl( getVocabulary().subPropertyOf(), this ); 96 97 98 private PropertyAccessor m_propSamePropertyAs = new PropertyAccessorImpl( getVocabulary().samePropertyAs(), this ); 99 100 101 private DAMLCommon m_common = null; 102 103 104 107 115 public DAMLPropertyImpl( Node n, EnhGraph g ) { 116 super( n, g ); 117 m_common = new DAMLCommonImpl( n, g ); 118 } 119 120 121 122 125 127 public void setRDFType( Resource rdfClass, boolean replace ) { m_common.setRDFType( rdfClass, replace ); } 128 public DAMLModel getDAMLModel() { return m_common.getDAMLModel(); } 129 public ExtendedIterator getRDFTypes( boolean complete ) { return m_common.getRDFTypes( complete ); } 130 public DAMLVocabulary getVocabulary() { return m_vocabulary; } 131 public LiteralAccessor prop_label() { return m_common.prop_label(); } 132 public LiteralAccessor prop_comment() { return m_common.prop_comment(); } 133 public PropertyAccessor prop_equivalentTo() { return m_common.prop_equivalentTo(); } 134 public PropertyAccessor prop_type() { return m_common.prop_type(); } 135 136 143 public ExtendedIterator getEquivalentValues() { 144 ConcatenatedIterator i = new ConcatenatedIterator( 145 m_common.getEquivalentValues(), 147 getSameProperties() ); 149 150 return UniqueExtendedIterator.create( i ).mapWith( new AsMapper( DAMLProperty.class ) ); 151 } 152 153 154 162 public ExtendedIterator getEquivalenceSet() { 163 Set s = new HashSet(); 164 165 s.add( this ); 166 for (Iterator i = getEquivalentValues(); i.hasNext(); s.add( i.next() ) ); 167 s.remove( this ); 168 169 return WrappedIterator.create( s.iterator() ); 170 } 171 172 173 174 175 181 public void setIsUnique( boolean unique ) { 182 if (unique) { 183 addRDFType( getVocabulary().UniqueProperty() ); 185 } 186 else { 187 removeProperty( RDF.type, getVocabulary().UniqueProperty() ); 189 } 190 } 191 192 193 199 public boolean isUnique() { 200 return hasRDFType( getVocabulary().UniqueProperty() ); 201 } 202 203 204 211 public PropertyAccessor prop_domain() { 212 return m_propDomain; 213 } 214 215 216 222 public PropertyAccessor prop_subPropertyOf() { 223 return m_propSubPropertyOf; 224 } 225 226 227 233 public PropertyAccessor prop_samePropertyAs() { 234 return m_propSamePropertyAs; 235 } 236 237 238 245 public PropertyAccessor prop_range() { 246 return m_propRange; 247 } 248 249 250 262 public ExtendedIterator getSameProperties() { 263 return WrappedIterator.create( super.listEquivalentProperties() ).mapWith( new AsMapper( DAMLProperty.class ) ); 264 } 265 266 267 275 public ExtendedIterator getSuperProperties() { 276 return getSuperProperties( true ); 277 } 278 279 280 294 public ExtendedIterator getSuperProperties( boolean closed ) { 295 return WrappedIterator.create( listSuperProperties( !closed ) ).mapWith( new AsMapper( DAMLProperty.class ) ); 296 } 297 298 299 304 public ExtendedIterator getSubProperties() { 305 return getSubProperties( true ); 306 } 307 308 309 323 public ExtendedIterator getSubProperties( boolean closed ) { 324 return WrappedIterator.create( listSubProperties( !closed ) ).mapWith( new AsMapper( DAMLProperty.class ) ); 325 } 326 327 328 337 public ExtendedIterator getDomainClasses() { 338 return WrappedIterator.create( listPropertyValues( getProfile().DOMAIN() ) ).mapWith( new AsMapper( DAMLClass.class ) ); 339 } 340 341 342 351 public ExtendedIterator getRangeClasses() { 352 return WrappedIterator.create( listPropertyValues( getProfile().RANGE() ) ).mapWith( new AsMapper( DAMLClass.class ) ); 353 } 354 355 356 357 358 361 362 363 367 368 } 369 370 399 400 | Popular Tags |