net.ontopia.topicmaps.utils
Class TypeHierarchyUtils

java.lang.Object
  extended by net.ontopia.topicmaps.utils.TypeHierarchyUtils

public class TypeHierarchyUtils
extends java.lang.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
TypeHierarchyUtils()
          INTERNAL: Creates and initialises a new instance of the utility class.
 
Method Summary
 java.util.Collection<TopicIF> getSubclasses(TopicIF klass)
          INTERNAL: Returns the topics which are subtypes of the topic klass.
 java.util.Collection<TopicIF> getSubclasses(TopicIF klass, int level)
          INTERNAL: Returns the topics which are subtypes of the given typing topic down to a given level.
 java.util.Collection<TopicIF> getSuperclasses(TopicIF klass)
          INTERNAL: Returns the topics which are supertypes of the given typing topic
 java.util.Collection<TopicIF> getSuperclasses(TopicIF klass, int level)
          INTERNAL: Returns the topics which are supertypes of the given typing topic up to a given level.
 java.util.Collection<TopicIF> getSupertypes(TopicIF typed)
          INTERNAL: Returns the topics which types of the object typed and all their supertypes.
 java.util.Collection<TopicIF> getSupertypes(TopicIF typed, boolean excludeTypes)
          INTERNAL: Returns the topics which types the object typed (if not excludeTypes is set to true) and all their supertypes.
 java.util.Collection<TopicIF> getSupertypes(TypedIF typed)
          INTERNAL: Returns the topic which types the singly typed object typed 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 the typed is an instance of the type klass.
 boolean isInstanceOf(TypedIF typed, TopicIF klass)
          INTERNAL: Determines if the singly-typed object typed is an instance of the type klass.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TypeHierarchyUtils

public TypeHierarchyUtils()
INTERNAL: Creates and initialises a new instance of the utility class.

Method Detail

isInstanceOf

public boolean isInstanceOf(TypedIF typed,
                            TopicIF klass)
INTERNAL: Determines if the singly-typed object typed is an instance of the type klass. This function returns true if typed is a direct instance of klass or if it is an instance of some subtype of klass.

Parameters:
typed - the given typedIF object
klass - 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 the typed is an instance of the type klass. This function returns true if typed is a direct instance of klass or if it is an instance of some subclass of klass.

Parameters:
typed - the given typedIF object
klass - 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 java.util.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 java.util.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 topic
level - 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 java.util.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 java.util.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 topic
level - 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 java.util.Collection<TopicIF> getSupertypes(TypedIF typed)
INTERNAL: Returns the topic which types the singly typed object typed 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 java.util.Collection<TopicIF> getSupertypes(TopicIF typed)
INTERNAL: Returns the topics which types of the object typed 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 java.util.Collection<TopicIF> getSupertypes(TopicIF typed,
                                                   boolean excludeTypes)
INTERNAL: Returns the topics which types the object typed (if not excludeTypes is set to true) and all their supertypes.

Parameters:
typed - a topic
excludeTypes - 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


Copyright © 2000-2012 Ontopia.