OInstance.java
001 /*
002  *  OInstance.java
003  *
004  *  Niraj Aswani, 09/March/07
005  *
006  *  $Id: OInstance.java 12224 2010-02-04 15:45:26Z johann_p $
007  */
008 package gate.creole.ontology;
009 
010 import java.util.List;
011 import java.util.Set;
012 
013 /**
014  * OInstance (Ontology Instance) represents an instance in the
015  * ontology/knowledge base. The interface provides various methods,
016  * including and not limited to, obtain a list of classes the instance
017  * belongs to, and various methods to add various property values on it.
018  
019  @author Niraj Aswani
020  @author Johann Petrak
021  
022  */
023 public interface OInstance extends OResource {
024   /**
025    * Gets the set of classes this instance belongs to.
026    
027    @param closure either OntologyConstants.DIRECT_CLOSURE or
028    *          OntologyConstants.TRANSITIVE_CLOSURE.
029    @return a set of {@link OClass} objects.
030    */
031   @Deprecated
032   public Set<OClass> getOClasses(byte closure);
033 
034   public Set<OClass> getOClasses(OConstants.Closure closure);
035 
036   /**
037    * Make this individual an instance of another class. This does nothing
038    * if the individual is already an instance of the given class. Note
039    * that this cann lead to inconsistencies, e.g. if this class is disjunct
040    * with a class of which the individual is already an instance.
041    *
042    @param theClass - the OClass object for the class of which the individual
043    * should be an instance.
044    */
045   public void addOClass(OClass theClass);
046 
047   /**
048    * Checks whether the instance is an instance of the provided class.
049    
050    @param aClass
051    @param closure either OntologyConstants.DIRECT_CLOSURE or
052    *          OntologyConstants.TRANSITIVE_CLOSURE.
053    @return true, if the instance is indded an instance of the provided
054    *         class, otherwise - false.
055    */
056   @Deprecated
057   public boolean isInstanceOf(OClass aClass, byte closure);
058 
059   public boolean isInstanceOf(OClass aClass, OConstants.Closure closure);
060 
061   /**
062    * Sets the instance being different from the provided instance.
063    
064    @param theIndividual
065    */
066   public void setDifferentFrom(OInstance theInstance);
067 
068   /**
069    * Returns a set of {@link OInstance} objects which are explicitly
070    * specified as being different from the current instance.
071    
072    @return a Set of OInstances
073    */
074   public Set<OInstance> getDifferentInstances();
075 
076   /**
077    * Checks whether the instance is different from the given instance
078    
079    @param theInstance
080    @return
081    */
082   public boolean isDifferentFrom(OInstance theInstance);
083 
084   /**
085    * Sets the instance being same as the provided instance.
086    
087    @param theIndividual
088    */
089   public void setSameInstanceAs(OInstance theIndividual);
090 
091   /**
092    * Returns a set of {@link OInstance} objects which are explicitly
093    * specified as being same as the current instance.
094    
095    @return
096    */
097   public Set<OInstance> getSameInstance();
098 
099   /**
100    * Checks whether the instance is same as the given instance
101    
102    @param theInstance
103    @return
104    */
105   public boolean isSameInstanceAs(OInstance theInstance);
106 
107   // ******************
108   // RDF Properties
109   // *****************
110 
111   /**
112    * Adds the value for the given RDFProperty.
113    
114    @param aProperty
115    @param value
116    @throws InvalidValueException This exception is thrown when a value
117    *           is not compatible with the specified property's range.
118    @deprecated this throws an exception in the new implementation
119    */
120   @Deprecated
121   public void addRDFPropertyValue(RDFProperty aProperty, OResource value)
122           throws InvalidValueException;
123 
124   /**
125    * Remove the provided value for the given property.
126    
127    @param aProperty
128    @param value
129    @return
130    @deprecated
131    */
132   @Deprecated
133   public void removeRDFPropertyValue(RDFProperty aProperty, OResource value);
134 
135   /**
136    * Gets a list of values for the given Property.
137    
138    @param aProperty
139    @return {@link List} of {@link OResource}.
140    @deprecated 
141    */
142   @Deprecated
143   public List<OResource> getRDFPropertyValues(RDFProperty aProperty);
144 
145   public List<OValue> getRDFPropertyOValues(RDFProperty aProperty);
146 
147   /**
148    * This method returns the RDF properties set on this resource.
149    @return
150    */
151   public Set<RDFProperty> getSetRDFProperties();
152 
153   /**
154    * Checks if the resource has the provided annotation property set on it with the specified value.
155    @param aProperty
156    @param aValue
157    @return
158    @deprecated
159    */
160   @Deprecated
161   public boolean hasRDFPropertyWithValue(RDFProperty aProperty, OResource aResource);
162 
163   
164   /**
165    * Removes all property values set for the current property.
166    
167    @param aProperty
168    @deprecated 
169    */
170   @Deprecated
171   public void removeRDFPropertyValues(RDFProperty aProperty);
172 
173   // ******************
174   // DataType Properties
175   // *****************
176 
177   /**
178    * Adds the value for the given Property.
179    
180    @param aProperty
181    @param value
182    @throws InvalidValueException This exception is thrown when a value
183    *           is not compatible with the specified property's range.
184    */
185   public void addDatatypePropertyValue(DatatypeProperty aProperty, Literal value)
186           throws InvalidValueException;
187 
188   /**
189    * Remove the provided value for the given property.
190    
191    @param aProperty
192    @param value
193    @return
194    */
195   public void removeDatatypePropertyValue(DatatypeProperty aProperty,
196           Literal value);
197 
198   /**
199    * Gets a list of values for the given Property.
200    
201    @param aProperty
202    @return {@link List} of {@link Literal}.
203    */
204   public List<Literal> getDatatypePropertyValues(DatatypeProperty aProperty);
205 
206   /**
207    * Removes all property values set for the current property.
208    
209    @param aProperty
210    */
211   public void removeDatatypePropertyValues(DatatypeProperty aProperty);
212 
213   // ******************
214   // Object, Symmetric and Transitive Properties
215   // *****************
216 
217   /**
218    * Adds the value for the given property (Object, Symmetric and
219    * Transitive).
220    
221    @param aProperty
222    @param value
223    @throws InvalidValueException This exception is thrown when a value
224    *           is not compatible with the specified property's range.
225    */
226   public void addObjectPropertyValue(ObjectProperty aProperty, OInstance value)
227           throws InvalidValueException;
228 
229   /**
230    * Remove the provided value for the given property (Object, Symmetric
231    * and Transitive).
232    
233    @param aProperty
234    @param value
235    @return true, if the value for the given property is deleted
236    *         successfully, otherwise - false.
237    */
238   public void removeObjectPropertyValue(ObjectProperty aProperty,
239           OInstance value);
240 
241   /**
242    * Gets a list of values for the given Property (Object, Symmetric and
243    * Transitive).
244    
245    @param aProperty
246    @return {@link List} of {@link OInstance}.
247    */
248   public List<OInstance> getObjectPropertyValues(ObjectProperty aProperty);
249 
250   /**
251    * Removes all property values set for the current property (Object,
252    * Symmetric and Transitive).
253    
254    @param aProperty
255    */
256   public void removeObjectPropertyValues(ObjectProperty aProperty);
257 
258   /**
259    * This method returns the datatype properties set on this resource.
260    @return
261    */
262   public Set<DatatypeProperty> getSetDatatypeProperties();
263   
264   
265   /**
266    * This method returns the object properties set on this resource.
267    @return
268    */
269   public Set<ObjectProperty> getSetObjectProperties();
270   
271   
272   /**
273    * Checks if the resource has the provided datatype property set on it with the specified value.
274    @param aProperty
275    @param aValue
276    @return
277    */
278   public boolean hasDatatypePropertyWithValue(DatatypeProperty aProperty, Literal aValue);
279   
280   /**
281    * Checks if the resource has the provided object property set on it with the specified value.
282    @param aProperty
283    @param aValue
284    @return
285    */
286   public boolean hasObjectPropertyWithValue(ObjectProperty aProperty, OInstance aValue);
287 
288   public OURI getOURI();
289 }