|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object texsoft.java.object.XsObjectWithReflection texsoft.java.object.XsObjectSerializable texsoft.java.object.XsKeyObject
Defines an object able to act as a key for instances of XsObjectWithKey
and derived classes, for seeking and sorting,
and to serialize its properties using XsObjectSerializable
services.
A key object should derive from this class and should have properties with public setter and getter for each property that is a key (for seeking or sorting) of the class for which the object has to act as a key.
By default all public properties of the object are used as key properties and no
standard sequence is imposed on the properties for sorting. This can be
overriden defining a custom sequence of public properties with
defineOrder(String[])
.
The ordering option constants from XsObjectComparator
can be appened
to property names into the String array that defines key properties to select
ordering options for the properties.
Say k is a XsKeyObject and obj is an object belonging to a class
for which k is a key, then the matching properties of k can be valorized
from obj, and vice versa the matching properties of obj can be valorized from
k. This is achieved using readFrom(XsObjectWithKey)
and
writeTo(XsObjectWithKey)
. All the public properties of the key object
are involved into this process.
Implements the Comparable
interface to allow ordering for key objects.
The sorting order is defined by the properties order sequence,
that is managed by defineOrder(String[])
).
If the key has to be used for sorting of object and it has more
than one property, the constructor in derived classes should
set the order array explicitly.
Interface filtering is suppressed for this class and its descendents: application of interface for properties filtering is ignored.
Constructor Summary | |
XsKeyObject()
Creates a new XsKeyObject instance. |
|
XsKeyObject(java.lang.Class iface)
Creates new XsKeyObject. |
|
XsKeyObject(java.lang.String serialized)
Creates a new XsKeyObject object and initializes it with the serialized string passed as argument. |
Method Summary | |
void |
applyInterfaceFilter(java.lang.Class iface)
Overloaded to avoid applying of filtering on key object. |
void |
applyInterfaceFilter(java.lang.String ifaceName)
Overloaded to avoid applying of filtering on key object. |
int |
compareTo(java.lang.Object obj)
Compares this object with the one passed as argument. |
java.lang.String[] |
currentOrder()
Gets the String array that defines the properties that compose the key and defines their order for sorting. |
void |
defineOrder(java.lang.String[] order)
Sets the String array that defines the properties that compose the key and defines their order for sorting. |
XsKeyObject |
readFrom(XsObjectWithKey obj)
Given an object exctract it's key fields and store them into this key object. |
XsObjectWithKey |
writeTo(XsObjectWithKey obj)
Given an object fills it's key fields from this key. |
Methods inherited from class texsoft.java.object.XsObjectSerializable |
deserialize, serialize |
Methods inherited from class texsoft.java.object.XsObjectWithReflection |
doGet, doNew, doSet, doSet, doSet, doSet, doSet, doSet, doSet, doSet, doSet, inspect, removeInterfaceFilter, toString |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public XsKeyObject() throws XsObjectException
XsObjectException
- thrown if a problem occurs while obtaining the inspector for the class.XsObjectWithReflection.XsObjectWithReflection()
public XsKeyObject(java.lang.Class iface) throws XsObjectException
iface
- ignored.
XsObjectException
- thrown if a problem occurs while obtaining the inspector for the class.XsObjectWithReflection.XsObjectWithReflection()
public XsKeyObject(java.lang.String serialized) throws XsObjectException
The passed String is supposed to be created by a XsObjectSerializable.serialize()
method called on a object of the same type of the this.
serialized
- serialized rapresentation of an object of this class.
XsObjectException
- thrown if an error occurs during deserialization of the string.Method Detail |
public final XsKeyObject readFrom(XsObjectWithKey obj) throws XsObjectException
obj
- an object of a class for which this object is a key.
XsObjectException
- thrown if a reflection error occurs.public final XsObjectWithKey writeTo(XsObjectWithKey obj) throws XsObjectException
obj
- object belonging to a class for which this is a key object.
XsObjectException
- thrown if a reflection error occurs.public java.lang.String[] currentOrder()
public void defineOrder(java.lang.String[] order)
order
- the property names array.public int compareTo(java.lang.Object obj)
The argument object must be belong to the same class of this object.
compareTo
in interface java.lang.Comparable
obj
- the object to be compared with this.
public final void applyInterfaceFilter(java.lang.Class iface) throws XsObjectException
applyInterfaceFilter
in class XsObjectWithReflection
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 final void applyInterfaceFilter(java.lang.String ifaceName) throws XsObjectException
applyInterfaceFilter
in class XsObjectWithReflection
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 name
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |