001 /*
002 * The contents of this file are subject to the Mozilla Public License
003 * Version 1.1 (the "License"); you may not use this file except in
004 * compliance with the License. You may obtain a copy of the License at
005 * http://www.mozilla.org/MPL/
006 *
007 * Software distributed under the License is distributed on an "AS IS" basis,
008 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
009 * the specific language governing rights and limitations under the License.
010 *
011 * The Original Code is Protege-2000.
012 *
013 * The Initial Developer of the Original Code is Stanford University. Portions
014 * created by Stanford University are Copyright (C) 2007. All Rights Reserved.
015 *
016 * Protege was developed by Stanford Medical Informatics
017 * (http://www.smi.stanford.edu) at the Stanford University School of Medicine
018 * with support from the National Library of Medicine, the National Science
019 * Foundation, and the Defense Advanced Research Projects Agency. Current
020 * information about Protege can be obtained at http://protege.stanford.edu.
021 *
022 */
023
024 package edu.stanford.smi.protegex.owl.model;
025
026 import edu.stanford.smi.protegex.owl.model.event.ClassListener;
027
028 import javax.swing.*;
029 import java.util.Collection;
030 import java.util.Set;
031
032 /**
033 * The base interface of the RDFS/OWL classes used by the OWL Plugin.
034 * All user-defined classes will be some instance of this interface.
035 *
036 * @author Holger Knublauch <holger@knublauch.com>
037 */
038 public interface RDFSClass extends ProtegeCls, RDFResource {
039
040
041 /**
042 * Adds a ClassListener to receive events about this RDFSClass.
043 *
044 * @param listener the ClassListener to add
045 */
046 void addClassListener(ClassListener listener);
047
048
049 /**
050 * Adds a class to the rdfs:subClassOfs of this.
051 *
052 * @param superclass
053 */
054 void addSuperclass(RDFSClass superclass);
055
056
057 /**
058 * Creates a copy of anonymous classes which contain a completely new expression tree.
059 * Named classes are NOT copied.
060 *
061 * @return a clone of this or the object itself for named classes
062 */
063 RDFSClass createClone();
064
065
066 /**
067 * Creates a new instance of this class.
068 *
069 * @param name the name of the new instance or null for a default name
070 * @return a new instance of this
071 */
072 RDFResource createInstance(String name);
073
074
075 /**
076 * Gets all OWLAnonymousClasses the life cycle of which depends on this.
077 * These are deleted when this is deleted.
078 * <p/>
079 * From existing usage, it appears that only the direct anonymous
080 * classes are required to be returned - these are then iterated over
081 *
082 * @return a Collection of OWLAnonymousClass instances
083 */
084 Collection getDependingClasses();
085
086
087 /**
088 * Gets a Collection of all directly equivalent Clses of this.
089 * These are those direct superclasses that also have this as direct superclass.
090 *
091 * @return a Collection of Cls objects
092 */
093 Collection getEquivalentClasses();
094
095
096 /**
097 * Gets an ImageIcon displaying this. This is a harder version of <CODE>getIcon()</CODE>
098 * for use when an ImageIcon is required.
099 *
100 * @return the ImageIcon
101 */
102 ImageIcon getImageIcon();
103
104
105 /**
106 * Gets the number of direct inferred instances of this class.
107 * This is equivalent to <CODE>getInferredInstances(false).size()</CODE> but
108 * could be optimized internally for better performance.
109 *
110 * @return the number of inferred instances
111 * @see #getInferredInstances
112 */
113 int getInferredInstanceCount();
114
115
116 /**
117 * Gets all resources that have this as their inferred type.
118 * Optionally, it is possible to include subclasses of this into the search.
119 *
120 * @param includingSubclasses true to include instances of subclasses of this
121 * @return the inferred instances of this
122 */
123 Collection getInferredInstances(boolean includingSubclasses);
124
125
126 /**
127 * Gets the number of instances of this, possibly including the instances of all subclasses.
128 *
129 * @param includingSubclasses true to also include the instances of the subclasses
130 * @return the number of instances of this
131 */
132 int getInstanceCount(boolean includingSubclasses);
133
134
135 /**
136 * Gets the instances of this, possibly including the instances of all subclasses.
137 *
138 * @param includingSubclasses true to also get the instances of the subclasses
139 * @return the instances of this
140 */
141 Collection getInstances(boolean includingSubclasses);
142
143
144 /**
145 * Gets a Collection of all direct subclasses that are not anonymous.
146 * (This is a convenience method for getNamedSubclasses(false))
147 *
148 * @return a Collection of Cls objects
149 */
150 Collection getNamedSubclasses();
151
152
153 /**
154 * Gets the named subclasses of this class.
155 *
156 * @param transitive true to include the descendent classes
157 * or false to only include the direct named subclasses
158 * @return a Collection of RDFSNamedClass objects.
159 */
160 Collection getNamedSubclasses(boolean transitive);
161
162
163 /**
164 * Gets a Collection of all direct superclasses that are not anonymous.
165 * (This is a convenience method for getNamedSuperclasses(false))
166 *
167 * @return a Collection of Cls objects
168 */
169 Collection getNamedSuperclasses();
170
171
172 /**
173 * Gets the superclasses of this class.
174 *
175 * @param transitive true to include the ancestor classes
176 * or false to only include the direct named superclasses
177 * @return A Collection of RDFSNamedClass objects.
178 */
179 Collection getNamedSuperclasses(boolean transitive);
180
181
182 /**
183 * Gets the browser text when this is embedded into a complex expression.
184 * This usually returns the browser key enclosed with round brackets.
185 *
186 * @return the nested browser text
187 */
188 String getNestedBrowserText();
189
190
191 /**
192 * Gets all RDFSClses that are somewhere used in the expression below this.
193 * If this is an anonymous class, this traverses the expression tree to
194 * collect them. If this is already an RDFSNamedClass, it will return itself.
195 *
196 * @param set an (initially empty) Set that will contain the nested named classes
197 */
198 void getNestedNamedClasses(Set set);
199
200
201 /**
202 * @deprecated not needed anymore
203 */
204 String getParsableExpression();
205
206
207 /**
208 * Gets the subset of those direct superclasses which are not at the same
209 * time equivalent classes (or operands of equivalent intersection classes).
210 * Note that equivalent classes are superclasses of each other, so that in
211 * many cases you may want to use this method instead of
212 * <CODE>getSuperclasses(false)</CODE>.
213 *
214 * @return the direct superclasses
215 */
216 Collection getPureSuperclasses();
217
218
219 /**
220 * Gets the number of (direct) subclasses of this.
221 *
222 * @return the number of classes with this as a rdfs:subClassOf value
223 */
224 int getSubclassCount();
225
226
227 /**
228 * Gets the subclasses of this, including the subclasses of the subclasses etc.
229 *
230 * @return the subclass values
231 */
232 Collection getSubclasses(boolean transitive);
233
234
235 /**
236 * Gets the number of (direct) superclasses of this.
237 *
238 * @return the number of rdfs:subClassOf values
239 */
240 int getSuperclassCount();
241
242
243 /**
244 * Gets the superclasses of this, optionally including the superclasses of the superclasses etc.
245 *
246 * @return the rdfs:subClassOf values
247 */
248 Collection getSuperclasses(boolean transitive);
249
250
251 /**
252 * Equivalent to <CODE>getUnionDomainProperties(false)</CODE>.
253 *
254 * @return the properties that have this in their (direct) domain
255 */
256 Collection getUnionDomainProperties();
257
258
259 /**
260 * Gets those properties that have this in their domain, with union semantics.
261 * If the argument is true, then this will also consider those properties that have
262 * superclasses of this in their domain.
263 *
264 * @param transitive true to include superclasses
265 * @return a Collection of RDFProperty objects
266 */
267 Collection getUnionDomainProperties(boolean transitive);
268
269
270 /**
271 * Checks whether this is a (direct) equivalent class of a given other Cls.
272 *
273 * @param other the Cls to compare with
274 * @return true if other is among the direct equivalent classes
275 */
276 boolean hasEquivalentClass(RDFSClass other);
277
278
279 /**
280 * For an object-valued property, checks whether one of the property values has a
281 * given browser text.
282 *
283 * @param property the property (must not have datatype literals as values)
284 * @param browserText the browser text to compare to
285 * @return true if one of the values of the property matches
286 */
287 boolean hasPropertyValueWithBrowserText(RDFProperty property, String browserText);
288
289
290 /**
291 * Checks whether this is an anonymous class. All classes except for instances
292 * of OWLNamedClass are anonymous.
293 *
294 * @return true if this is anonymous
295 */
296 boolean isAnonymous();
297
298
299 /**
300 * Checks whether this is a metaclass, i.e. whether it is a subclass of rdfs:Class.
301 *
302 * @return true if this is a metaclass
303 */
304 boolean isMetaclass();
305
306
307 /**
308 * Checks whether this is a (direct) subclass of a given class.
309 *
310 * @param superclass the superclass in question
311 * @return true if this has superclass among its rdfs:subClassOf values
312 */
313 boolean isSubclassOf(RDFSClass superclass);
314
315
316 /**
317 * Removes a ClassListener to receive events about this RDFSClass.
318 *
319 * @param listener the ClassListener to remove
320 */
321 void removeClassListener(ClassListener listener);
322
323
324 /**
325 * Removes a given class from the superclasses of this.
326 *
327 * @param superclass the superclass to remove
328 */
329 void removeSuperclass(RDFSClass superclass);
330 }
331