com.sdm.quasar.client.core.common.hierarchy
Interface HierarchyProvider

All Known Subinterfaces:
DialogHierarchyService, HierarchyManager
All Known Implementing Classes:
DefaultDialogHierarchyService, DefaultHierarchyManager

public interface HierarchyProvider

Provides a hierarchy organized as a tree of IDs. The hierarchy is managed using only the IDs of the entities and their parent-child relationship. The hierarchy provider implies no meaning concerning these ids.

See com.sdm.quasar.client.comp.dlgdef.ctrl.DialogController for a description concerning the way the hierarchy manager is used to organize dialogs of the session.

Note: Implementations of this interface must be threadsafe.

Version:
1.0
Author:
Martin Haft, sd&m AG, Carsten Lucke, sd&m AG, Bernd Olleck, sd&m AG

Method Summary
 void addHierarchyProviderListener(HierarchyProviderListener listener)
          Registers a listener that observes changes in the hierarchy.
 int getChildCount(ID parentId, boolean deep, boolean leafesOnly)
          Returns the number of childs for the given parent id.
 ID[] getChildren(ID parentId)
          Returns the children of a node.
 ID getParentForChild(ID id)
          Returns the parent id of a node.
 ID[] getRoots()
          Returns the root nodes.
 boolean hasID(ID id)
          Tests whether a given ID is known in the hierarchy either as a parent or as a child.
 boolean isChild(ID id1, ID id2, boolean deep)
          Checks if id2 is a child of id1.
 void removeHierarchyProviderListener(HierarchyProviderListener listener)
          Unregisters a listener.
 

Method Detail

hasID

public boolean hasID(ID id)
Tests whether a given ID is known in the hierarchy either as a parent or as a child.

Parameters:
id - the id to be tested
Returns:
true iff the node is registered in the hierarchy

getChildren

public ID[] getChildren(ID parentId)
Returns the children of a node. The returned array is a copy, any modifications made to the hierarchy will not affect the returned set.

Parameters:
parentId - the id of the parent node
Returns:
an array with the IDs of the children
Throws:
java.lang.IllegalArgumentException - if the parent id is unknown

getParentForChild

public ID getParentForChild(ID id)
Returns the parent id of a node.

Parameters:
id - the id of the child node
Returns:
the id of the parent node or null, if the child has no parent
Throws:
java.lang.IllegalArgumentException - if the id is unknown

isChild

public boolean isChild(ID id1,
                       ID id2,
                       boolean deep)
Checks if id2 is a child of id1. The check is done down the whole sub hierarchy of id1 if deep = true. Else only direct childs are considered.

Parameters:
id1 - the potential parent
id2 - the potential child
deep - true: The check is done down the whole sub hierarchy false: only direct childs are considered
Returns:
true, if

getChildCount

public int getChildCount(ID parentId,
                         boolean deep,
                         boolean leafesOnly)
Returns the number of childs for the given parent id.

Parameters:
parentId - the ID of the parent to count childs of
deep - if true, the whole subtree will be counted, if false, only direct childs are counted
leafesOnly - if true, the returned number is restricted to leafes (childs, that have no childs themselfes)
Returns:
the number of children of the specified parent node

getRoots

public ID[] getRoots()
Returns the root nodes. The returned array is a copy, any modifications made to the hierarchy will not affect the returned value.

Returns:
an array with the IDs of the root nodes.

addHierarchyProviderListener

public void addHierarchyProviderListener(HierarchyProviderListener listener)
Registers a listener that observes changes in the hierarchy.

Parameters:
listener - the listener to be added

removeHierarchyProviderListener

public void removeHierarchyProviderListener(HierarchyProviderListener listener)
Unregisters a listener.

Parameters:
listener - the listener to be removed