|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objecteu.beesoft.gaia.util.Miner
public class Miner
Miner is a class dedicated to support the data binding. From external perspective it has two simple methods:
getValue(propertyName, object)
- gets
value from the property of the objectsetValue(value, propertyName,
object)
- sets value to the property of the objectProperty name can be a simple property name, or you can use the dot-convention to chain objects referenced from properties. For example, if object A has property a that references object B, and object B has property b that references object C, and object C has property c you want to get, you can use as property name text a.b.c to get / set this property.
Miner prioritizes a method access (via getters / setters), but if the method for the property cannot be found, it uses the field access.
You can use this class "as is". But you have to subclass it if
createObject(String, Object)
Constructor Summary | |
---|---|
Miner()
Creates a new instance of the Miner. |
Method Summary | |
---|---|
protected java.lang.Object |
createObject(java.lang.String simplePropertyName,
java.lang.Object owner)
Creates object for given property and object owner . |
java.lang.Object |
getValue(java.lang.String dottedPropertyName,
java.lang.Object object)
Returns value from the property with the given dottedPropertyName of the object object . |
protected java.lang.Object |
getValueFromProperty(java.lang.String simplePropertyName,
java.lang.Object object)
Returns value from the property with the given simplePropertyName of the object object . |
void |
setValue(java.lang.Object value,
java.lang.String dottedPropertyName,
java.lang.Object object)
Sets value to the object's property. |
protected void |
setValueToProperty(java.lang.Object value,
java.lang.String simplePropertyName,
java.lang.Object object)
Sets value to the object's property. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Miner()
Method Detail |
---|
public java.lang.Object getValue(java.lang.String dottedPropertyName, java.lang.Object object)
dottedPropertyName
of the object object
. If
dottedPropertyName
contains '.' character, the method parses
it to simple property names and obtains last value from this chain. If
given object
is null, returns null.
dottedPropertyName
- - name of requested property, or dot-separated names of
chained propertiesobject
- - object (container of properties)
java.lang.RuntimeException
- if dottedPropertyName is null, or if cannot find getter(s)
for given property(ies) or field(s) with that name(s)protected java.lang.Object getValueFromProperty(java.lang.String simplePropertyName, java.lang.Object object)
simplePropertyName
of the object object
. First
it tries to get the value via getter. If not found, field access is used.
Method is invoked from getValue(String, Object)
method.
simplePropertyName
- - name of the object propertyobject
- - object (owner of the property)
java.lang.RuntimeException
- if cannot find getter for given property or field with that
namepublic void setValue(java.lang.Object value, java.lang.String dottedPropertyName, java.lang.Object object)
dottedPropertyName
contains '.' character the method parses it to simple property names and
sets value to the last member of this chain. If given object
or any object in the chain is null, method
createObject(String, Object)
is invoked to complete chain.
value
- - value to setdottedPropertyName
- - name of the requested property, or dot-separated names of
chained propertiesobject
- - object (container of properties)
java.lang.RuntimeException
- if dottedPropertyName is null, or if cannot find setter(s)
for given property(ies) or field(s) with that name(s)protected void setValueToProperty(java.lang.Object value, java.lang.String simplePropertyName, java.lang.Object object)
setValue(Object, String, Object)
method.
value
- - value to setsimplePropertyName
- - name of the requested propertyobject
- - object (container of properties)
java.lang.RuntimeException
- if cannot find setter for given property or field with that
nameprotected java.lang.Object createObject(java.lang.String simplePropertyName, java.lang.Object owner)
owner
. This
method is invoked from setValue(Object, String, Object)
to
refill chain of objects.
In this implementation method throws RuntimeException, so if you have null objects in the middle of the chain of your objects, you have to override it. Don't set / add created object to the owner, just create it and return.
simplePropertyName
- - name of the property where created object belongsowner
-
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |