|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--mls.common.XmlObject | +--mls.common.TranslatingXmlObject
An XML aware object that can translate from XML to Java and back
Field Summary | |
private static java.lang.String |
EMPTY
|
private static boolean |
NULL_BOOLEAN
|
private static byte |
NULL_BYTE
|
private static char |
NULL_CHAR
|
private static double |
NULL_DOUBLE
|
private static float |
NULL_FLOAT
|
private static int |
NULL_INTEGER
|
private static long |
NULL_LONG
|
private static short |
NULL_SHORT
|
private static java.lang.String |
NULL_STRING
|
Fields inherited from class mls.common.XmlObject |
INDENT |
Constructor Summary | |
TranslatingXmlObject()
|
Method Summary | |
private static void |
addCloseTag(java.lang.StringBuffer xmlDoc,
java.lang.String tag,
int level)
Add close tag to an initialized document |
private static void |
addOpenTag(java.lang.StringBuffer xmlDoc,
java.lang.String tag,
int level)
Add open tag to an initialized document |
private static void |
addString(java.lang.StringBuffer xmlDoc,
java.lang.String str,
int level)
Add a string element using level to determine indenting Do not add tags as these are assumed to exist Note this is only used by buildEnum |
private static void |
addString(java.lang.StringBuffer xmlDoc,
java.lang.String tag,
java.lang.String str,
int level)
Add a string element with CDATA quoting to an initialized document Use level to determine indenting |
private static void |
build(java.lang.StringBuffer sb,
java.lang.Object ob,
int level)
Build XML document from the specified object This routine is recursive to handle nesting; the recursion terminates primitive elements (or strings) are encountered level specifies indentation within the XML document |
private static void |
buildArrayPrimitive(java.lang.StringBuffer sb,
java.lang.Object array,
int index,
java.lang.Class arrayComponentClass,
int level)
Build a primitive element from an item in an array |
private static void |
buildEnum(java.lang.StringBuffer sb,
java.lang.Object ob,
java.lang.Class thisClass,
int level)
Build an enumerated type XML string |
private static void |
buildPrimitive(java.lang.StringBuffer sb,
java.lang.Object ob,
java.lang.reflect.Field field,
java.lang.Class fieldType,
int level)
Build a primitive element from the field in an object |
private static java.lang.String |
classNameToXmlTag(java.lang.String className)
Convert a class name to an xml tag name |
private static java.lang.Object |
extract(java.lang.Class thisClass,
org.w3c.dom.Element el)
Extract an instance of the specified class from the supplied DOM element This routine is recursive to handle nesting; the recursion terminates when primitive elements (or strings) are encountered |
private static void |
extractArrayPrimitive(java.lang.Object array,
int index,
java.lang.Class arrayComponentClass,
org.w3c.dom.Element el)
Extract a primitive element's value and populate the indexed item in an array |
private static java.lang.Object |
extractEnum(java.lang.Class thisClass,
org.w3c.dom.Element el)
Extract a value for an enumerated type |
private static void |
extractPrimitive(java.lang.Object ob,
java.lang.reflect.Field field,
java.lang.Class fieldType,
org.w3c.dom.Element el)
Extract a primitive element's values and populate a field in an object |
private static java.lang.StringBuffer |
initDoc()
Initialize a document as a standalone document |
private static boolean |
isPrimitive(java.lang.Class fieldType)
Return true if this is a Java primitive or String class |
static java.lang.String |
object2Xml(java.lang.Object ob)
Build an xml document string from the specified object |
static java.lang.Object |
xml2Object(java.lang.String fileName,
java.lang.String className)
Extract an object from the specified xml document file |
Methods inherited from class mls.common.XmlObject |
dump,
dumpElement,
getChildren,
getChildren,
getElement,
getElement,
getElement,
getElementText,
getParser,
indent,
narrow,
nElements,
parse,
parseString |
Methods inherited from class java.lang.Object |
|
Field Detail |
private static final java.lang.String EMPTY
private static final int NULL_INTEGER
private static final short NULL_SHORT
private static final byte NULL_BYTE
private static final long NULL_LONG
private static final float NULL_FLOAT
private static final double NULL_DOUBLE
private static final char NULL_CHAR
private static final boolean NULL_BOOLEAN
private static final java.lang.String NULL_STRING
Constructor Detail |
public TranslatingXmlObject()
Method Detail |
public static java.lang.String object2Xml(java.lang.Object ob)
ob
- the Object to convert to XMLprivate static java.lang.StringBuffer initDoc()
private static void addString(java.lang.StringBuffer xmlDoc, java.lang.String tag, java.lang.String str, int level)
xmlDoc
- IN OUT the string buffer to which this will be addedtag
- the element tag to addstr
- the element's contained textlevel
- the level of indentation to applyprivate static void addString(java.lang.StringBuffer xmlDoc, java.lang.String str, int level)
xmlDoc
- IN OUT the string buffer to which this will be addedstr
- the text to addlevel
- the level of indentation to applyprivate static void addOpenTag(java.lang.StringBuffer xmlDoc, java.lang.String tag, int level)
xmlDoc
- IN OUT the string buffer to which this will be addedtag
- the element tag to addlevel
- the level of indentation to applyprivate static void addCloseTag(java.lang.StringBuffer xmlDoc, java.lang.String tag, int level)
xmlDoc
- IN OUT the string buffer to which this will be addedtag
- the element tag to addlevel
- the level of indentation to applyprivate static void build(java.lang.StringBuffer sb, java.lang.Object ob, int level)
sb
- IN OUT the string buffer in which the object will be builtob
- The object to convert to an XML stringlevel
- the level of indentation to applyprivate static void buildArrayPrimitive(java.lang.StringBuffer sb, java.lang.Object array, int index, java.lang.Class arrayComponentClass, int level)
sb
- IN OUT the string buffer in which the object will be builtarray
- the array containing the primitiveindex
- the index of this element in the arrayarrayComponentClass
- the class of this array's componentslevel
- the level of indentation to applyprivate static void buildPrimitive(java.lang.StringBuffer sb, java.lang.Object ob, java.lang.reflect.Field field, java.lang.Class fieldType, int level)
sb
- IN OUT the string buffer in which the object will be builton
- the object containing this primitivefield
- the field containing this primitivefieldType
- the class of this fieldlevel
- the level of indentation to applyprivate static void buildEnum(java.lang.StringBuffer sb, java.lang.Object ob, java.lang.Class thisClass, int level)
sb
- IN OUT the string buffer in which the object will be builtob
- the object containing this enumerationthisClass
- the class of this enumerationlevel
- the level of indentation to applyprivate static java.lang.String classNameToXmlTag(java.lang.String className)
className
- the class name to convertprivate static boolean isPrimitive(java.lang.Class fieldType)
fieldType
- The type of field to evaluatepublic static java.lang.Object xml2Object(java.lang.String fileName, java.lang.String className) throws java.lang.ClassNotFoundException
fileName
- the file containing an XML documentclassName
- the full Java class name (including package)
of the object corresponding to the root of the XML documentprivate static java.lang.Object extract(java.lang.Class thisClass, org.w3c.dom.Element el)
thisClass
- the Java class that corresponds to the DOM elementel
- a DOM element containing a tag that corresponds to thisClassprivate static void extractArrayPrimitive(java.lang.Object array, int index, java.lang.Class arrayComponentClass, org.w3c.dom.Element el)
array
- the array which will contain the primitiveindex
- the index of this element in the arrayarrayComponentClass
- the class of this array's componentsel
- the element from which this will be extractedprivate static void extractPrimitive(java.lang.Object ob, java.lang.reflect.Field field, java.lang.Class fieldType, org.w3c.dom.Element el)
ob
- the object which will contain the primitivefield
- teh field in the object which will contain the primitivefieldType
- the class of this fieldel
- the element from which this will be extractedprivate static java.lang.Object extractEnum(java.lang.Class thisClass, org.w3c.dom.Element el)
thisClass
- the class of this enumerationel
- the element from which this will be extracted
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |