Package net.ontopia.topicmaps.utils
Class TypeHierarchyUtils
- java.lang.Object
-
- net.ontopia.topicmaps.utils.TypeHierarchyUtils
-
public class TypeHierarchyUtils extends Object
INTERNAL: This class provides utility functions for traversing class hierarchies which are expressed using the Published Subject Indicators (PSIs) defined by the XTM 1.0 Specification. Operations provided by this class are not thread-safe.
-
-
Constructor Summary
Constructors Constructor Description TypeHierarchyUtils()
INTERNAL: Creates and initialises a new instance of the utility class.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Collection<TopicIF>
getSubclasses(TopicIF klass)
INTERNAL: Returns the topics which are subtypes of the topic klass.Collection<TopicIF>
getSubclasses(TopicIF klass, int level)
INTERNAL: Returns the topics which are subtypes of the given typing topic down to a given level.Collection<TopicIF>
getSuperclasses(TopicIF klass)
INTERNAL: Returns the topics which are supertypes of the given typing topicCollection<TopicIF>
getSuperclasses(TopicIF klass, int level)
INTERNAL: Returns the topics which are supertypes of the given typing topic up to a given level.Collection<TopicIF>
getSupertypes(TopicIF typed)
INTERNAL: Returns the topics which types of the objecttyped
and all their supertypes.Collection<TopicIF>
getSupertypes(TopicIF typed, boolean excludeTypes)
INTERNAL: Returns the topics which types the objecttyped
(if notexcludeTypes
is set to true) and all their supertypes.Collection<TopicIF>
getSupertypes(TypedIF typed)
INTERNAL: Returns the topic which types the singly typed objecttyped
and all of its supertypes.boolean
isAssociatedWith(TopicIF start, TopicIF associated)
INTERNAL: Returns true if the two topics are directly or indirectly associated under the association type and rolespec definitions provided in the constructor for this walker.boolean
isInstanceOf(TopicIF typed, TopicIF klass)
INTERNAL: Determines if thetyped
is an instance of the typeklass
.boolean
isInstanceOf(TypedIF typed, TopicIF klass)
INTERNAL: Determines if the singly-typed objecttyped
is an instance of the typeklass
.
-
-
-
Method Detail
-
isInstanceOf
public boolean isInstanceOf(TypedIF typed, TopicIF klass)
INTERNAL: Determines if the singly-typed objecttyped
is an instance of the typeklass
. This function returns true iftyped
is a direct instance ofklass
or if it is an instance of some subtype ofklass
.- Parameters:
typed
- the given typedIF objectklass
- a topicIF object; the given type- Returns:
- boolean; true iff the given typedIF is an instance of the given type or an instance of a subtype of the given type
-
isInstanceOf
public boolean isInstanceOf(TopicIF typed, TopicIF klass)
INTERNAL: Determines if thetyped
is an instance of the typeklass
. This function returns true iftyped
is a direct instance ofklass
or if it is an instance of some subclass ofklass
.- Parameters:
typed
- the given typedIF objectklass
- a topicIF object; the given type- Returns:
- boolean; true if the given object is an instance of the given type or an instance of a subtype of the given type
-
isAssociatedWith
public boolean isAssociatedWith(TopicIF start, TopicIF associated)
INTERNAL: Returns true if the two topics are directly or indirectly associated under the association type and rolespec definitions provided in the constructor for this walker. The calculation is performed using a depth-first traversal of the tree formed by the associations concerned, which aborts as soon as the associated topic is found.- Parameters:
start
- The topic to begin computation from; an object implementing TopicIF.associated
- The topic to be found in the association; an object implementing TopicIF.- Returns:
- Boolean: true if the given topics are directly or indirectly associated
-
getSuperclasses
public Collection<TopicIF> getSuperclasses(TopicIF klass)
INTERNAL: Returns the topics which are supertypes of the given typing topic- Parameters:
klass
- a topicIF; the given typing topic- Returns:
- an unmodifiable collection of topicIF objects; the supertypes of the given topic
-
getSuperclasses
public Collection<TopicIF> getSuperclasses(TopicIF klass, int level)
INTERNAL: Returns the topics which are supertypes of the given typing topic up to a given level. If the level is 1 only the immediate superclasses are returned, at level 2 immediate superclasses and their immediate superclasses are returned, and so on. To get all superclasses, regardless of level, use the variant of this method which has no numeric parameter.- Parameters:
klass
- a topicIF; the given typing topiclevel
- the level to which superclasses are to be found- Returns:
- an unmodifiable collection of topicIF objects; the supertypes of the given topic
- Since:
- 1.2.5
-
getSubclasses
public Collection<TopicIF> getSubclasses(TopicIF klass)
INTERNAL: Returns the topics which are subtypes of the topic klass.- Parameters:
klass
- a topicIF; the given typing topic- Returns:
- a collection of topicIF objects; the subtypes of the given topic
-
getSubclasses
public Collection<TopicIF> getSubclasses(TopicIF klass, int level)
INTERNAL: Returns the topics which are subtypes of the given typing topic down to a given level. If the level is 1 only the immediate subclasses are returned, at level 2 immediate subclasses and their immediate subclasses are returned, and so on. To get all subclasses, regardless of level, use the variant of this method which has no numeric parameter.- Parameters:
klass
- a topicIF; the given typing topiclevel
- the level to which subclasses are to be found- Returns:
- a collection of topicIF objects; the subtypes of the given topic
- Since:
- 1.2.5
-
getSupertypes
public Collection<TopicIF> getSupertypes(TypedIF typed)
INTERNAL: Returns the topic which types the singly typed objecttyped
and all of its supertypes.- Parameters:
typed
- a typedIF object- Returns:
- a collection of topicIF objects; the type and all supertypes of the given typedIF object.
-
getSupertypes
public Collection<TopicIF> getSupertypes(TopicIF typed)
INTERNAL: Returns the topics which types of the objecttyped
and all their supertypes.- Parameters:
typed
- a topic- Returns:
- a collection of topicIF objects; the type and all supertypes of the given object
-
getSupertypes
public Collection<TopicIF> getSupertypes(TopicIF typed, boolean excludeTypes)
INTERNAL: Returns the topics which types the objecttyped
(if notexcludeTypes
is set to true) and all their supertypes.- Parameters:
typed
- a topicexcludeTypes
- types of specified topic are not in returned collection- Returns:
- a collection of topicIF objects; the type and all supertypes of the given object
- Since:
- 1.1
-
-