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.vocabulary.*; 35 import com.hp.hpl.jena.util.iterator.*; 36 37 38 39 46 public class DAMLClassImpl 47 extends OntClassImpl 48 implements DAMLClass 49 { 50 53 54 55 58 63 public static Implementation factory = new Implementation() { 64 public EnhNode wrap( Node n, EnhGraph eg ) { 65 if (canWrap( n, eg )) { 66 return new DAMLClassImpl( n, eg ); 67 } 68 else { 69 throw new ConversionException( "Cannot convert node " + n.toString() + " to DAMLClass" ); 70 } 71 } 72 73 public boolean canWrap( Node node, EnhGraph eg ) { 74 Profile profile = (eg instanceof OntModel) ? ((OntModel) eg).getProfile() : null; 76 return (profile != null) && profile.isSupported( node, eg, DAMLClass.class ); 77 } 78 }; 79 80 81 84 85 private PropertyAccessor m_propSubClassOf = new PropertyAccessorImpl( getProfile().SUB_CLASS_OF(), this ); 86 87 88 private PropertyAccessor m_propDisjointWith = new PropertyAccessorImpl( getProfile().DISJOINT_WITH(), this ); 89 90 91 private PropertyAccessor m_propDisjointUnionOf = new PropertyAccessorImpl( DAML_OIL.disjointUnionOf, this ); 92 93 94 private PropertyAccessor m_propSameClassAs = new PropertyAccessorImpl( getProfile().EQUIVALENT_CLASS(), this ); 95 96 97 private PropertyAccessor m_propOneOf = new PropertyAccessorImpl( getProfile().ONE_OF(), this ); 98 99 100 private PropertyAccessor m_propUnionOf = new PropertyAccessorImpl( getProfile().UNION_OF(), this ); 101 102 103 private PropertyAccessor m_propIntersectionOf = new PropertyAccessorImpl( getProfile().INTERSECTION_OF(), this ); 104 105 106 private PropertyAccessor m_propComplementOf = new PropertyAccessorImpl( getProfile().COMPLEMENT_OF(), this ); 107 108 109 protected DAMLCommon m_common = null; 110 111 112 protected DAMLVocabulary m_vocabulary = VocabularyManager.getDefaultVocabulary(); 113 114 115 118 126 public DAMLClassImpl( Node n, EnhGraph g ) { 127 super( n, g ); 128 m_common = new DAMLCommonImpl( n, g ); 129 } 130 131 132 133 136 138 public void setRDFType( Resource rdfClass, boolean replace ) { m_common.setRDFType( rdfClass, replace ); } 139 public DAMLModel getDAMLModel() { return m_common.getDAMLModel(); } 140 public ExtendedIterator getRDFTypes( boolean complete ) { return m_common.getRDFTypes( complete ); } 141 public DAMLVocabulary getVocabulary() { return m_vocabulary; } 142 public LiteralAccessor prop_label() { return m_common.prop_label(); } 143 public LiteralAccessor prop_comment() { return m_common.prop_comment(); } 144 public PropertyAccessor prop_equivalentTo() { return m_common.prop_equivalentTo(); } 145 public PropertyAccessor prop_type() { return m_common.prop_type(); } 146 147 154 public ExtendedIterator getEquivalentValues() { 155 ConcatenatedIterator i = new ConcatenatedIterator( 156 m_common.getEquivalentValues(), 158 getSameClasses() ); 160 161 return UniqueExtendedIterator.create( i ).mapWith( new AsMapper( DAMLClass.class ) ); 162 } 163 164 165 173 public ExtendedIterator getEquivalenceSet() { 174 Set s = new HashSet(); 175 176 s.add( this ); 177 for (Iterator i = getEquivalentValues(); i.hasNext(); s.add( i.next() ) ); 178 s.remove( this ); 179 180 return WrappedIterator.create( s.iterator() ); 181 } 182 183 184 185 191 public PropertyAccessor prop_subClassOf() { 192 return m_propSubClassOf; 193 } 194 195 196 202 public PropertyAccessor prop_disjointWith() { 203 return m_propDisjointWith; 204 } 205 206 207 214 public PropertyAccessor prop_disjointUnionOf() { 215 return m_propDisjointUnionOf; 216 } 217 218 219 225 public PropertyAccessor prop_sameClassAs() { 226 return m_propSameClassAs; 227 } 228 229 230 236 public PropertyAccessor prop_unionOf() { 237 return m_propUnionOf; 238 } 239 240 241 247 public PropertyAccessor prop_intersectionOf() { 248 return m_propIntersectionOf; 249 } 250 251 252 258 public PropertyAccessor prop_complementOf() { 259 return m_propComplementOf; 260 } 261 262 263 269 public PropertyAccessor prop_oneOf() { 270 return m_propOneOf; 271 } 272 273 274 283 public boolean isEnumeration() { 284 return hasProperty( getVocabulary().oneOf() ); 285 } 286 287 288 297 public boolean isNamedClass() { 298 return !isAnon(); 299 } 300 301 302 312 public boolean isRestriction() { 313 return hasProperty( RDF.type, getProfile().RESTRICTION() ); 314 } 315 316 317 326 public boolean isIntersection() { 327 return hasProperty( getVocabulary().intersectionOf() ); 328 } 329 330 331 340 public boolean isUnion() { 341 return hasProperty( getVocabulary().unionOf() ); 342 } 343 344 345 354 public boolean isDisjointUnion() { 355 return hasProperty( getVocabulary().disjointUnionOf() ); 356 } 357 358 359 368 public boolean isComplement() { 369 return hasProperty( getVocabulary().complementOf() ); 370 } 371 372 373 381 public ExtendedIterator getSubClasses() { 382 return getSubClasses( true ); 383 } 384 385 386 403 public ExtendedIterator getSubClasses( boolean closed ) { 404 return WrappedIterator.create( super.listSubClasses( !closed ) ).mapWith( new AsMapper( DAMLClass.class ) ); 405 } 406 407 408 416 public ExtendedIterator getSuperClasses() { 417 return getSuperClasses( true ); 418 } 419 420 421 438 public ExtendedIterator getSuperClasses( boolean closed ) { 439 return WrappedIterator.create( super.listSuperClasses( !closed ) ).mapWith( new AsMapper( DAMLClass.class ) ); 440 } 441 442 443 455 public ExtendedIterator getSameClasses() { 456 return WrappedIterator.create( super.listEquivalentClasses() ).mapWith( new AsMapper( DAMLClass.class ) ); 457 } 458 459 460 461 469 public ExtendedIterator getInstances() { 470 return WrappedIterator.create( listInstances() ).mapWith( new AsMapper( DAMLInstance.class ) ); 471 } 472 473 474 481 public ExtendedIterator getDefinedProperties() { 482 return getDefinedProperties( true ); 483 } 484 485 486 503 public ExtendedIterator getDefinedProperties( boolean closed ) { 504 return WrappedIterator.create( listDeclaredProperties( !closed ) ).mapWith( new AsMapper( DAMLProperty.class ) ); 505 } 506 507 508 511 512 516 } 517 518 547 548 | Popular Tags |