livespace.services
Class XmlEntityCodec

java.lang.Object
  extended by dsto.dfc.databeans.io.XmlDataObjectCodec
      extended by livespace.services.XmlEntityCodec
All Implemented Interfaces:
XmlDecoder, XmlEncoder

public class XmlEntityCodec
extends XmlDataObjectCodec

XML codec for Livespace Entity types.

Author:
Matthew Phillips

Field Summary
 boolean clearUndefinedProperties
          Setting this to true (default = false) causes the decode logic to blow away any entity properties that were not defined in the XML.
static String ELEMENT_TAG
           
 
Constructor Summary
XmlEntityCodec()
           
XmlEntityCodec(EntityContainer container)
          Create a codec that uses EntityContainer.createEntity(String, String) to create new entities.
 
Method Summary
 boolean canEncode(XmlEncodeContext context, Object value)
          Test if this codec can encode a given object.
 Object decode(XmlDecodeContext context, org.jdom.Element element)
          Decode an XML representation into a value.
 org.jdom.Element encode(XmlEncodeContext context, Object value)
          Generate an XML representation of an object.
static void register()
          Register this codec for XML IO.
protected  void setObjectValue(IDataObject object, Object property, Object value)
          Called by data object decoders to set property values.
 
Methods inherited from class dsto.dfc.databeans.io.XmlDataObjectCodec
decodeDataBean, decodeDataObject, decodeDataObjectProperty, decodeJavaBean, encodeDataBean, encodeDataBeanProperties, encodeDataObject, encodeDataObjectProperty, encodeJavaBean, shouldPreserveIdentity
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ELEMENT_TAG

public static final String ELEMENT_TAG
See Also:
Constant Field Values

clearUndefinedProperties

public boolean clearUndefinedProperties
Setting this to true (default = false) causes the decode logic to blow away any entity properties that were not defined in the XML. This is useful in the case that createEntity () returned a previously allocated entity with properties that are no longer defined. It is generally used by clients receiving an object from a publisher.

Constructor Detail

XmlEntityCodec

public XmlEntityCodec()

XmlEntityCodec

public XmlEntityCodec(EntityContainer container)
Create a codec that uses EntityContainer.createEntity(String, String) to create new entities.

Method Detail

register

public static void register()
Register this codec for XML IO.


canEncode

public boolean canEncode(XmlEncodeContext context,
                         Object value)
Description copied from interface: XmlEncoder
Test if this codec can encode a given object.

Specified by:
canEncode in interface XmlEncoder
Overrides:
canEncode in class XmlDataObjectCodec
Parameters:
context - The current encode context.
value - The value. May be null.
Returns:
True if this encoder should be used for value.

encode

public org.jdom.Element encode(XmlEncodeContext context,
                               Object value)
Description copied from interface: XmlEncoder
Generate an XML representation of an object.

Specified by:
encode in interface XmlEncoder
Overrides:
encode in class XmlDataObjectCodec
Parameters:
context - The encoding context.
value - The value to be encoded.
Returns:
The JDOM element created for the value.

decode

public Object decode(XmlDecodeContext context,
                     org.jdom.Element element)
              throws IllegalArgumentException,
                     ClassNotFoundException
Description copied from interface: XmlDecoder
Decode an XML representation into a value.

Specified by:
decode in interface XmlDecoder
Overrides:
decode in class XmlDataObjectCodec
Parameters:
context - The decode context.
element - The element to decode.
Returns:
The new object.
Throws:
IllegalArgumentException - if an error is found in the structure of the document.
ClassNotFoundException - if a referenced class cannot be found.

setObjectValue

protected void setObjectValue(IDataObject object,
                              Object property,
                              Object value)
Called by data object decoders to set property values. Overridden to change setValue () into merge ().

Overrides:
setObjectValue in class XmlDataObjectCodec


Copyright © 2008 Commonwealth of Australia