twaver.model
Class QuickFinder<T extends Data>

java.lang.Object
  extended by twaver.model.QuickFinder<T>
Type Parameters:
T - 数据类型

public class QuickFinder<T extends Data>
extends java.lang.Object

快速查找器,通过元素的某个属性查找相关元素,比如通过元素名称查找,下面的例子是查找所有名称为"pc"的元素:

 QuickFinder finder = new QuickFinder(box, "name");
 List elements = finder.find("pc");
 


Constructor Summary
QuickFinder(DataBox<T> dataBox, java.lang.String propertyName)
          快速查找器,通过元素的某个属性查找相关元素,比如通过元素名称查找,下面的例子是查找所有名称为"pc"的元素:
QuickFinder(DataBox<T> dataBox, java.lang.String propertyName, java.lang.String propertyType)
          构造函数,快速查找器,通过元素的某个属性查找相关元素,比如通过元素名称查找,下面的例子是查找所有名称为"pc"的元素:
QuickFinder(DataBox<T> dataBox, java.lang.String propertyName, java.lang.String propertyType, Generator<T,java.lang.Object> valueGenerator, IFilter<T> filter)
          构造函数,快速查找器,通过元素的某个属性查找相关元素,比如通过元素名称查找,下面的例子是查找所有名称为"pc"的元素:
 
Method Summary
 void dispose()
          Call this method to dispose all resources this quick finder used.
 java.util.List<T> find(java.lang.Object value)
          Call this to execute the query by specified condition.
 T findFirst(java.lang.Object value)
          Find the first matched data.
 DataBox<T> getDataBox()
          Get the data box this quick finder connected.
 IFilter<T> getFilter()
          Get search filter function.
 java.lang.String getPropertyName()
          The property name query condition of this finder.
 java.lang.String getPropertyType()
          Get the property type query condition.
protected  java.lang.Object getValue(T data)
          读取元素属性
 Generator<T,java.lang.Object> getValueGenerator()
          Get the value generator function.
protected  boolean isInterested(T data)
          Whether specified data instanceof a data that current finder has interesting.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QuickFinder

public QuickFinder(DataBox<T> dataBox,
                   java.lang.String propertyName)
快速查找器,通过元素的某个属性查找相关元素,比如通过元素名称查找,下面的例子是查找所有名称为"pc"的元素:
 QuickFinder finder = new QuickFinder(box, "name");
 List elements = finder.find("pc");
 

Parameters:
dataBox - 数据容器
propertyName - 查找属性

QuickFinder

public QuickFinder(DataBox<T> dataBox,
                   java.lang.String propertyName,
                   java.lang.String propertyType)
构造函数,快速查找器,通过元素的某个属性查找相关元素,比如通过元素名称查找,下面的例子是查找所有名称为"pc"的元素:
 QuickFinder finder = new QuickFinder(box, "name");
 List elements = finder.find("pc");
 

Parameters:
dataBox - 数据容器
propertyName - 查找属性
propertyType - 查找属性类型,默认按元素的javabean属性(Consts.PROPERTY_TYPE_ACCESSOR)

QuickFinder

public QuickFinder(DataBox<T> dataBox,
                   java.lang.String propertyName,
                   java.lang.String propertyType,
                   Generator<T,java.lang.Object> valueGenerator,
                   IFilter<T> filter)
构造函数,快速查找器,通过元素的某个属性查找相关元素,比如通过元素名称查找,下面的例子是查找所有名称为"pc"的元素:
 QuickFinder finder = new QuickFinder(box, "name");
 List elements = finder.find("pc");
 

Parameters:
dataBox - 数据容器
propertyName - 属性名称
propertyType - 查找属性类型,默认按元素的javabean属性(Consts.PROPERTY_TYPE_ACCESSOR) 可以使用下面这些类型: Consts.PROPERTY_TYPE_ACCESSOR, Consts.PROPERTY_TYPE_CLIENT, Consts.PROPERTY_TYPE_STYLE
valueGenerator - 属性生成器,默认按属性名称和属性类型读取元素的相应属性, 比如属性名称:"name",属性类型:Consts.PROPERTY_TYPE_ACCESSOR, 默认会通过Element.getName()获取属性,设置定制的valueGenerator,则可以
filter - 元素过滤器,用于控制哪些元素可以查找,哪些不需要查找
Method Detail

getValueGenerator

public Generator<T,java.lang.Object> getValueGenerator()
Get the value generator function.

Returns:
the value generate of this finder.

getFilter

public IFilter<T> getFilter()
Get search filter function.

Returns:
this filter used to filter out the data you don't want include in the query result.

find

public java.util.List<T> find(java.lang.Object value)
Call this to execute the query by specified condition.

Parameters:
value - the value condition of the query.
Returns:
all matched data of this query.

findFirst

public T findFirst(java.lang.Object value)
Find the first matched data.

Parameters:
value - the value condition of this query.
Returns:
first matched data of this query.

dispose

public void dispose()
Call this method to dispose all resources this quick finder used. When you distroy this quick finder, call this to release all resources.


getDataBox

public DataBox<T> getDataBox()
Get the data box this quick finder connected.

Returns:
the data box that this quick finder connected.

getPropertyType

public java.lang.String getPropertyType()
Get the property type query condition. The property type of this query condition can be: Consts.PROPERTY_TYPE_ACCESSOR, Consts.PROPERTY_TYPE_CLIENT, Consts.PROPERTY_TYPE_STYLE.

Returns:
the property type query condition.

getPropertyName

public java.lang.String getPropertyName()
The property name query condition of this finder. Finder will search according to this property value.

Returns:
the property name query condition of this finder.

isInterested

protected boolean isInterested(T data)
Whether specified data instanceof a data that current finder has interesting. Only the data this finder has interesting will be searched by this finder.

Parameters:
data - a data need to check
Returns:
true if has interesting in this data, false otherwise.

getValue

protected java.lang.Object getValue(T data)
读取元素属性

Parameters:
data -
Returns: