org.omnaest.utils.structure.hierarchy
Class TokenMonoHierarchy.Navigator

java.lang.Object
  extended by org.omnaest.utils.structure.hierarchy.TokenMonoHierarchy.Navigator
Enclosing class:
TokenMonoHierarchy<E,V>

public class TokenMonoHierarchy.Navigator
extends Object

The TokenMonoHierarchy.Navigator allows to navigate on a given TokenMonoHierarchy

Author:
Omnaest

Field Summary
protected  boolean navigationSuccessful
           
protected  TokenMonoHierarchy.TokenElementNode tokenElementNode
           
 
Constructor Summary
protected TokenMonoHierarchy.Navigator(TokenMonoHierarchy.TokenElementNode tokenElementNode)
           
 
Method Summary
protected  TokenMonoHierarchy.Navigator addValuesToCurrentNode(V... values)
          Adds values to the current node
protected  TokenMonoHierarchy.TokenElementNode determineSiblingTokenElementNode(int relativeIndexPosition)
           
 List<E> determineTokenPathElementList()
          Determines the List of token path elements which represents the current hierarchy path.
 E getTokenElement()
          Returns the current token element
 List<E> getTokenElementOfChildrenList()
          Returns a List with all token elements of the children.
 List<V> getValues()
          Returns the values of the current node
 boolean hasChildren()
          Returns true if the current node has children
 boolean hasNextSibling()
          Returns true if the current node has a next sibling
 boolean hasParent()
          Returns true if the current node has a parent
 boolean hasPreviousSibling()
          Returns true if the current node has a previous sibling
 boolean hasSibling(int relativeIndexPosition)
          Returns true if the current node has a sibling a the given relative index position.
 boolean hasValues()
          Returns true if the current node has at least one value
 boolean isNavigationSuccessful()
          Returns true if the last navigation was successful.
 TokenMonoHierarchy.Navigator navigateToChild(E tokenElement)
          Navigates the current TokenMonoHierarchy.Navigator to the given child token element.
protected  TokenMonoHierarchy.Navigator navigateToChildAndCreateItIfNotExisting(E tokenElement)
          Navigates the current TokenMonoHierarchy.Navigator to the given child token element.
 TokenMonoHierarchy.Navigator navigateToFirstChild()
          Navigates the current TokenMonoHierarchy.Navigator to the first child token element.
 TokenMonoHierarchy.Navigator navigateToNextNodeWithValues()
          Navigates to the next node which hasValues().
 TokenMonoHierarchy.Navigator navigateToNextSibling()
          Navigates to the next sibling
 TokenMonoHierarchy.Navigator navigateToParent()
          Navigates the current TokenMonoHierarchy.Navigator to its parent
 TokenMonoHierarchy.Navigator navigateToPreviousSibling()
          Navigates to the previous sibling
 TokenMonoHierarchy.Navigator navigateToSibling(int relativeIndexPosition)
          Navigates to a relative position within the siblings.
 TokenMonoHierarchy.Navigator newNavigatorFork()
          Returns a new TokenMonoHierarchy.Navigator instance based on the current navigation position.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

tokenElementNode

protected TokenMonoHierarchy.TokenElementNode tokenElementNode

navigationSuccessful

protected boolean navigationSuccessful
Constructor Detail

TokenMonoHierarchy.Navigator

protected TokenMonoHierarchy.Navigator(TokenMonoHierarchy.TokenElementNode tokenElementNode)
Parameters:
tokenElementNode -
See Also:
TokenMonoHierarchy.Navigator
Method Detail

newNavigatorFork

public TokenMonoHierarchy.Navigator newNavigatorFork()
Returns a new TokenMonoHierarchy.Navigator instance based on the current navigation position. This new TokenMonoHierarchy.Navigator will not affect the current TokenMonoHierarchy.Navigator instance.

Returns:

getTokenElement

public E getTokenElement()
Returns the current token element

Returns:

getTokenElementOfChildrenList

public List<E> getTokenElementOfChildrenList()
Returns a List with all token elements of the children.

Returns:

determineTokenPathElementList

public List<E> determineTokenPathElementList()
Determines the List of token path elements which represents the current hierarchy path.

Returns:

hasValues

public boolean hasValues()
Returns true if the current node has at least one value

Returns:

navigateToNextNodeWithValues

public TokenMonoHierarchy.Navigator navigateToNextNodeWithValues()
Navigates to the next node which hasValues(). The navigation occurs at first through all children and their children and then to the next siblings until the whole hierarchy is traversed.

Returns:
See Also:
isNavigationSuccessful()

navigateToNextSibling

public TokenMonoHierarchy.Navigator navigateToNextSibling()
Navigates to the next sibling

Returns:

navigateToPreviousSibling

public TokenMonoHierarchy.Navigator navigateToPreviousSibling()
Navigates to the previous sibling

Returns:

navigateToSibling

public TokenMonoHierarchy.Navigator navigateToSibling(int relativeIndexPosition)
Navigates to a relative position within the siblings. A relative index position of 0 point at the current node.

Parameters:
relativeIndexPosition -
Returns:

hasNextSibling

public boolean hasNextSibling()
Returns true if the current node has a next sibling

Returns:

hasPreviousSibling

public boolean hasPreviousSibling()
Returns true if the current node has a previous sibling

Returns:

hasSibling

public boolean hasSibling(int relativeIndexPosition)
Returns true if the current node has a sibling a the given relative index position.

Parameters:
relativeIndexPosition -
Returns:

determineSiblingTokenElementNode

protected TokenMonoHierarchy.TokenElementNode determineSiblingTokenElementNode(int relativeIndexPosition)
Parameters:
relativeIndexPosition -
Returns:

hasChildren

public boolean hasChildren()
Returns true if the current node has children

Returns:

hasParent

public boolean hasParent()
Returns true if the current node has a parent

Returns:

navigateToChildAndCreateItIfNotExisting

protected TokenMonoHierarchy.Navigator navigateToChildAndCreateItIfNotExisting(E tokenElement)
Navigates the current TokenMonoHierarchy.Navigator to the given child token element. If no child token element exists it will be created before.

Parameters:
tokenElement -
Returns:
this

navigateToChild

public TokenMonoHierarchy.Navigator navigateToChild(E tokenElement)
Navigates the current TokenMonoHierarchy.Navigator to the given child token element.

Parameters:
tokenElement -
Returns:
this

navigateToFirstChild

public TokenMonoHierarchy.Navigator navigateToFirstChild()
Navigates the current TokenMonoHierarchy.Navigator to the first child token element.

Parameters:
tokenElement -
Returns:
this

addValuesToCurrentNode

protected TokenMonoHierarchy.Navigator addValuesToCurrentNode(V... values)
Adds values to the current node

Parameters:
values -
Returns:
this

getValues

public List<V> getValues()
Returns the values of the current node

Returns:

navigateToParent

public TokenMonoHierarchy.Navigator navigateToParent()
Navigates the current TokenMonoHierarchy.Navigator to its parent

Returns:
this

isNavigationSuccessful

public boolean isNavigationSuccessful()
Returns true if the last navigation was successful.

Returns:
See Also:
navigateToChild(Object), navigateToParent()

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2013. All Rights Reserved.