org.ujac.util.xml
Class DynamicObjectSerializer

java.lang.Object
  extended by org.ujac.util.xml.BaseObjectSerializer
      extended by org.ujac.util.xml.DynamicObjectSerializer

public class DynamicObjectSerializer
extends BaseObjectSerializer

Name: DynamicObjectSerializer
Description: A dynamic configurable object serializer.

Author:
lauerc

Nested Class Summary
 
Nested classes/interfaces inherited from class org.ujac.util.xml.BaseObjectSerializer
BaseObjectSerializer.ObjectHandler, BaseObjectSerializer.StackElement
 
Field Summary
 
Fields inherited from class org.ujac.util.xml.BaseObjectSerializer
parentSerializer
 
Constructor Summary
DynamicObjectSerializer()
          Constructs a DynamicObjectSerializer instance with no specific attributes.
DynamicObjectSerializer(String encoding)
          Constructs a DynamicObjectSerializer instance with specific attributes.
DynamicObjectSerializer(String encoding, TypeConverter typeConverter)
          Constructs a DynamicObjectSerializer instance with specific attributes.
 
Method Summary
 String attributeName2PropertyName(String attributeName)
          Converts the given attribute name (form: parta-partb) into a property name (form: partaPartb).
 void endElement(BaseObjectSerializer.StackElement localElement, String content, BaseObjectSerializer.StackElement parentElement, Object root)
          Ends the given local element.
 ComplexTypeDefinition getComplexType(Class clazz)
          Gets the element class for the given tag name.
 ComplexTypeDefinition getComplexType(String name)
          Gets the element class for the given tag name.
 ElementDefinition getRootElement()
          Gets the root element definition.
 String propertyName2AttributeName(String propertyName)
          Converts the given property name (form: partaPartb) into a attribute name (form: parta-partb).
protected  void registerComplexTypes()
          Registers the base complex types.
 void setComplexType(ComplexTypeDefinition clazz)
          Sets the element class for the given tag name.
 void setRootElement(ElementDefinition rootElement)
          Sets the root element definition.
 void startElement(BaseObjectSerializer.StackElement localElement, BaseObjectSerializer.StackElement parentElement, Object root)
          Starts the given local element.
 void write(PrintWriter writer, Object obj)
          Writes an object to the given print writer.
 void writeObject(PrintWriter writer, ElementDefinition elementDefinition, Object obj, int level)
          Writes an object to the given print writer.
 
Methods inherited from class org.ujac.util.xml.BaseObjectSerializer
closeOpenTag, delegateHandler, getEncoding, getRootLevel, getRootObject, indent, parseBooleanValue, parseIntValue, read, read, read, setEncoding, setRootLevel, startNewLine, write, write, writeAttribute, writeAttribute, writeAttribute, writeCloseTag, writeOpenTag, writeTag, writeTagBody
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DynamicObjectSerializer

public DynamicObjectSerializer()
Constructs a DynamicObjectSerializer instance with no specific attributes.


DynamicObjectSerializer

public DynamicObjectSerializer(String encoding)
Constructs a DynamicObjectSerializer instance with specific attributes.

Parameters:
encoding - The encoding to use.

DynamicObjectSerializer

public DynamicObjectSerializer(String encoding,
                               TypeConverter typeConverter)
Constructs a DynamicObjectSerializer instance with specific attributes.

Parameters:
encoding - The encoding to use.
typeConverter - The type converter to use.
Method Detail

getRootElement

public ElementDefinition getRootElement()
Gets the root element definition.

Returns:
The current root element definition.

setRootElement

public void setRootElement(ElementDefinition rootElement)
Sets the root element definition.

Parameters:
rootElement - The root element definition.

registerComplexTypes

protected void registerComplexTypes()
Registers the base complex types.


setComplexType

public void setComplexType(ComplexTypeDefinition clazz)
Sets the element class for the given tag name.

Parameters:
clazz - The element class to define.

getComplexType

public ComplexTypeDefinition getComplexType(String name)
Gets the element class for the given tag name.

Parameters:
name - The tag name to retrieve the element class for.
Returns:
The according element class.

getComplexType

public ComplexTypeDefinition getComplexType(Class clazz)
Gets the element class for the given tag name.

Parameters:
clazz - The object class to retrieve the type definition for.
Returns:
The according element class.

write

public void write(PrintWriter writer,
                  Object obj)
           throws IOException
Writes an object to the given print writer.

Overrides:
write in class BaseObjectSerializer
Parameters:
writer - The writer to write the WebForm to.
obj - The instance to write.
Throws:
IOException - In case an I/O failure occurred.

writeObject

public void writeObject(PrintWriter writer,
                        ElementDefinition elementDefinition,
                        Object obj,
                        int level)
                 throws IOException
Writes an object to the given print writer.

Parameters:
writer - The writer to write the WebForm to.
elementDefinition - The definition of the element.
obj - The instance to write.
level - The indention level.
Throws:
IOException - In case an I/O failure occurred.

startElement

public void startElement(BaseObjectSerializer.StackElement localElement,
                         BaseObjectSerializer.StackElement parentElement,
                         Object root)
                  throws SAXException
Description copied from class: BaseObjectSerializer
Starts the given local element.

Specified by:
startElement in class BaseObjectSerializer
Parameters:
localElement - The element to process.
parentElement - The parent element if present, else null.
root - The root object of the data structure.
Throws:
SAXException - In case the parsing failed.
See Also:
BaseObjectSerializer.startElement(org.ujac.util.xml.BaseObjectSerializer.StackElement, org.ujac.util.xml.BaseObjectSerializer.StackElement, java.lang.Object)

endElement

public void endElement(BaseObjectSerializer.StackElement localElement,
                       String content,
                       BaseObjectSerializer.StackElement parentElement,
                       Object root)
                throws SAXException
Description copied from class: BaseObjectSerializer
Ends the given local element.

Specified by:
endElement in class BaseObjectSerializer
Parameters:
localElement - The element to process.
content - The content of the local element.
parentElement - The parent element if present, else null.
root - The root object of the data structure.
Throws:
SAXException - In case the parsing failed.
See Also:
BaseObjectSerializer.endElement(org.ujac.util.xml.BaseObjectSerializer.StackElement, java.lang.String, org.ujac.util.xml.BaseObjectSerializer.StackElement, java.lang.Object)

attributeName2PropertyName

public String attributeName2PropertyName(String attributeName)
Converts the given attribute name (form: parta-partb) into a property name (form: partaPartb).

Parameters:
attributeName - The attribute name to convert.
Returns:
The resulting property name.

propertyName2AttributeName

public String propertyName2AttributeName(String propertyName)
Converts the given property name (form: partaPartb) into a attribute name (form: parta-partb).

Parameters:
propertyName - The property name to convert.
Returns:
The resulting attribute name.


Copyright © 2003-2004 UJAC.org. All Rights Reserved.