public interface TreeModel extends Model
Modifier and Type | Field and Description |
---|---|
static String |
ROOT
Constant for root node.
|
Modifier and Type | Method and Description |
---|---|
void |
addModelListener(ModelListener l)
Registers given listener.
|
Object[] |
getChildren(Object parent,
int from,
int to)
Returns children for given parent on given indexes.
|
int |
getChildrenCount(Object node)
Returns the number of children for given node.
|
Object |
getRoot()
Returns the root node of the tree or null, if the tree is empty.
|
boolean |
isLeaf(Object node)
Returns true if node is leaf.
|
void |
removeModelListener(ModelListener l)
Unregisters given listener.
|
static final String ROOT
Object getRoot()
Object[] getChildren(Object parent, int from, int to) throws UnknownTypeException
This method works in pair with TreeModel.getChildrenCount(java.lang.Object)
, the to
parameter is up to the value that is returned from TreeModel.getChildrenCount(java.lang.Object)
.
If the list of children varies over time, the implementation code
needs to pay attention to bounds and check the from
and
to
parameters, especially if TreeModel.getChildrenCount(java.lang.Object)
returns Integer.MAX_VALUE
. Caching of the children between
TreeModel.getChildrenCount(java.lang.Object)
and TreeModel.getChildren(java.lang.Object, int, int)
can be used as well,
if necessary.
parent
- a parent of returned nodesfrom
- a start indexto
- a end indexUnknownTypeException
- if this TreeModel implementation is not
able to resolve children for given node typeTreeModel.getChildrenCount(java.lang.Object)
boolean isLeaf(Object node) throws UnknownTypeException
UnknownTypeException
- if this TreeModel implementation is not
able to resolve children for given node typeint getChildrenCount(Object node) throws UnknownTypeException
This method works in pair with TreeModel.getChildren(java.lang.Object, int, int)
, which gets
this returned value (or less) as the to
parameter. This method
is always called before a call to TreeModel.getChildren(java.lang.Object, int, int)
. This method can
return e.g. Integer.MAX_VALUE
when all children should be
loaded.
node
- the parent nodeUnknownTypeException
- if this TreeModel implementation is not
able to resolve children for given node typeTreeModel.getChildren(java.lang.Object, int, int)
void addModelListener(ModelListener l)
l
- the listener to addvoid removeModelListener(ModelListener l)
l
- the listener to remove