com.skaringa.javaxml.serializers
Class ArraySerializer

java.lang.Object
  extended by com.skaringa.javaxml.serializers.AbstractSerializer
      extended by com.skaringa.javaxml.serializers.ArraySerializer
All Implemented Interfaces:
ComponentSerializer

public final class ArraySerializer
extends AbstractSerializer

Implementation of ComponentSerializer for arrays.


Field Summary
 
Fields inherited from class com.skaringa.javaxml.serializers.AbstractSerializer
FIELD_TEMPLATE
 
Method Summary
 void addUsedClasses(java.lang.Class base, java.util.Set usedClasses)
          Get all classes used by a given base class.
 java.lang.Object endDeserialize(java.lang.Object obj, java.lang.String text)
          This method is called during deserialization when the end of the element is found.
 java.lang.String getXMLTypeName()
          Get the XML type name for objects handled by the serializer.
 void serialize(java.lang.Object obj, java.lang.Class type, java.lang.String name, java.util.Map propertyMap, java.util.Map objectIdMap, DocumentOutputHandlerInterface output)
          Serialize an object.
 void setMember(java.lang.Object parent, java.lang.String name, java.lang.Object value)
          This method is called when a member field of an object was completely deserialized and needs to be set.
 java.lang.Object startDeserialize(java.lang.String name, org.xml.sax.Attributes attrs, java.lang.Object parent, java.util.Stack objStack, java.lang.ClassLoader classLoader)
          This method is called during deserialization when the start of an element is found.
 void toJson(java.lang.Object obj, java.lang.Class type, java.util.Map propertyMap, java.io.PrintStream output)
          Serialize an object to JSON.
 void writeXMLTypeDefinition(java.lang.Class type, java.util.Map propertyMap, DocumentOutputHandlerInterface output)
          Write the definition the type in XML Schema format.
 
Methods inherited from class com.skaringa.javaxml.serializers.AbstractSerializer
getField, getFieldsToSerialize, getFieldType, printEncodedStr, startElement, subst, writeXMLCollectionDef, writeXMLExtensionDef
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

serialize

public void serialize(java.lang.Object obj,
                      java.lang.Class type,
                      java.lang.String name,
                      java.util.Map propertyMap,
                      java.util.Map objectIdMap,
                      DocumentOutputHandlerInterface output)
               throws SerializerException
Description copied from interface: ComponentSerializer
Serialize an object.

Parameters:
obj - The object to serialize.
type - The type of the object.
name - The name of the object.
propertyMap - A map (string-to-object) of properties for serialization.
objectIdMap - The objects and their ids that were already serialized.
output - The destination of the serialization.
Throws:
SerializerException - If an error occured during serialization.
See Also:
ComponentSerializer.serialize(Object, Class, String, Map, Map, DocumentOutputHandlerInterface)

getXMLTypeName

public java.lang.String getXMLTypeName()
Description copied from interface: ComponentSerializer
Get the XML type name for objects handled by the serializer.

Returns:
The XML type name.
See Also:
ComponentSerializer.getXMLTypeName()

startDeserialize

public java.lang.Object startDeserialize(java.lang.String name,
                                         org.xml.sax.Attributes attrs,
                                         java.lang.Object parent,
                                         java.util.Stack objStack,
                                         java.lang.ClassLoader classLoader)
                                  throws DeserializerException
Description copied from interface: ComponentSerializer
This method is called during deserialization when the start of an element is found.

Parameters:
name - The name of the element.
attrs - The attributes of the XML element.
parent - The parent object or null if unknown.
objStack - The complete stack of all parent ObjectDeserializerHolder objects.
classLoader - The class loader used to load the class of the new object.
Returns:
A newly created object.
Throws:
DeserializerException - If the creation of the object failed.
See Also:
ComponentSerializer.startDeserialize(String, Attributes, Object, Stack, ClassLoader)

setMember

public void setMember(java.lang.Object parent,
                      java.lang.String name,
                      java.lang.Object value)
               throws DeserializerException
Description copied from interface: ComponentSerializer
This method is called when a member field of an object was completely deserialized and needs to be set.

Parameters:
parent - The parent object.
name - The name of the member.
value - The value of the member.
Throws:
DeserializerException - If the setting of the member failed.
See Also:
ComponentSerializer.setMember(Object, String, Object)

endDeserialize

public java.lang.Object endDeserialize(java.lang.Object obj,
                                       java.lang.String text)
                                throws DeserializerException
Description copied from interface: ComponentSerializer
This method is called during deserialization when the end of the element is found.

Parameters:
obj - The element created by startDeserialize.
text - The text child node of the XML element.
Returns:
The completely deserialized object.
Throws:
DeserializerException - If the deserialization failed.
See Also:
ComponentSerializer.endDeserialize(Object, String)

writeXMLTypeDefinition

public void writeXMLTypeDefinition(java.lang.Class type,
                                   java.util.Map propertyMap,
                                   DocumentOutputHandlerInterface output)
                            throws SerializerException
Description copied from interface: ComponentSerializer
Write the definition the type in XML Schema format.

Parameters:
type - The type of the object.
propertyMap - A map (string-to-object) of properties.
output - Where to write the schema definition to.
Throws:
SerializerException - If an error occured during write.
See Also:
ComponentSerializer.writeXMLTypeDefinition(Class, Map, DocumentOutputHandlerInterface)

addUsedClasses

public void addUsedClasses(java.lang.Class base,
                           java.util.Set usedClasses)
                    throws SerializerException
Description copied from interface: ComponentSerializer
Get all classes used by a given base class. This includes the class itself, the classes of all fields, and all base classes.

Parameters:
base - The base class.
usedClasses - A Set with Class objects which represent all used classes. This set is filled up by this function.
Throws:
SerializerException - If an error occured.
See Also:
ComponentSerializer.addUsedClasses(Class, Set)

toJson

public void toJson(java.lang.Object obj,
                   java.lang.Class type,
                   java.util.Map propertyMap,
                   java.io.PrintStream output)
            throws SerializerException
Description copied from interface: ComponentSerializer
Serialize an object to JSON.

Parameters:
obj - The object to serialize.
type - The type of the object.
propertyMap - A map (string-to-object) of properties for serialization.
output - The destination of the serialization.
Throws:
SerializerException - If an error occurred during serialization.
See Also:
CollectionSerializer.toJson(Object, Class, Map, PrintStream)