com.ail.core.xmlbinding
Class CastorXMLStringFieldHandler
java.lang.Object
org.exolab.castor.mapping.loader.FieldHandlerFriend
org.exolab.castor.mapping.ExtendedFieldHandler
org.exolab.castor.mapping.AbstractFieldHandler
com.ail.core.xmlbinding.CastorXMLStringFieldHandler
- All Implemented Interfaces:
- org.exolab.castor.mapping.FieldHandler
public class CastorXMLStringFieldHandler
- extends org.exolab.castor.mapping.AbstractFieldHandler
Castor data field handler which wraps a fields of type XMLString.
Typically, if an object contains a property of type XMLString, you will want the
contents of that string to be embdedded into the XML generaged by ToXMLCommand
as though it were an inherent node in the XML, and for FromXMLCommand to
read the embedded nodes into the XMLString insrance.
This isn't the most natural behaviour for Castor, but it is achievable using this FieldHandler, and castor's AnyNode type.
Assuming that you have an object (com.core.MyObject) which declates an XMLString property myBitOfXml with the appropriate getters
and setters, and the following castor mapping:
...
<class name="com.core.MyObject">
<field name="myBitOfXml" type="org.exolab.castor.types.AnyNode" handler="com.ail.core.xmlbinding.CastorXMLStringFieldHandler">
<bind-xml type="any" node="element"/>
</field>
</class>
...
The following section of code:
MyObject mobj=new MyObj();
mobj.setMyBitOfXml(new XMLString("<name>Mr. Pig</name>"));
System.out.println(core.toXml(mobj));
Would generate the following output:
<myObj xsi:type='java:com.ail.MyObj' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
<myBitOfXml><name>Mr. Pig</name></myBitOfXml>
</myObj>
- Version:
- $Revision$
- Author:
- $Author$
|
Method Summary |
java.lang.Object |
getValue(java.lang.Object object)
uses reflection to retrieve the value then output it in it's raw format (i.e. |
java.lang.Object |
newInstance(java.lang.Object arg0)
|
java.lang.Object |
newInstance(java.lang.Object arg0,
java.lang.Object[] arg1)
|
void |
resetValue(java.lang.Object object)
|
void |
setValue(java.lang.Object object,
java.lang.Object value)
|
| Methods inherited from class org.exolab.castor.mapping.AbstractFieldHandler |
hasValue, setFieldDescriptor |
| Methods inherited from class org.exolab.castor.mapping.ExtendedFieldHandler |
checkValidity |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
CastorXMLStringFieldHandler
public CastorXMLStringFieldHandler()
getValue
public java.lang.Object getValue(java.lang.Object object)
throws java.lang.IllegalStateException
- uses reflection to retrieve the value then output it in it's raw format (i.e. as XML).
- Specified by:
getValue in interface org.exolab.castor.mapping.FieldHandler- Specified by:
getValue in class org.exolab.castor.mapping.AbstractFieldHandler
- Throws:
java.lang.IllegalStateException
newInstance
public java.lang.Object newInstance(java.lang.Object arg0)
throws java.lang.IllegalStateException
- Specified by:
newInstance in interface org.exolab.castor.mapping.FieldHandler- Specified by:
newInstance in class org.exolab.castor.mapping.AbstractFieldHandler
- Throws:
java.lang.IllegalStateException
newInstance
public java.lang.Object newInstance(java.lang.Object arg0,
java.lang.Object[] arg1)
throws java.lang.IllegalStateException
- Specified by:
newInstance in class org.exolab.castor.mapping.AbstractFieldHandler
- Throws:
java.lang.IllegalStateException
resetValue
public void resetValue(java.lang.Object object)
throws java.lang.IllegalStateException,
java.lang.IllegalArgumentException
- Specified by:
resetValue in interface org.exolab.castor.mapping.FieldHandler- Specified by:
resetValue in class org.exolab.castor.mapping.AbstractFieldHandler
- Throws:
java.lang.IllegalStateException
java.lang.IllegalArgumentException
setValue
public void setValue(java.lang.Object object,
java.lang.Object value)
throws java.lang.IllegalStateException,
java.lang.IllegalArgumentException
- Specified by:
setValue in interface org.exolab.castor.mapping.FieldHandler- Specified by:
setValue in class org.exolab.castor.mapping.AbstractFieldHandler
- Throws:
java.lang.IllegalStateException
java.lang.IllegalArgumentException