de.javakaffee.web.msm.serializer.javolution
Class ReflectionFormat<T>

java.lang.Object
  extended by javolution.xml.XMLFormat<T>
      extended by de.javakaffee.web.msm.serializer.javolution.ReflectionFormat<T>
Type Parameters:
T - the type that is read/written by this XMLFormat.

public class ReflectionFormat<T>
extends javolution.xml.XMLFormat<T>

An XMLFormat that provides the binding for a certain class to to/from xml based on reflection.

When serializing an object to xml, the values of the declared fields are read (including inherited fields) from the object. Fields marked as transient or static are omitted.

During deserialization, first all attributes contained in the xml are read and written to the object. Afterwards the fields that are bound to elements are checked for contained xml elements and in this case the values are written to the object.

Author:
Martin Grotzke

Nested Class Summary
 
Nested classes/interfaces inherited from class javolution.xml.XMLFormat
javolution.xml.XMLFormat.InputElement, javolution.xml.XMLFormat.OutputElement
 
Field Summary
 
Fields inherited from class javolution.xml.XMLFormat
APPENDABLE_XML, BOOLEAN_XML, BYTE_XML, CHARACTER_XML, CLASS_XML, COLLECTION_XML, CONFIGURABLE_XML, DOUBLE_XML, FAST_COLLECTION_XML, FAST_COMPARATOR_XML, FAST_MAP_XML, FLOAT_XML, INDEX_XML, INTEGER_XML, LONG_XML, MAP_XML, OBJECT_ARRAY_XML, OBJECT_XML, PERSISTENT_CONTEXT_XML, QNAME_XML, SHORT_XML, STRING_XML, TEXT_XML
 
Constructor Summary
ReflectionFormat(Class<T> clazz, ClassLoader classLoader)
          Creates a new instance for the provided class.
 
Method Summary
protected static boolean isAttribute(Class<?> clazz)
           
protected static boolean isAttribute(Field field)
           
 T newInstance(Class<T> clazz, javolution.xml.XMLFormat.InputElement xml)
          
 void read(javolution.xml.XMLFormat.InputElement input, T obj)
          
 void write(T obj, javolution.xml.XMLFormat.OutputElement output)
          
 
Methods inherited from class javolution.xml.XMLFormat
getBoundClass, getDefault, isReferenceable, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ReflectionFormat

public ReflectionFormat(Class<T> clazz,
                        ClassLoader classLoader)
Creates a new instance for the provided class.

Parameters:
clazz - the Class that is supported by this XMLFormat.
classLoader - the ClassLoader that is used to load user types.
Method Detail

isAttribute

protected static boolean isAttribute(Field field)

isAttribute

protected static boolean isAttribute(Class<?> clazz)

newInstance

public T newInstance(Class<T> clazz,
                     javolution.xml.XMLFormat.InputElement xml)
              throws javolution.xml.stream.XMLStreamException

Overrides:
newInstance in class javolution.xml.XMLFormat<T>
Throws:
javolution.xml.stream.XMLStreamException

read

public void read(javolution.xml.XMLFormat.InputElement input,
                 T obj)
          throws javolution.xml.stream.XMLStreamException

Specified by:
read in class javolution.xml.XMLFormat<T>
Throws:
javolution.xml.stream.XMLStreamException

write

public void write(T obj,
                  javolution.xml.XMLFormat.OutputElement output)
           throws javolution.xml.stream.XMLStreamException

Specified by:
write in class javolution.xml.XMLFormat<T>
Throws:
javolution.xml.stream.XMLStreamException


Copyright © 2009-2012. All Rights Reserved.