twaver.model
Class DataBox<T extends Data>

java.lang.Object
  extended by twaver.model.HashList<T>
      extended by twaver.model.HashCollection<T>
          extended by twaver.model.DataBox<T>
Type Parameters:
T - 数据元素类型
All Implemented Interfaces:
java.lang.Iterable<T>, java.util.Collection<T>, IDataBox<T>, IHashCollection<T>, IHashList<T>, IHandler<ListEvent<T>>, IFilter<T>
Direct Known Subclasses:
AlarmBox, ElementBox, LayerBox

public class DataBox<T extends Data>
extends HashCollection<T>
implements IDataBox<T>

数据容器


Field Summary
protected  HashList<T> roots
          根层元素集合
 
Fields inherited from class twaver.model.HashList
dataList, dataMap
 
Constructor Summary
DataBox()
           
 
Method Summary
protected  boolean beforeDataPropertyChange(PropertyChangeEvent event)
          元素属性变化事件前
protected  void doAdd(int index, T data)
           
protected  boolean doRemove(int id, T data)
           
 boolean forEachByBreadthFirst(Action<Data> action)
          广度优先遍历
 boolean forEachByDepthFirst(Action<Data> action)
          深度优先遍历
 boolean forEachByDepthFirstReverse(Action<Data> action)
          深度优先反向遍历
 IDispatcher<PropertyChangeEvent> getDataChangeDispatcher()
           
 IDispatcher<ParentChangeEvent> getParentChangeDispatcher()
          元素父节点变化事件派发器
 T getRandomData()
          获取随机元素
 HashList<T> getRoots()
          根层元素原始集合
 IDispatcher<ListEvent<T>> getSelectionChangeDispatcher()
           
 SelectionModel<T> getSelectionModel()
           
protected  void onAdd(int index, T data)
          添加元素
protected  void onClear()
          容器被清空
protected  void onDataPropertyChange(PropertyChangeEvent event)
          元素属性变化时回调此函数
protected  void onParentChange(ParentChangeEvent event)
          父节点变化事件
protected  void onRemove(T data)
           
 java.util.List<T> toRoots()
          根层元素数组
 
Methods inherited from class twaver.model.HashCollection
_remove, accept, add, add, clearAll, getFilterDispatcher, getListChangeDispatcher, remove, setIndex, setListener
 
Methods inherited from class twaver.model.HashList
add, add, add, addAll, addLast, clear, contains, contains, containsAll, containsById, forEach, forEach, forEachReverse, getById, getByIndex, getDatas, getLastData, indexOf, isEmpty, iterator, remove, remove, removeAll, removeById, removeByIndex, retainAll, reverseIterator, set, set, size, sort, toArray, toArray, toDatas, toDatas
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface twaver.core.model.IHashCollection
getListChangeDispatcher
 
Methods inherited from interface twaver.core.model.IHashList
add, add, add, add, clearAll, contains, containsById, forEach, forEachReverse, getById, getByIndex, getDatas, getLastData, indexOf, isEmpty, remove, remove, removeById, reverseIterator, set, set, setIndex, size, toDatas
 
Methods inherited from interface java.lang.Iterable
iterator
 
Methods inherited from interface twaver.filter.IFilter
accept
 
Methods inherited from interface twaver.event.IHandler
setListener
 
Methods inherited from interface java.util.Collection
equals, hashCode
 

Field Detail

roots

protected HashList<T extends Data> roots
根层元素集合

Constructor Detail

DataBox

public DataBox()
Method Detail

getSelectionModel

public SelectionModel<T> getSelectionModel()
Specified by:
getSelectionModel in interface IDataBox<T extends Data>

beforeDataPropertyChange

protected boolean beforeDataPropertyChange(PropertyChangeEvent event)
元素属性变化事件前

Parameters:
event - 事件
Returns:
是否允许属性修改

onDataPropertyChange

protected void onDataPropertyChange(PropertyChangeEvent event)
元素属性变化时回调此函数

Parameters:
event - 元素属性变化事件

getDataChangeDispatcher

public IDispatcher<PropertyChangeEvent> getDataChangeDispatcher()
Specified by:
getDataChangeDispatcher in interface IDataBox<T extends Data>

getParentChangeDispatcher

public IDispatcher<ParentChangeEvent> getParentChangeDispatcher()
元素父节点变化事件派发器

Returns:
元素父节点变化事件派发器

getSelectionChangeDispatcher

public IDispatcher<ListEvent<T>> getSelectionChangeDispatcher()
Specified by:
getSelectionChangeDispatcher in interface IDataBox<T extends Data>

doAdd

protected void doAdd(int index,
                     T data)
Overrides:
doAdd in class HashList<T extends Data>

onAdd

protected void onAdd(int index,
                     T data)
添加元素

Parameters:
index - 序号
data - 元素

doRemove

protected boolean doRemove(int id,
                           T data)
Overrides:
doRemove in class HashList<T extends Data>

onRemove

protected void onRemove(T data)

onParentChange

protected void onParentChange(ParentChangeEvent event)
父节点变化事件

Parameters:
event - 父节点变化事件

onClear

protected void onClear()
Description copied from class: HashCollection
容器被清空

Overrides:
onClear in class HashCollection<T extends Data>

getRoots

public HashList<T> getRoots()
根层元素原始集合

Returns:
根层元素原始集合

toRoots

public java.util.List<T> toRoots()
根层元素数组

Returns:
根层元素数组

forEachByDepthFirst

public boolean forEachByDepthFirst(Action<Data> action)
深度优先遍历

Parameters:
action - 执行函数,返回false时结束遍历
Returns:
是否完成全部遍历

forEachByDepthFirstReverse

public boolean forEachByDepthFirstReverse(Action<Data> action)
深度优先反向遍历

Parameters:
action - 执行函数,返回false时结束遍历
Returns:
是否完成全部遍历

forEachByBreadthFirst

public boolean forEachByBreadthFirst(Action<Data> action)
广度优先遍历

Parameters:
action - 执行函数,返回false时结束遍历
Returns:
是否完成全部遍历

getRandomData

public T getRandomData()
获取随机元素

Returns:
随机元素