common-util

local.tomas.common.xml
Class XMLSerializer

java.lang.Object
  extended by local.tomas.common.xml.XMLSerializer

public class XMLSerializer
extends Object

This pure static class is used to create XML descriptions for instances of standard and user defined classes.

Author:
Teubner

Method Summary
static Class findType(String name)
          Find class with the given name.
static XMLTypeHandler getTypeHandler(Class type)
          Get a type handler for a class.
static XMLTypeHandler getTypeHandler(String name)
          Find a type handler for the class with the given name.
static void marshall(String name, Class type, Object src, XMLTokenGenerator gen)
          Create XML description for an object.
static void marshall(String name, int index, Class type, Object src, XMLTokenGenerator gen)
          Create XML description for an object.
static void marshall(String name, int index, Object src, XMLTokenGenerator gen)
          Create XML description for an object.
static void marshall(String name, Object src, XMLTokenGenerator gen)
          Create XML description for an object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getTypeHandler

public static XMLTypeHandler getTypeHandler(Class type)
Get a type handler for a class. A default handler is returned if no explicit association can be found.

Parameters:
type - - the class
Returns:
type handler

getTypeHandler

public static XMLTypeHandler getTypeHandler(String name)
Find a type handler for the class with the given name. A default handler is returned if no explicit association can be found.

Parameters:
name - - class name
Returns:
type handler

findType

public static Class findType(String name)
Find class with the given name.

Parameters:
name - - name of the class or type
Returns:
class or null if none

marshall

public static void marshall(String name,
                            int index,
                            Class type,
                            Object src,
                            XMLTokenGenerator gen)
                     throws XMLException
Create XML description for an object.

Parameters:
name - - XML tag name used
index - - index attribute used on XML tag, must be negative to omit index
type - - type of object
src - - the object
gen - - used to generate XML tokens
Throws:
XMLException

marshall

public static void marshall(String name,
                            int index,
                            Object src,
                            XMLTokenGenerator gen)
                     throws XMLException
Create XML description for an object.

Parameters:
name - - XML tag name used
index - - index attribute used on XML tag, must be negative to omit index
src - - the object
gen - - used to generate XML tokens
Throws:
XMLException

marshall

public static void marshall(String name,
                            Class type,
                            Object src,
                            XMLTokenGenerator gen)
                     throws XMLException
Create XML description for an object.

Parameters:
name - - XML tag name used
type - - type of object
src - - the object
gen - - used to generate XML tokens
Throws:
XMLException

marshall

public static void marshall(String name,
                            Object src,
                            XMLTokenGenerator gen)
                     throws XMLException
Create XML description for an object.

Parameters:
name - - XML tag name used
src - - the object
gen - - used to generate XML tokens
Throws:
XMLException

common-util

Copyright © 2007 null. All Rights Reserved.