public class DefaultTreeTable extends Object implements TreeTable, Cloneable, Serializable
TreeTable
implementation with a list of columns given at
construction time. The list of columns is unmodifiable, but the root node
can be modified.
Example:
Thepublic class CityLocation { public static final TableColumn<String> CITY_NAME = new TableColumn<>(String.class); public static final TableColumn<Float> LATITUDE = new TableColumn<>(Float .class); public static final TableColumn<Float> LONGTITUDE = new TableColumn<>(Float .class); public TreeTable createTable() { DefaultTreeTable table = new DefaultTreeTable(CITY_NAME, LATITUDE, LONGITUDE); TreeTable.Node city = table.getRoot(); city.setValue(CITY_NAME, "Rimouski"); city.setValue(LATITUDE, 48.470417); city.setValue(LONGITUDE, -68.521385); return table; } }
setRoot(…)
method accepts arbitrary TreeTable.Node
implementations.
However it is likely to be safer and more memory efficient when used together with the
implementation provided in the DefaultTreeTable.Node
inner class.DefaultTreeTable.Node
,
TableColumn
,
Serialized FormDefined in the sis-utility
module
Modifier and Type | Class and Description |
---|---|
static class |
DefaultTreeTable.Node
A
TreeTable.Node implementation which can store values for a pre-defined list
of columns. |
Constructor and Description |
---|
DefaultTreeTable(DefaultTreeTable.Node root)
Creates a new tree table initialized to the given root.
|
DefaultTreeTable(TableColumn<?>... columns)
Creates a new tree table with the given columns.
|
Modifier and Type | Method and Description |
---|---|
DefaultTreeTable |
clone()
Returns a clone of this table.
|
boolean |
equals(Object other)
Compares the given object with this tree table for equality.
|
List<TableColumn<?>> |
getColumns()
Returns the table columns given at construction time.
|
TreeTable.Node |
getRoot()
Returns the root node.
|
int |
hashCode()
Returns a hash code value for this table.
|
void |
setRoot(TreeTable.Node root)
Sets the root to the given node.
|
String |
toString()
Returns a string representation of this tree table.
|
public DefaultTreeTable(TableColumn<?>... columns)
columns
- The list of table columns.public DefaultTreeTable(DefaultTreeTable.Node root)
root
- The tree table root (can not be null).public final List<TableColumn<?>> getColumns()
getColumns
in interface TreeTable
DefaultTreeTable.Node.getValue(TableColumn)
,
DefaultTreeTable.Node.setValue(TableColumn, Object)
public TreeTable.Node getRoot()
setRoot(TreeTable.Node)
method.public void setRoot(TreeTable.Node root)
root
- The new root node (can not be null).IllegalArgumentException
- If the table columns in the given node are inconsistent
with the table columns in this DefaultTreeTable
.public DefaultTreeTable clone() throws CloneNotSupportedException
DefaultTreeTable.Node
, then cloning the root will recursively clone
all its children.clone
in class Object
CloneNotSupportedException
- If this table, the root node or one of its children
can not be cloned.DefaultTreeTable.Node.clone()
public boolean equals(Object other)
DefaultTreeTable.Node
inner class, then all node values and children
will be compared recursively.equals
in class Object
other
- The object to compare with this table.true
if the two objects are equal.DefaultTreeTable.Node.equals(Object)
public int hashCode()
equals(Object)
contract.hashCode
in class Object
DefaultTreeTable.Node.hashCode()
public String toString()
TreeTableFormat
.
This is okay for debugging or occasional usages. However for more extensive usages,
developers are encouraged to create and configure their own TreeTableFormat
instance.Copyright © 2010–2015 The Apache Software Foundation. All rights reserved.