public class AssociationWalker extends Object
Modifier and Type | Field and Description |
---|---|
protected Predicate<AssociationIF> |
assocDecider
PROTECTED: The decider used to filter associations to only those
which are being walked
|
protected Predicate<AssociationRoleIF> |
leftRoleDecider
PROTECTED: The decider used to filter the left-hand role of the
transitive association
|
protected List<AssociationWalkerListenerIF> |
listeners
PROTECTED: The listeners to be informed as the walker processes
the topic map.
|
protected Predicate<AssociationRoleIF> |
rightRoleDecider
PROTECTED: The decider used to filter the right-hand role of the
transitive association.
|
Constructor and Description |
---|
AssociationWalker(Predicate<AssociationIF> assocDecider,
Predicate<AssociationRoleIF> fromRoleDecider,
Predicate<AssociationRoleIF> toRoleDecider)
PUBLIC: Creates a walker which uses deciders to traverse the associations.
|
AssociationWalker(TopicIF associationType,
TopicIF leftRoleSpec,
TopicIF rightRoleSpec)
PUBLIC: Creates a walker which determines that a topic A is
related to topic B if A plays a role specified by
leftRoleSpec in an association of type
associationType and topic B plays a role specified
by rightRoleSpec in the same association. |
Modifier and Type | Method and Description |
---|---|
void |
addListener(AssociationWalkerListenerIF listener)
PUBLIC: Registers a listener with the walker.
|
protected void |
foundLeaf(net.ontopia.topicmaps.utils.WalkerState state)
PROTECTED: Invoked when the walker encounters the end of a
transitive association path.
|
boolean |
isAssociated(TopicIF start,
TopicIF associated)
PUBLIC: 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.
|
void |
removeListener(AssociationWalkerListenerIF listener)
PUBLIC: Unregisters a listener with the walker.
|
protected net.ontopia.topicmaps.utils.WalkerState |
walk(TopicIF start,
boolean storePaths)
PROTECTED: Computes the transitive closure under the association
type and rolespec definitions provided in the constructor; this
method is used by both walkTopics and walkPaths.
|
Collection<List<TMObjectIF>> |
walkPaths(TopicIF start)
PUBLIC: Computes the transitive closure under the association
type and rolespec definitions provided in the constructor, and
returns a set containing the paths taken through the topic map in
computing the closure.
|
Set<TopicIF> |
walkTopics(TopicIF start)
PUBLIC: Computes the transitive closure under the association
type and rolespec definitions provided in the constructor, and
returns the result as a set of topics.
|
protected Predicate<AssociationIF> assocDecider
protected Predicate<AssociationRoleIF> leftRoleDecider
protected Predicate<AssociationRoleIF> rightRoleDecider
protected List<AssociationWalkerListenerIF> listeners
public AssociationWalker(TopicIF associationType, TopicIF leftRoleSpec, TopicIF rightRoleSpec)
leftRoleSpec
in an association of type
associationType
and topic B plays a role specified
by rightRoleSpec
in the same association.associationType
- The given association type; an object
implementing TopicIF.leftRoleSpec
- The first given association rolespec; an
object implementing TopicIF.rightRoleSpec
- The second given association rolespec; an
object implementing TopicIF.public AssociationWalker(Predicate<AssociationIF> assocDecider, Predicate<AssociationRoleIF> fromRoleDecider, Predicate<AssociationRoleIF> toRoleDecider)
assocDecider
- ; an object implementing DeciderIF.fromRoleDecider
- ; an object implementing DeciderIF.toRoleDecider
- ; an object implementing DeciderIF.public Set<TopicIF> walkTopics(TopicIF start)
start
- The topic to start the computation from; an object
implementing TopicIF.public Collection<List<TMObjectIF>> walkPaths(TopicIF start)
start
- The topic to start the computation from; an object
implementing TopicIF.protected net.ontopia.topicmaps.utils.WalkerState walk(TopicIF start, boolean storePaths)
storePaths
parameter is false
then the
walker will collect only the set of topics which form the
transitive closure and will not store the individual paths
discovered.start
- The topic to start the computation from; an object
implementing TopicIF.storePaths
- Boolean: if true, store paths walked; if
false, store only topics found.protected void foundLeaf(net.ontopia.topicmaps.utils.WalkerState state)
state
- A WalkerState object; the current state of the walk.public boolean isAssociated(TopicIF start, TopicIF associated)
start
- The topic to begin computation from; an object implementing TopicIF.associated
- The topic to be found in the association; an object implementing TopicIF.public void addListener(AssociationWalkerListenerIF listener)
listener
- The listener to be registered; an object
implementing AssociationWalkerListenerIF.AssociationWalkerListenerIF
public void removeListener(AssociationWalkerListenerIF listener)
listener
- The listener to be unregistered; an object
implementing AssociationWalkerListenerIF.AssociationWalkerListenerIF