1   /*
2    * Property.java
3    *
4    * Copyright (c) 2005, The University of Sheffield.
5    *
6    * This file is part of GATE (see http://gate.ac.uk/), and is free
7    * software, licenced under the GNU Library General Public License,
8    * Version 2, June1991.
9    *
10   * A copy of this licence is included in the distribution in the file
11   * licence.html, and is also available at http://gate.ac.uk/gate/licence.html.
12   *
13   * Kalina Bontcheva 11/2003
14   *
15   *
16   *  $Id: Property.java,v 1.6 2005/12/14 14:28:57 julien_nioche Exp $
17   */
18  package gate.creole.ontology;
19  
20  import java.util.Set;
21  
22  /**
23   * This interface defines an ontology property and is the top level interface
24   * for all types of ontological properties.
25   */
26  public interface Property extends OntologyResource, OntologyConstants {
27    /**
28     * Add a samePropertyAs relation between the two properties. Each property has
29     * a set of these, so it is possible to have samePropertyAs relation between
30     * more than two properties.
31     * 
32     * @param theProperty
33     */
34    public void setSamePropertyAs(Property theProperty);
35  
36    /**
37     * Returns a set of all KBProperty instances that are in SamePropertyAs
38     * relation with this property. Or null if there are no such properties.
39     * 
40     * @return a {@link Set} value.
41     */
42    public Set getSamePropertyAs();
43  
44    /**
45     * Adds a SubPropertyOf relation between the given property and this.
46     * 
47     * @param property
48     */
49    public void addSuperProperty(Property property);
50  
51    /**
52     * Removes a SubPropertyOf relation between the given property and this.
53     * 
54     * @param property
55     */
56    public void removeSuperProperty(Property property);
57  
58    /**
59     * Add a SuperPropertyOf relation between the given property and this.
60     * 
61     * @param property
62     */
63    public void addSubProperty(Property property);
64  
65    /**
66     * Removes a SuperPropertyOf relation between the given property and this.
67     * 
68     * @param property
69     */
70    public void removeSubProperty(Property property);
71  
72    /**
73     * Returns the set of domain restrictions for this property.
74     */
75    public Set getDomain();
76  
77    /**
78     * Gets the set of range restrictions for this property. If no range has been
79     * set it returns an empty set.
80     * 
81     * @return a set of {@link OClass} or {@link Class} objects.
82     */
83    public Set getRange();
84  
85    /**
86     * Checks whether this property can apply to the provided instance
87     * 
88     * @param instance
89     *          the instance
90     * @return <tt>true</tt> if the property is valid for the instance.
91     */
92    public boolean isValidDomain(OntologyResource instance);
93  
94    /**
95     * 
96     * @param value
97     * @return true if this value is compatible with the range restrictions on the
98     *         property. False otherwise.
99     */
100   public boolean isValidRange(Object value);
101 
102   /**
103    * Answers whether this property is a functional property. Functional
104    * properties are the ones that can have at most one value for any given value
105    * from the domain. Both object properties and datatype properties can be
106    * functional.
107    * 
108    * @return <tt>true</tt> if this property is functional.
109    */
110   public boolean isFunctional();
111 
112   /**
113    * Sets the functional property flag on this property.
114    * 
115    * @param functional
116    *          <tt>true</tt> iff the property should be marked as functional.
117    */
118   public void setFunctional(boolean functional);
119 
120   /**
121    * Answers whether this property is an inverse functional property. Inverse
122    * functional properties are the ones that for any given domain value there
123    * can be at most one range value that is valid for this property. Both object
124    * properties and datatype properties can be inverse functional.
125    * 
126    * @return <tt>true</tt> if this property is inverse functional.
127    */
128   public boolean isInverseFunctional();
129 
130   /**
131    * Sets the inverse functional property flag on this property.
132    * 
133    * @param inverseFunctional
134    *          <tt>true</tt> iff the property should be marked as inverse
135    *          functional.
136    */
137   public void setInverseFunctional(boolean inverseFunctional);
138 
139   /**
140    * Gets the set of super-properties for this property.
141    * 
142    * @param {@link OntologyConstants#DIRECT_CLOSURE}
143    *          for direct super-properties only or
144    *          {@link OntologyConstants#TRANSITIVE_CLOSURE} for all the
145    *          super-properties.
146    * @return a set of {@link Property} values.
147    */
148   public Set getSuperProperties(byte closure);
149 
150   /**
151    * Gets the set of sub-properties for this property.
152    * 
153    * @param {@link OntologyConstants#DIRECT_CLOSURE}
154    *          for direct sub-properties only or
155    *          {@link OntologyConstants#TRANSITIVE_CLOSURE} for all the
156    *          sub-properties.
157    * @return a set of {@link Property} values.
158    */
159   public Set getSubProperties(byte closure);
160 }