public class XmlEncoder extends XmlUtil
XmlUtil.ElementListIterator
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ATTR_CLASS
The name for the class attribute.
|
static java.lang.String |
ATTR_ENCODING
The name for the encode attribute
|
static java.lang.String |
ATTR_ID
The name for the id attribute.
|
static java.lang.String |
ATTR_IDREF
The name for the idref attribute.
|
static java.lang.String |
ATTR_LENGTH
The name for the length attribute.
|
static java.lang.String |
ATTR_NAME
The name for the name attribute.
|
static java.lang.String |
ATTR_NULL
The name for the null attribute.
|
static java.lang.String |
ATTR_STRINGVALUE
The name for the stringvalue attribute.
|
static java.lang.String |
ATTR_VALUE
The name for the value attribute.
|
static boolean |
debug
Just a debug flag.
|
protected java.util.ArrayList |
delegateClasses
List of classes that we have corresponding
XmlDelegate s for. |
protected java.util.ArrayList |
delegates
The List of
XmlDelegate s that know how to handle certain classes. |
protected org.w3c.dom.Document |
document
The Xml document we create.
|
static java.lang.String |
METHOD_ADD
Method name for List.add
|
static java.lang.String |
METHOD_INIT
The name of the init method that is called (if it exists)
after an object is deserialized
|
static java.lang.String |
METHOD_PUT
Method name for Hashtable.put
|
static java.lang.String |
NAME_STRING
The name used in the xml for String objects.
|
static java.lang.String |
TAG_ARRAY
The tag name used for arrays.
|
static java.lang.String |
TAG_CONSTRUCTOR
The xml tag for constructors.
|
static java.lang.String |
TAG_ENUM
The tag name used for enums.
|
static java.lang.String |
TAG_FACTORY
The xml tag for factory objects.
|
static java.lang.String |
TAG_FIELD
The xml tag for object fields.
|
static java.lang.String |
TAG_IGNORE
The xml tag when we want to ignore something?
|
static java.lang.String |
TAG_METHOD
The xml tag for method calls.
|
static java.lang.String |
TAG_NULL
The xml tag for the null object.
|
static java.lang.String |
TAG_OBJECT
The xml tag for objects.
|
static java.lang.String |
TAG_PARRAY
The tag name used for primitive arrays.
|
static java.lang.String |
TAG_PROPERTY
The xml tag for properties.
|
static java.lang.String |
TAG_SERIAL
The xml tag for serialized objects.
|
static java.lang.String |
VALUE_BASE64
The value for the encode by base64
|
NULL_STRING, TAG_WILDCARD, XML_HEADER
Constructor and Description |
---|
XmlEncoder()
Create a new XmlEncoder.
|
Modifier and Type | Method and Description |
---|---|
void |
addClassPatternReplacement(java.lang.String pattern,
java.lang.String replace)
This allows on to change package paths of classes that are in bundles
with a new path
|
protected void |
addDefaultDelegates()
Define the set of default delegates (e.g., for Rectangle, Font, etc.) for common objects
that don't encode very well.
|
void |
addDelegateForClass(java.lang.Class theClass,
XmlDelegate delegate)
Add an
XmlDelegate for the given class. |
void |
addHighPriorityDelegateForClass(java.lang.Class theClass,
XmlDelegate delegate)
Add an
XmlDelegate for the given class. |
void |
addSeedObject(java.lang.Object seedObject)
Add an existing object from the environement that is to be used in place
of a newly created object.
|
void |
clear()
Clear the internal state this encoder keeps during the encoding/decoding process.
|
org.w3c.dom.Element |
createArrayElement(java.lang.Object arrayObject)
Create an Xml Element that represents the given object (which should be an array).
|
ObjectClass |
createArrayObject(org.w3c.dom.Element element)
Create an array that contains a set of objects.
|
org.w3c.dom.Element |
createConstructorElement(java.util.List arguments)
Construct a "constructor" tag that holds the set of argument objects.
|
org.w3c.dom.Element |
createConstructorElement(java.util.List arguments,
java.util.List types)
Construct a "constructor" tag that holds the set of argument objects with respective types.
|
org.w3c.dom.Element |
createElement(java.lang.Object object)
This acts as a wrapper around
(Object, boolean) ,
passing in true for the checkPersistable flag. |
org.w3c.dom.Element |
createElement(java.lang.Object object,
boolean checkDelegate)
This acts as a wrapper around
createElement(Object,Class,boolean,boolean) ,
passing in true for the checkPersistable flag. |
protected org.w3c.dom.Element |
createElement(java.lang.Object object,
java.lang.Class theClass)
This acts as a wrapper around
createElement(Object,Class,boolean,boolean) ,
passing in true and true for the checkPersistable and checkDelegate flags. |
protected org.w3c.dom.Element |
createElement(java.lang.Object object,
java.lang.Class theClass,
boolean checkPersistable,
boolean checkDelegate)
Create a xml representation of the object.
|
org.w3c.dom.Element |
createElementDontCheckDelegate(java.lang.Object object)
This acts as a wrapper around
createElement(Object,boolean) ,
passing in false for the checkDelegate flag. |
org.w3c.dom.Element |
createElementDontCheckPersistable(java.lang.Object object)
This acts as a wrapper around
createElement(Object,Class,boolean,boolean) ,
passing in false for the checkPersistable flag and true for the checkDelegate flag. |
org.w3c.dom.Element |
createElementForObject(java.lang.Object object,
java.lang.Class theClass)
Construct the Xml representation of the given object.
|
<E extends java.lang.Enum<E>> |
createEnumElement(E e)
Creates the element based on the enum.
|
ObjectClass |
createEnumObject(org.w3c.dom.Element element)
Creates the enum.
|
org.w3c.dom.Element |
createFactoryElement(java.lang.Class factoryClass)
Create a "factory" tag with the given factoryClass.
|
org.w3c.dom.Element |
createMethodElement(java.lang.String methodName)
Create a "method" xml element, one that represents a method call.
|
org.w3c.dom.Element |
createMethodElement(java.lang.String methodName,
org.w3c.dom.Element contents)
Create a "method" xml element, one that represents a method call.
|
org.w3c.dom.Element |
createMethodElement(java.lang.String methodName,
java.util.List argumentElements)
Create a "method" xml element, one that represents a method call.
|
org.w3c.dom.Element |
createNullElement()
Create a null element with no class.
|
org.w3c.dom.Element |
createNullElement(java.lang.Class type)
Create a null element with the given class (if non-null).
|
java.lang.Object |
createObject(org.w3c.dom.Element element)
Create an object defined by the given XML.
|
org.w3c.dom.Element |
createObjectConstructorElement(java.lang.Object object,
java.util.List arguments)
Create an object tag that holds a constructor tag.
|
org.w3c.dom.Element |
createObjectConstructorElement(java.lang.Object object,
java.util.List arguments,
java.util.List types)
Create an object tag that holds a constructor tag.
|
java.lang.Object |
createObjectDontCheckDelegate(org.w3c.dom.Element element)
Create an object defined by the given XML.
|
org.w3c.dom.Element |
createObjectElement(java.lang.Class objectClass)
Create a "object" tag with the given objectClass.
|
ObjectClass |
createObjectInner(org.w3c.dom.Element element)
Create the object defined by the given xml.
|
ObjectClass |
createObjectInner(org.w3c.dom.Element element,
boolean checkDelegate)
This method creates both the Object that the Element element
represents and its Class.
|
org.w3c.dom.Element |
createPrimitiveArrayElement(java.lang.Object primitiveArray)
Create an Xml Element that represents the given array of primitives.
|
ObjectClass |
createPrimitiveArrayObject(org.w3c.dom.Element element)
Create an array that contains a set of primitive objects.
|
org.w3c.dom.Element |
createPrimitiveElement(java.lang.String primitiveName,
java.lang.Object value)
Create the xml element for the given primitive value and name.
|
ObjectClass |
createPrimitiveObject(java.lang.Class primitiveClass,
org.w3c.dom.Element element)
Create the primitive object defined by the given class and xml element.
|
java.lang.Object |
createPrimitiveObject(java.lang.Class primitiveClass,
java.lang.String value)
Create the primitive object defined by the given class and value.
|
org.w3c.dom.Element |
createPropertyElement(java.lang.String propertyName,
org.w3c.dom.Element value)
Create a "property" xml element, one that represents a bean property on an object.
|
org.w3c.dom.Element |
createReferenceElement(java.lang.String id)
Create an element that represents a reference to an already encoded object.
|
org.w3c.dom.Element |
createSerialElement(java.lang.Class theClass,
java.lang.String serialRepresentation)
Create a "serial" xml element, one that represents a serialized Object.
|
ObjectClass |
createSerializedObject(org.w3c.dom.Element parent)
Deserialize the serialized object defined by the given parent xml element.
|
org.w3c.dom.Node |
createTextNode(java.lang.String contents)
A utility to create a text node
|
static java.lang.Object |
decodeXml(java.lang.String xml)
Decode the XML
|
void |
defineObjectId(java.lang.Object theObject,
java.lang.String theId)
Allow client code to predefine an object to id mapping.
|
static java.lang.Object |
deserialize(byte[] bytes)
A utility to deserialize the given bytes
|
static java.lang.String |
encodeObject(java.lang.Object object)
XML encode the object
|
static java.util.List |
findPropertyMethods(java.lang.Class c)
For the given class find the set of public set/get property methods.
|
static java.util.List |
findPropertyMethods(java.lang.Class c,
boolean returnGetters)
Find the property methods
|
java.lang.Class |
getClass(java.lang.String className)
Find the Class that corresponds to the given className.
|
java.lang.String |
getClassName(java.lang.Class theClass)
Get the String name of the given class.
|
protected XmlDelegate |
getDelegate(java.lang.Class theClass)
Find the
XmlDelegate that handles the given class. |
org.w3c.dom.Document |
getDocument()
Create (if needed) and return the xml Document for this encoder.
|
protected org.w3c.dom.Element |
getElementForObject(java.lang.Object theObject)
Return the DOM element that represents the given object.
|
java.util.List |
getErrorMessages()
The the error messages
|
java.util.List |
getExceptions()
Get the exceptions
|
java.util.List |
getFieldElements(java.lang.Object object,
java.util.Hashtable propertyNames)
Return a List of Xml Elements that represent the set of public fields in the given object.
|
protected java.lang.String |
getNextId()
Utility method to return a unique (during a particular encoding) String id.
|
protected java.lang.Object |
getObjectFromId(java.lang.String id)
Returns the object (maybe null) that has the given id.
|
protected java.lang.String |
getObjectId(java.lang.Object theObject)
Return the encoding id defined for the given object.
|
java.lang.Class |
getPrimitiveClass(java.lang.String name)
For the given name (e.g., "int", "boolean") return the class (e.g., Integer.TYPE, Boolean.TYPE).
|
java.lang.reflect.Constructor |
getPrimitiveCtor(java.lang.Class primitiveClass)
Find the Constructor that creates objects of the given primitive class.
|
java.lang.String |
getPrimitiveName(java.lang.Class primitiveClass)
Return the name of the class to be used for the given class.
|
java.util.List |
getPropertyElements(java.lang.Object object,
java.util.Hashtable propertyNames)
Return a List of Xml Elements that represent the set of public properties in the given object.
|
java.util.List |
getSpecialCaseElements(java.lang.Object object)
Handle certain objects in a special way.
|
java.lang.String |
getTextFromChild(org.w3c.dom.Element parent)
A utility to find the text node child of the given parent
|
protected void |
init()
This resets the state of this encoder.
|
protected void |
initPrimitiveName()
Initialize the mapping between names for primitives and their classes.
|
protected void |
invokeField(java.lang.Object object,
java.lang.String fieldName,
org.w3c.dom.Element parent)
Set the field, identified by the given field name, on the given object,
to the value defined by the first xml child of the given parent.
|
protected void |
invokeMethod(java.lang.Object object,
java.lang.String methodName,
org.w3c.dom.Element element)
Invoke the the method, identified by the given method name, on the given object.
|
boolean |
isPrimitive(java.lang.Class theClass)
Is the given Class a primitive (e.g., an int, float, Integer, Double, etc.).
|
static void |
main(java.lang.String[] args)
Runs some tests.
|
boolean |
methodOk(java.lang.String methodName)
Is the given method name one of the allowable methods to execute.
|
org.w3c.dom.Element |
newElement(java.lang.String tagName)
Create a new Element of the given tag name using the current document.
|
static void |
pr(java.lang.String msg)
A utility method to print out an error message if we are in debug mode.
|
void |
registerClassName(java.lang.String theName,
java.lang.Class theClass)
Define a mapping from some name (perhaps an old class path) to the new
Class that actually is used to create an object.
|
void |
registerNewClassName(java.lang.String oldName,
java.lang.String newName)
Register new class name
|
static byte[] |
serialize(java.io.Serializable object)
A utility to serialize the given object
|
void |
setDocument(org.w3c.dom.Document document)
Set the xml Document used by this encoder.
|
protected void |
setObject(java.lang.String id,
java.lang.Object theObject)
Define a mapping between the given id and the object.
|
protected java.lang.String |
setObjectId(java.lang.Object theObject)
Create a new id and define mappings between the id, object and DOM element.
|
java.lang.String |
setObjectId(java.lang.Object theObject,
org.w3c.dom.Element element)
Create a new id and define mappings between the id, object and DOM element.
|
boolean |
test(java.lang.Object o,
boolean printXml)
A simple test method.
|
org.w3c.dom.Element |
toElement(java.lang.Object theObject)
Create the DOM Element that represents the given object.
|
java.lang.Object |
toObject(org.w3c.dom.Element node)
Create an object from the given dom subtree.
|
java.lang.Object |
toObject(java.lang.String xml)
Create an object from the given xml.
|
java.lang.Object |
toObject(java.lang.String xml,
boolean catchAndLogError)
XML string to object
|
java.lang.String |
toXml(java.lang.Object theObject)
Convert the given object to xml, formatting the xml (with spaces and newlines).
|
java.lang.String |
toXml(java.lang.Object theObject,
boolean formatXml)
Convert the given object to xml.
|
addChildren, appendCdata, appendCdataBytes, attr, attr, attrs, attrs, attrs, attrs, attrs, calculateRFC2104HMAC, closeTag, comment, create, create, create, create, create, create, create, create, create, create, create, create, createCDataNode, decodeBase64, elements, encodeBase64, encodeString, ensureAttributes, eval, expr, findAncestor, findChild, findChildRecurseUp, findChildren, findChildrenRecurseUp, findDescendant, findDescendantFromPath, findDescendants, findDescendantsFromPath, findElement, findElement, findRoot, findUrlRefNode, findUrlRefNode, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttributeFromTree, getAttributeFromTree, getAttributeFromTree, getAttributeFromTree, getAttributesFromTree, getAttributesFromTree, getCdata, getChildText, getDocument, getDocument, getDocument, getElement, getElements, getElements, getElements, getFirstChild, getGrandChildren, getGrandChildText, getGrandChildText, getGrandChildValue, getHeader, getListOfElements, getLocalName, getNodeName, getRoot, getRoot, getRoot, hasAttribute, isFullyQualified, isTag, loadXml, makeCDataNode, makeCDataNode, makeDocument, mergeAttributes, openTag, openTag, quote, removeChildren, setAttribute, setAttributes, tag, tag, toHtml, toString, toString, toString, toString, toString, toStringNoChildren, toStringWithHeader, toStringWithHeader, toStringWithHeader
public static boolean debug
public static final java.lang.String METHOD_INIT
public static final java.lang.String METHOD_PUT
public static final java.lang.String METHOD_ADD
public static final java.lang.String NAME_STRING
public static final java.lang.String TAG_ARRAY
public static final java.lang.String TAG_ENUM
public static final java.lang.String TAG_PARRAY
public static final java.lang.String TAG_CONSTRUCTOR
public static final java.lang.String TAG_FACTORY
public static final java.lang.String TAG_FIELD
public static final java.lang.String TAG_IGNORE
public static final java.lang.String TAG_METHOD
public static final java.lang.String TAG_NULL
public static final java.lang.String TAG_OBJECT
public static final java.lang.String TAG_PROPERTY
public static final java.lang.String TAG_SERIAL
public static final java.lang.String ATTR_CLASS
public static final java.lang.String ATTR_ENCODING
public static final java.lang.String VALUE_BASE64
public static final java.lang.String ATTR_ID
public static final java.lang.String ATTR_IDREF
public static final java.lang.String ATTR_NAME
public static final java.lang.String ATTR_NULL
public static final java.lang.String ATTR_STRINGVALUE
public static final java.lang.String ATTR_LENGTH
public static final java.lang.String ATTR_VALUE
protected org.w3c.dom.Document document
protected java.util.ArrayList delegateClasses
XmlDelegate
s for.protected java.util.ArrayList delegates
XmlDelegate
s that know how to handle certain classes.protected void addDefaultDelegates()
public java.lang.String toXml(java.lang.Object theObject)
theObject
- The object to convert.public java.lang.String toXml(java.lang.Object theObject, boolean formatXml)
theObject
- The object to convert.formatXml
- Do we format the result xml with newlines and spaces to make it readable.public java.util.List getExceptions()
public java.util.List getErrorMessages()
public org.w3c.dom.Element toElement(java.lang.Object theObject)
theObject
- The object to encode.public static java.lang.Object decodeXml(java.lang.String xml) throws java.lang.Exception
xml
- java.lang.Exception
public static java.lang.String encodeObject(java.lang.Object object) throws java.lang.Exception
object
- java.lang.Exception
public java.lang.Object toObject(java.lang.String xml) throws java.lang.Exception
xml
- The xml String that defines an object.java.lang.Exception
- When anything bad happens.public java.lang.Object toObject(java.lang.String xml, boolean catchAndLogError) throws java.lang.Exception
xml
- catchAndLogError
- java.lang.Exception
public java.lang.Object toObject(org.w3c.dom.Element node)
node
- The xml.public void clear()
protected void init()
public boolean methodOk(java.lang.String methodName)
methodName
- The mehtod name.public void addDelegateForClass(java.lang.Class theClass, XmlDelegate delegate)
XmlDelegate
for the given class.
The delegate is the object responsible for the persistence
of all objects of the type of the given class or are a derived class.theClass
- The class to handle.delegate
- The delegate that handles the class.public void addHighPriorityDelegateForClass(java.lang.Class theClass, XmlDelegate delegate)
XmlDelegate
for the given class. The given delegate
will get added to the beginning of the list so that it takes
priority over ant existing delegates
The delegate is the object responsible for the persistence
of all objects of the type of the given class or are a derived class.theClass
- The class to handle.delegate
- The delegate that handles the class.protected XmlDelegate getDelegate(java.lang.Class theClass)
XmlDelegate
that handles the given class.theClass
- The class.public org.w3c.dom.Document getDocument()
public void setDocument(org.w3c.dom.Document document)
document
- The new xml document for this encoder to use.protected java.lang.String getNextId()
protected java.lang.Object getObjectFromId(java.lang.String id)
id
- The id to lookup.public void addSeedObject(java.lang.Object seedObject)
seedObject
- The object that exists in the environment that we really want to use.protected void setObject(java.lang.String id, java.lang.Object theObject)
id
- The id of the object.theObject
- The object.protected java.lang.String getObjectId(java.lang.Object theObject)
theObject
- The object to lookup an id for.protected org.w3c.dom.Element getElementForObject(java.lang.Object theObject)
theObject
- The object.public void defineObjectId(java.lang.Object theObject, java.lang.String theId)
encoder.defineObjectId (someSingletonObject, "idOfSingletonObject");Will result in xml that looks like:
<object class="SomeOtherObject"> ... < property name="referenceToSomeSingleton" idref="idOfSingletonObject"/> ...Now when we decode the above xml the object defined with "idOfSingletonObject" will be pre-loaded here.
theObject
- The initial object.theId
- The id.protected java.lang.String setObjectId(java.lang.Object theObject)
theObject
- The object to define an id for.public java.lang.String setObjectId(java.lang.Object theObject, org.w3c.dom.Element element)
theObject
- The object to define a new id for.element
- The Xml DOM node that defines theObject.protected void initPrimitiveName()
public boolean isPrimitive(java.lang.Class theClass)
theClass
- The class to check.public java.lang.String getPrimitiveName(java.lang.Class primitiveClass)
primitiveClass
- The class.public java.lang.Class getPrimitiveClass(java.lang.String name)
name
- Primitive class name.public java.lang.reflect.Constructor getPrimitiveCtor(java.lang.Class primitiveClass)
primitiveClass
- The class of the primitive (e.g., Integer, int, etc.)public void registerClassName(java.lang.String theName, java.lang.Class theClass)
encoder.registerClassName ("old.path.SomeObject", new.path.SomeObject.class);
theName
- The old class name.theClass
- The new Class to use.public void registerNewClassName(java.lang.String oldName, java.lang.String newName)
oldName
- the old namenewName
- the new namepublic void addClassPatternReplacement(java.lang.String pattern, java.lang.String replace)
pattern
- the patternreplace
- the replace patternpublic java.lang.Class getClass(java.lang.String className) throws java.lang.ClassNotFoundException
className
- The name of the Class.java.lang.ClassNotFoundException
- When we cannot find the class.public java.lang.String getClassName(java.lang.Class theClass)
theClass
- The Class.public org.w3c.dom.Element newElement(java.lang.String tagName)
tagName
- The tag name.public org.w3c.dom.Element createArrayElement(java.lang.Object arrayObject)
String[]array ={"foo", "bar"};would result in: String[]array ={"foo", "bar"};
<array class="string" length="2" > <string><![CDATA[foo]]></string> <string><![CDATA[bar]]></string> </array>Primitive arrays are handled differently (for size reasons):
int[]array ={5,4};Would result in:
<parray class="int" length="2" >5,4</parray>
arrayObject
- The array object.public <E extends java.lang.Enum<E>> org.w3c.dom.Element createEnumElement(E e)
E
- the enum element typee
- the epublic org.w3c.dom.Element createPrimitiveArrayElement(java.lang.Object primitiveArray)
primitiveArray
- The array of primitives.public org.w3c.dom.Node createTextNode(java.lang.String contents)
contents
- The textpublic static java.lang.Object deserialize(byte[] bytes) throws java.lang.Exception
bytes
- The bytesjava.lang.Exception
- When something bad happenspublic static byte[] serialize(java.io.Serializable object) throws java.lang.Exception
object
- The objectjava.lang.Exception
- When something bad happenspublic org.w3c.dom.Element createMethodElement(java.lang.String methodName, java.util.List argumentElements)
methodName
- The name of the method.argumentElements
- List of method arguments.public org.w3c.dom.Element createMethodElement(java.lang.String methodName, org.w3c.dom.Element contents)
methodName
- The name of the method.contents
- Xml represention of the method arguments.public org.w3c.dom.Element createMethodElement(java.lang.String methodName)
methodName
- The name of the method.public org.w3c.dom.Element createSerialElement(java.lang.Class theClass, java.lang.String serialRepresentation)
theClass
- The class of the original serialized object.serialRepresentation
- Go figure.public org.w3c.dom.Element createPropertyElement(java.lang.String propertyName, org.w3c.dom.Element value)
propertyName
- The bean name.value
- The xml represention of the property value.public org.w3c.dom.Element createReferenceElement(java.lang.String id)
id
- The id of the object.public org.w3c.dom.Element createPrimitiveElement(java.lang.String primitiveName, java.lang.Object value)
primitiveName
- The name of the primitive (e.g., string, int, etc.)value
- The value.public org.w3c.dom.Element createNullElement(java.lang.Class type)
type
- The class of the null object.public org.w3c.dom.Element createNullElement()
public org.w3c.dom.Element createObjectElement(java.lang.Class objectClass)
objectClass
- The class of the object.public org.w3c.dom.Element createFactoryElement(java.lang.Class factoryClass)
factoryClass
- The class of the object that implements XmlObjectFactory
.public org.w3c.dom.Element createObjectConstructorElement(java.lang.Object object, java.util.List arguments)
object
- The object to encode.arguments
- The argument values to the constructor.public org.w3c.dom.Element createObjectConstructorElement(java.lang.Object object, java.util.List arguments, java.util.List types)
object
- The object to encode.arguments
- The argument values to the constructor.types
- The types of the argumentspublic org.w3c.dom.Element createConstructorElement(java.util.List arguments)
arguments
- The argument values.public org.w3c.dom.Element createConstructorElement(java.util.List arguments, java.util.List types)
arguments
- The argument values.types
- The types of the arguments.public static java.util.List findPropertyMethods(java.lang.Class c)
c
- The class to look at.public static java.util.List findPropertyMethods(java.lang.Class c, boolean returnGetters)
c
- the classreturnGetters
- return the getterspublic java.lang.Object createObject(org.w3c.dom.Element element)
element
- The xml representation of the object.public java.lang.Object createObjectDontCheckDelegate(org.w3c.dom.Element element)
element
- The xml representation of the object.public ObjectClass createArrayObject(org.w3c.dom.Element element)
element
- The xml representation of the array.public ObjectClass createEnumObject(org.w3c.dom.Element element)
element
- the elementpublic java.lang.String getTextFromChild(org.w3c.dom.Element parent)
parent
- The parent nodepublic ObjectClass createPrimitiveArrayObject(org.w3c.dom.Element element)
element
- The xml representation of the primitive array.public ObjectClass createPrimitiveObject(java.lang.Class primitiveClass, org.w3c.dom.Element element)
primitiveClass
- The class of the primitive.element
- The xml representation of the primitive.public java.lang.Object createPrimitiveObject(java.lang.Class primitiveClass, java.lang.String value)
primitiveClass
- The class of the primitive.value
- The String representation of the value.public ObjectClass createSerializedObject(org.w3c.dom.Element parent)
parent
- Contains the serialization xml.public ObjectClass createObjectInner(org.w3c.dom.Element element)
element
- Defines the object.public ObjectClass createObjectInner(org.w3c.dom.Element element, boolean checkDelegate)
element
- The xml element that represents the encoded object.checkDelegate
- Should we check if there is an XmlDelegate
for this object.protected void invokeMethod(java.lang.Object object, java.lang.String methodName, org.w3c.dom.Element element)
object
- The object to set the field value of.methodName
- The name of the method.element
- The parent xml node that contains the argument object values.protected void invokeField(java.lang.Object object, java.lang.String fieldName, org.w3c.dom.Element parent)
object
- The object to set the field value of.fieldName
- The name of the field.parent
- The parent xml node that contains the object value.public org.w3c.dom.Element createElement(java.lang.Object object)
(Object, boolean)
,
passing in true for the checkPersistable flag.object
- The object to create the xml element for.public org.w3c.dom.Element createElementDontCheckPersistable(java.lang.Object object)
createElement(Object,Class,boolean,boolean)
,
passing in false for the checkPersistable flag and true for the checkDelegate flag.object
- The object to create the xml element for.public org.w3c.dom.Element createElementDontCheckDelegate(java.lang.Object object)
createElement(Object,boolean)
,
passing in false for the checkDelegate flag.object
- The object to create the xml element for.public org.w3c.dom.Element createElement(java.lang.Object object, boolean checkDelegate)
createElement(Object,Class,boolean,boolean)
,
passing in true for the checkPersistable flag.object
- The object to create the xml element for.checkDelegate
- Should we check if the object has an XmlDelegate
that handles it.protected org.w3c.dom.Element createElement(java.lang.Object object, java.lang.Class theClass)
createElement(Object,Class,boolean,boolean)
,
passing in true and true for the checkPersistable and checkDelegate flags.object
- The object to create the xml element for.theClass
- Its class.protected org.w3c.dom.Element createElement(java.lang.Object object, java.lang.Class theClass, boolean checkPersistable, boolean checkDelegate)
object
- The object to encode.theClass
- The Class of the object.checkPersistable
- Do we defer to the object if is is an XmlPersistable
checkDelegate
- Do we defer to the delegate if the object has an XmlDelegate
public org.w3c.dom.Element createElementForObject(java.lang.Object object, java.lang.Class theClass)
object
- The regular object.theClass
- The class of the object. We have this here in case the object is null.public java.util.List getFieldElements(java.lang.Object object, java.util.Hashtable propertyNames)
object
- The object to look for fields in.propertyNames
- These represent properties that are already being persisted.public java.util.List getPropertyElements(java.lang.Object object, java.util.Hashtable propertyNames)
object
- The object to look for properties in.propertyNames
- Put the property names in here so we can keep them unique.public java.util.List getSpecialCaseElements(java.lang.Object object)
object
- The object to check for special case handling.public static void pr(java.lang.String msg)
msg
- The message.public boolean test(java.lang.Object o, boolean printXml) throws java.lang.Exception
o
- The object to encode.printXml
- Do we println the result xml.java.lang.Exception
- When something goes bad.public static void main(java.lang.String[] args)
args
- The command line arguments.