|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object texsoft.java.object.XsObjectWithReflection
Add easy reflection support to derived classes.
Classes that extends XsObjectWithReflection can access their properties via reflection easily and without need to write complex code that use java.lang.reflect .
doGet(String prop)
returns the value of property prop.
doSet(String prop, Object v)
sets the value of property prop to v.
doNew()
creates and returns a new instance for the class.
There is also a group of wrapper methods doSet(String prop, ...) that accept as value primitive types such as int, long, boolean, etc ...
The inspect()
method return the XsClassInspector
object for the class.
It is usefull to obtain more detailed information on properties.
Using the applyInterfaceFilter(Class)
method the object reflection methods
doSet(), doGet() and inspect() are filtered to the public setter/getter
of the interface. The interface passed must be implemented by
the class. The doNew()
method creates an instance of the class, ignoring
the filter applied.
The constructor that has a Class parameters allow to apply an interface
for filtering as using the applyInterfaceFilter(Class)
method.
XsClassInspector
Constructor Summary | |
XsObjectWithReflection()
Create a new instance of the class. |
|
XsObjectWithReflection(java.lang.Class iface)
Create a new instance of the class, filtering inspected properties on the passed interface. |
Method Summary | |
void |
applyInterfaceFilter(java.lang.Class iface)
Apply an interface that acts as a filter for inpected properties. |
void |
applyInterfaceFilter(java.lang.String ifaceName)
Apply an interface that acts as a filter for inpected properties. |
java.lang.Object |
doGet(java.lang.String p)
Returns the value of the property whose name is p. |
XsObjectWithReflection |
doNew()
This method create and return a new instance for the class. |
void |
doSet(java.lang.String p,
boolean v)
Sets the property named p to the value v. |
void |
doSet(java.lang.String p,
byte v)
Sets the property named p to the value v. |
void |
doSet(java.lang.String p,
char v)
Sets the property named p to the value v. |
void |
doSet(java.lang.String p,
double v)
Sets the property named p to the value v. |
void |
doSet(java.lang.String p,
float v)
Sets the property named p to the value v. |
void |
doSet(java.lang.String p,
int v)
Sets the property named p to the value v. |
void |
doSet(java.lang.String p,
long v)
Sets the property named p to the value v. |
void |
doSet(java.lang.String p,
java.lang.Object v)
Assigns v to the property whose name is p. |
void |
doSet(java.lang.String p,
short v)
Sets the property named p to the value v. |
XsClassInspector |
inspect()
Returns the class inspector of this object. |
void |
removeInterfaceFilter()
Removes the interface filter for properties previously applied. |
java.lang.String |
toString()
Override default toString method to return classname and properties mapped by the inspector for this class. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public XsObjectWithReflection() throws XsObjectException
Transparently acquires from XsInspectionFactory
the inspector for the class beeing instantiated.
XsObjectException
- thrown if can't acquire the inspector for the classpublic XsObjectWithReflection(java.lang.Class iface) throws XsObjectException
Query from XsInspectionFactory
the inspector for the interface passed.
The interface must be implemented by the class.
This constructor is used to reduce the visibility of properties
accessed by the inspection system based on an interface that the class implements.
Currently the class properties can be filtered only on one interface.
iface
- specifies the interface on which the class inspected properties are to
be filtered on
XsObjectException
- thrown if can't acquire the inspector for the class or the interfaceMethod Detail |
public void applyInterfaceFilter(java.lang.Class iface) throws XsObjectException
The interface passed must be implemented by this class. This method can be called many time, with different interfaces as argument, if it's needed to filter the inspected properties on different interfaces of the calss in different moments.
iface
- specifies the interface on which the class inspected properties are to
be filtered on
XsObjectException
- thrown if can't acquire the inspector for the class or the interfacepublic void applyInterfaceFilter(java.lang.String ifaceName) throws XsObjectException
The interface passed must be implemented by this class. This method can be called many time, with different interfaces as argument, if it's needed to filter the inspected properties on different interfaces of the calss in different moments.
ifaceName
- specifies the name of the interface on which the class inspected properties are to
be filtered on
XsObjectException
- thrown if can't acquire the inspector for the class or the interface or if no
interface match the passed interface namepublic void removeInterfaceFilter()
public final java.lang.Object doGet(java.lang.String p) throws XsObjectException
XsClassInspector.get(Object, String)
.
p
- name of the property whose value has to be returned.
XsObjectException
- thrown if a reflection or class type error occurs while getting the property valuepublic final void doSet(java.lang.String p, java.lang.Object v) throws XsObjectException
Invokes the setter with class inspector for property p, setting value v.
p
- name of the property to be set.v
- value to be assigned to the property.
XsObjectException
- thrown if a reflection or class type error occurs while setting the property valueXsClassInspector.set(Object, String, Object)
public final XsObjectWithReflection doNew() throws XsObjectException
XsObjectException
- Thrown if a reflection error occurs while creating the new instance.public final XsClassInspector inspect()
Usefull for requesting properties list, and other reflection services.
XsClassInspector
of this object.public final void doSet(java.lang.String p, byte v) throws XsObjectException
p
- name of the propertyv
- value to be assigned to the property
XsObjectException
- thrown if a reflection error occurs while setting the property value.doSet(String, Object)
public final void doSet(java.lang.String p, short v) throws XsObjectException
p
- name of the propertyv
- value to be assigned to the property
XsObjectException
- thrown if a reflection error occurs while setting the property value.doSet(String, Object)
public final void doSet(java.lang.String p, int v) throws XsObjectException
p
- name of the propertyv
- value to be assigned to the property
XsObjectException
- thrown if a reflection error occurs while setting the property value.doSet(String, Object)
public final void doSet(java.lang.String p, long v) throws XsObjectException
p
- name of the propertyv
- value to be assigned to the property
XsObjectException
- thrown if a reflection error occurs while setting the property value.doSet(String, Object)
public final void doSet(java.lang.String p, float v) throws XsObjectException
p
- name of the propertyv
- value to be assigned to the property
XsObjectException
- thrown if a reflection error occurs while setting the property value.doSet(String, Object)
public final void doSet(java.lang.String p, double v) throws XsObjectException
p
- name of the propertyv
- value to be assigned to the property
XsObjectException
- thrown if a reflection error occurs while setting the property value.doSet(String, Object)
public final void doSet(java.lang.String p, char v) throws XsObjectException
p
- name of the propertyv
- value to be assigned to the property
XsObjectException
- thrown if a reflection error occurs while setting the property value.doSet(String, Object)
public final void doSet(java.lang.String p, boolean v) throws XsObjectException
p
- name of the propertyv
- value to be assigned to the property
XsObjectException
- thrown if a reflection error occurs while setting the property value.doSet(String, Object)
public java.lang.String toString()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |