public class DataBoxQuickFinder
extends java.lang.Object
To use this class, you have to input the bound property name string in the constructor, and implement method 'getKey' to return the property related value. Then you can invoke 'find' with an object as the condition to get all match element data.
String propertyName = TWaverConst.CLIENT_PROPERTY_PREFIX + "age"; DataBoxQuickFinder finder = new DataBoxQuickFinder (box, propertyName) { protected Object getKey (Element element) { return element.getClientProperty ("age"); } }; Node node1=new Node(); node1.putClientProperty("age",20); box.addElement(node1); Node node2=new Node(); node2.putClientProperty("age",30); box.addElement(node2); List result=finder.find(new Integer (20));
Modifier and Type | Field and Description |
---|---|
protected TDataBox |
box |
protected java.lang.Class |
elementClass |
protected Generator |
keyGenerator |
protected java.lang.String |
propertyName |
Constructor and Description |
---|
DataBoxQuickFinder(TDataBox box,
java.lang.String propertyName)
create a DataBoxQuickFinder instance for the specified data box
and bind the specified property name.
|
DataBoxQuickFinder(TDataBox box,
java.lang.String propertyName,
java.lang.Class elementClass)
create a DataBoxQuickFinder instance for the specified data box
and bind the specified property name.
|
DataBoxQuickFinder(TDataBox box,
java.lang.String propertyName,
java.lang.Class elementClass,
Generator keyGenerator)
create a DataBoxQuickFinder instance for the specified data box
and bind the specified property name.
|
Modifier and Type | Method and Description |
---|---|
protected void |
addElement(Element element)
Add given element into internal cache.
|
protected void |
clear()
Clear all internal caches.
|
void |
dispose()
Dispose all related resources.
|
protected void |
elementPropertyChange(java.beans.PropertyChangeEvent e)
Process the action for element property change.
|
java.util.List |
find(java.lang.Object value)
Find all elements whose bound property value equals to the
given value.
|
Element |
findFirst(java.lang.Object value)
Find the first element whose bound property value equals to the
given value.
|
protected java.lang.Object |
getKey(Element element)
Gets bind property's value of the given element.
|
boolean |
interested(Element element)
Determines whether or not this finder has interest on
this specified element.
|
protected void |
removeElement(Element element)
Remove the element from internal cache.
|
protected TDataBox box
protected java.lang.String propertyName
protected java.lang.Class elementClass
protected Generator keyGenerator
public DataBoxQuickFinder(TDataBox box, java.lang.String propertyName)
box
- the box that will be listened on.propertyName
- the element property name that will be listened on.public DataBoxQuickFinder(TDataBox box, java.lang.String propertyName, java.lang.Class elementClass)
box
- the box that will be listened on.propertyName
- the element property name that will be listened on.elementClass
- the element class that is interested.public DataBoxQuickFinder(TDataBox box, java.lang.String propertyName, java.lang.Class elementClass, Generator keyGenerator)
box
- the box that will be listened on.propertyName
- the element property name that will be listened on.elementClass
- the element class that is interested.keyGenerator
- the key generator for getting key from elementpublic java.util.List find(java.lang.Object value)
value
- Object the conditional value.public Element findFirst(java.lang.Object value)
value
- Object the conditional value.protected void addElement(Element element)
element
- Element the element need to add.protected void removeElement(Element element)
element
- Element the element need to removeprotected void clear()
protected void elementPropertyChange(java.beans.PropertyChangeEvent e)
e
- PropertyChangeEvent the property change event.public void dispose()
public boolean interested(Element element)
element
- protected java.lang.Object getKey(Element element)
element
- the element objectCopyright © 2002 - 2010 Serva Software. All Rights Reserved.