public class Relationships<N> extends Object
Tree
.
The following definitions should help you understand the meaning of Relationships
properties:
Modifier and Type | Field and Description |
---|---|
static String |
CHILD
if the current node is a child of the base node
|
static String |
CURRENT
the state if the current node is the base node
|
static String |
DEFAULT
This is the default state.
|
static String |
IN_PATH
has this state if the current node is ancestor of base node-
|
static int |
INVALID_DISTANCE
if it is imposible to compute the distance it will get this distance.
|
static String |
PARENT_IN_PATH
has this state if the current node is a child of a node that has the
state
IS_IN_PATH |
static String |
ROOT
the state if the current node is the root node
|
static String |
SIBLING
the state if the current node is a sibling to the base node
|
Modifier | Constructor and Description |
---|---|
protected |
Relationships(N pBase,
N pCurrent,
Tree<N> pTree)
Constructs a RelationShips.
|
protected |
Relationships(N pBase,
N pCurrent,
Tree<N> pTree,
View<N> view)
Full constructor.
|
Modifier and Type | Method and Description |
---|---|
int |
getDistance()
Returns the distance (that is, number of steps) between the current node and the base node.
|
boolean |
getHasNoChildren()
Returns
true if the current node has no children. |
int |
getLevel()
Returns the level of the current node (the distance
from the current node to the root-node).
|
int |
getRelativeDistance()
Returns the relative distance between the current node and the base node.
|
int |
getRelativeLevel()
Returns the level of the current node relative to
to the base node.
|
String |
getState()
Returns a description of the current node's relationship to the base node.
|
boolean |
isAncestor()
Returns
true if the current node is an ancestor of the base node. |
boolean |
isBase()
Returns
true if the current node is the node. |
boolean |
isChild()
Returns
true if the current node is a child of the base node. |
boolean |
isChildInView()
Returns
true if the current node has children in the view. |
boolean |
isDescendant()
Returns
true if the current node is a descendant of the base node. |
boolean |
isFirst()
Returns
true if the current node has no preceding siblings. |
boolean |
isFirstChild()
Returns
true if the current node has no preceding siblings. |
boolean |
isFirstInView()
Returns
true if the current node is the first node in the view. |
boolean |
isLast()
Returns
true if the current node has no following siblings. |
boolean |
isLastChild()
Returns
true if the current node has no following siblings. |
boolean |
isLastInView()
Returns
true if the current node is the last node in the view. |
boolean |
isNextInView()
Returns
true if the current node's following sibling is in the view. |
boolean |
isOnlyChild()
Returns
true if the current node has no siblings (that is, if it is
either the only child of its parent or the root node). |
boolean |
isParent()
Returns
true if the current node is the parent of the base node. |
boolean |
isPreviousInView()
Returns
true if the current node's preceding sibling is in the view. |
boolean |
isRoot()
Returns
true if the current node is the root. |
boolean |
isSibling()
Returns
true if the current node is a sibling of the base node. |
boolean |
isUnrelated()
Returns
true if the current node is not related to the base
node. |
public static final int INVALID_DISTANCE
public static final String IN_PATH
public static final String CURRENT
public static final String ROOT
public static final String SIBLING
public static final String CHILD
public static final String PARENT_IN_PATH
IS_IN_PATH
public static final String DEFAULT
protected Relationships(N pBase, N pCurrent, Tree<N> pTree)
pBase
- the base node.pCurrent
- the target node.pTree
- the tree to traverse.public boolean isOnlyChild()
true
if the current node has no siblings (that is, if it is
either the only child of its parent or the root node).true
if it is the only child of its parent, or if this
is the root, which has no siblings. false
if not.public boolean isFirstChild()
true
if the current node has no preceding siblings.true
if it is the only child of its parent, or if this
is the root, which has no siblings, or if the parent's first child
is equal to this one..public boolean isLastChild()
true
if the current node has no following siblings.true
if it is the only child of its parent, or if this
is the root, which has no siblings, or if the parent's last child
is equal to this one. false
if none of the rules apply.public boolean isBase()
true
if the current node is the node.true
if current is the base. false
if not.public boolean isSibling()
true
if the current node is a sibling of the base node.true
if the current has the same parent as the base, but the base node is not the same as the current.public boolean isParent()
true
if the current node is the parent of the base node.true
if the base's parent is the current node.public boolean isChild()
true
if the current node is a child of the base node.true
if the current's parent is the base node.public boolean isAncestor()
true
if the current node is an ancestor of the base node.true
if the base's parent is the current node,
or if the base node's parent's parent is the current node etc.public boolean isDescendant()
true
if the current node is a descendant of the base node.true
if the current node's parent is the base node,
or if the current node's parent's parent is the current node etc.public int getDistance()
public int getRelativeDistance()
isAncestor()
,
isBase()
, isChild()
, isDescendant()
or isParent()
returns true
.public boolean isUnrelated()
true
if the current node is not related to the base
node. A node is related to base node if it is an ancestor, a descendant
or a sibling.true
if not related to the base node, else false
public int getLevel()
public int getRelativeLevel()
public boolean isRoot()
true
if the current node is the root.public String getState()
CURRENT
if isBase()
return true
.
ROOT
if isRoot()
return true
.
IN_PATH
if both isAncestor()
return true
and isParent()
return true
.
CHILD
if isChild()
return true
.
SIBLING
if isSibling()
return true
.
PARENT_IN_PATH
if parent of current isAncestor()
return true
OR isRoot()
return true
.
public boolean getHasNoChildren()
true
if the current node has no children.true
if the current node has no children,
false
otherwise.public boolean isFirst()
true
if the current node has no preceding siblings.true
if the current node is the first node on a level,
false
otherwise.public boolean isLast()
true
if the current node has no following siblings.true
if the current node is the last node on a level,
false
otherwise.public boolean isFirstInView()
true
if the current node is the first node in the view.true
if the current node is the first node in the view.public boolean isLastInView()
true
if the current node is the last node in the view.true
if the current node is the last node in the view.public boolean isChildInView()
true
if the current node has children in the view.true
if the current node has children in the view.public boolean isPreviousInView()
true
if the current node's preceding sibling is in the view.true
if the current node's parent is in the view.public boolean isNextInView()
true
if the current node's following sibling is in the view.true
if the current node's next node is in the view.© 1998- 2018 Stibo DX