1 18 19 package com.hp.hpl.jena.ontology.daml.impl; 22 23 24 import com.hp.hpl.jena.rdf.model.*; 27 import com.hp.hpl.jena.util.iterator.*; 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.vocabulary.*; 33 34 35 36 42 public class DAMLInstanceImpl 43 extends DAMLCommonImpl 44 implements DAMLInstance 45 { 46 49 50 53 58 public static Implementation factory = new Implementation() { 59 public EnhNode wrap( Node n, EnhGraph eg ) { 60 if (canWrap( n, eg )) { 61 return new DAMLInstanceImpl( n, eg ); 62 } 63 else { 64 throw new ConversionException( "Cannot convert node " + n.toString() + " to DAMLDatatype" ); 65 } 66 } 67 68 public boolean canWrap( Node node, EnhGraph eg ) { 69 Profile profile = (eg instanceof OntModel) ? ((OntModel) eg).getProfile() : null; 70 return (profile != null) && profile.isSupported( node, eg, DAMLInstance.class ); 71 } 72 }; 73 74 77 78 protected PropertyAccessor m_propsameIndividualAs = null; 79 80 81 82 85 93 public DAMLInstanceImpl( Node n, EnhGraph g ) { 94 super( n, g ); 95 } 96 97 98 99 100 103 104 110 Object getKey() { 111 return DAML_OIL.Thing.getURI(); 112 } 113 114 115 120 public PropertyAccessor prop_sameIndividualAs() { 121 if (m_propsameIndividualAs == null) { 122 m_propsameIndividualAs = new PropertyAccessorImpl( getVocabulary().sameIndividualAs(), this ); 123 } 124 125 return m_propsameIndividualAs; 126 } 127 128 129 136 public ExtendedIterator getSameInstances() { 137 return listAs( getProfile().SAME_INDIVIDUAL_AS(), "SAME_INDIVIDUAL_AS", DAMLInstance.class ); 138 } 139 140 141 142 150 public ExtendedIterator getEquivalentValues() { 151 return UniqueExtendedIterator.create( listAs( getProfile().SAME_AS(), "SAME_AS", DAMLInstance.class ).andThen( getSameInstances() ) ); 152 } 153 154 155 162 public PropertyAccessor accessProperty( Property property ) { 163 return new PropertyAccessorImpl( property, this ); 164 } 165 166 167 170 177 protected Resource getDefaultType() { 178 return getVocabulary().Thing(); 179 } 180 181 182 183 187 188 } 189 190 191 192 221 222 | Popular Tags |