public static class DefaultTreeTable.Node extends Object implements TreeTable.Node, Cloneable, Serializable
TreeTable.Node
implementation which can store values for a pre-defined list of columns.
The list of columns is specified by a TreeTable
, or inherited from a parent node.
getParent()
method is updated automatically when this node
is added to or removed from the list of children
of another Node
instance - there is no setParent(Node)
method. Since the parent
is inferred rather than user-specified, it is ignored by the clone()
,
equals(Object)
and hashCode()
methods.DefaultTreeTable
,
TableColumn
,
Serialized FormDefined in the sis-utility
module
Constructor and Description |
---|
Node(CharSequence name)
Creates a node with a single column for object names (convenience constructor).
|
Node(DefaultTreeTable.Node parent)
Creates a new node with the given parent.
|
Node(DefaultTreeTable.Node parent,
int index)
Creates a new node with the given parent.
|
Node(TreeTable table)
Creates a new node for the given table.
|
Modifier and Type | Method and Description |
---|---|
DefaultTreeTable.Node |
clone()
Returns a clone of this node without parent.
|
boolean |
equals(Object other)
|
List<TreeTable.Node> |
getChildren()
Returns the children of this node.
|
TreeTable.Node |
getParent()
Returns the parent of this node.
|
Object |
getUserObject()
Returns the user object associated to this node.
|
<V> V |
getValue(TableColumn<V> column)
Returns the value in the given column, or
null if none. |
int |
hashCode()
|
boolean |
isEditable(TableColumn<?> column)
Determines whether the value in the specified column is editable.
|
boolean |
isLeaf()
Returns
true if this node can not have any children. |
DefaultTreeTable.Node |
newChild()
Adds a new child in the children list.
|
<V> void |
setValue(TableColumn<V> column,
V value)
Sets the value for the given column.
|
String |
toString()
Returns a string representation of this node for identification in error message or in debugger.
|
public Node(TreeTable table)
This method does not set the new node as the root of the given table. If desired, it is the caller responsibility to set the table root node.
table
- the table for which this node is created.public Node(DefaultTreeTable.Node parent)
parent
- the parent of the new node.public Node(DefaultTreeTable.Node parent, int index)
parent
- the parent of the new node.index
- the index where to add the new node in the parent list of children.public Node(CharSequence name)
Header | Type | Initial value |
---|---|---|
"Name" | CharSequence | name |
name
- the initial value for the "Name" column (can be null
).public final TreeTable.Node getParent()
Node
creation, this value may be initially
null
. It will be automatically set to a non-null value when this node will be
added as a child of another Node
instance.
Note that the parent is intentionally ignored by the clone()
,
equals(Object)
and hashCode()
methods.
getParent
in interface TreeTable.Node
null
if none.public boolean isLeaf()
true
if this node can not have any children. The default implementation
unconditionally returns false
even if the list of children is empty, because the
list is allowed to grow at any time.
Subclasses can override this method if they can determine which nodes are leaves. In the current implementation, the return value shall be stable (i.e. a node can not alternate between leaf and non-leaf state). However this restriction may be relaxed in a future SIS version.
isLeaf
in interface TreeTable.Node
true
if this node can not have any children.public final List<TreeTable.Node> getChildren()
Node
instance added to or removed from the list.
For leaf nodes, this method returns an unmodifiable empty list.
getChildren
in interface TreeTable.Node
public DefaultTreeTable.Node newChild()
Node(Node)
constructor.
That constructor call has the following implications:
newChild
in interface TreeTable.Node
UnsupportedOperationException
- if this node is a leaf.public <V> V getValue(TableColumn<V> column)
null
if none.getValue
in interface TreeTable.Node
V
- the base type of values in the given column.column
- identifier of the column from which to get the value.null
if none.TreeTable.getColumns()
public <V> void setValue(TableColumn<V> column, V value) throws IllegalArgumentException
isEditable(TableColumn)
method can be invoked before this setter method
for determining if the given column is modifiable.setValue
in interface TreeTable.Node
V
- the base type of values in the given column.column
- identifier of the column into which to set the value.value
- the value to set.IllegalArgumentException
- if the given column is not a legal column for this node.isEditable(TableColumn)
public boolean isEditable(TableColumn<?> column)
Node
instance, then this method
returns false
.isEditable
in interface TreeTable.Node
column
- the column to query.true
if the given column is a legal column for this Node
implementation and the corresponding value is editable, or false
otherwise.public Object getUserObject()
null
.getUserObject
in interface TreeTable.Node
null
if none.public DefaultTreeTable.Node clone() throws CloneNotSupportedException
null
.clone
in class Object
CloneNotSupportedException
- if this node or one of its children can not be cloned.public boolean equals(Object other)
clone()
method, which can not clone the parent.equals
in interface TreeTable.Node
equals
in class Object
other
- the object to compare with this node.true
if the two objects are equal, ignoring the parent node.public int hashCode()
equals(Object)
contract.hashCode
in interface TreeTable.Node
hashCode
in class Object
public String toString()
toString()
value of the first non-empty
CharSequence
found in the values, if any.
If no such value is found, then this method returns "Node-i"
where Node is the simple classname
and i is the index of this node in the parent node.Copyright © 2010–2017 The Apache Software Foundation. All rights reserved.