|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||
java.lang.Object
|
+--com.wutka.jox.JOXBeanOutput
|
+--com.wutka.jox.JOXBeanDOM
Converts a Java Bean into an XML Document. If you don't supply a Document object, this class uses the DocumentBuilder to create a new document. For some tools like the Xalan XSL processor, you must use a specific Document implementation (the Xerces implementation). If you need to use Xalan, create your own Document using the Xerces API and pass it to one of the JOXBeanDOM constructors.
| Field Summary | |
protected java.util.Hashtable |
attrTranslation
|
protected static java.util.Hashtable |
beanCache
|
protected java.util.Hashtable |
childTranslation
|
protected static java.text.DateFormat |
dateFormat
The date formatter used to write out dates |
protected org.w3c.dom.Document |
document
|
protected com.wutka.dtd.DTD |
dtd
|
protected static java.lang.Object[] |
getParams
The dummy parameter block for invoking the getters for the bean |
protected java.util.Hashtable |
nameTranslation
|
protected com.wutka.jox.JOXOutput |
outputStream
|
static int |
WRITE_AS_ATTRIBUTE
|
static int |
WRITE_AS_ELEMENT
|
static int |
WRITE_AS_INDEXED_ELEMENT
|
protected boolean |
writeAttributes
|
| Constructor Summary | |
JOXBeanDOM()
Creates a JOXBeanDOM that stores simple properties as attributes |
|
JOXBeanDOM(boolean writeAttributesFlag)
Creates a JOXBeanDOM that doesn't use a DTD |
|
JOXBeanDOM(org.w3c.dom.Document aDocument)
Creates a JOXBeanDOM that stores simple properties as attributes |
|
JOXBeanDOM(org.w3c.dom.Document aDocument,
boolean writeAttributesFlag)
Creates a JOXBeanDOM that doesn't use a DTD |
|
JOXBeanDOM(org.w3c.dom.Document aDocument,
com.wutka.dtd.DTD aDTD)
Creates a JOXBeanDOM that uses a DTD to determine which attributes to store and what the format of the names should be. |
|
JOXBeanDOM(org.w3c.dom.Document aDocument,
java.lang.String dtdURL)
Creates a JOXBeanDOM that uses a DTD to determine which attributes to store and what the format of the names should be. |
|
JOXBeanDOM(com.wutka.dtd.DTD aDTD)
Creates a JOXBeanDOM that uses a DTD to determine which attributes to store and what the format of the names should be. |
|
JOXBeanDOM(java.lang.String dtdURL)
Creates a JOXBeanDOM that uses a DTD to determine which attributes to store and what the format of the names should be. |
|
| Method Summary | |
org.w3c.dom.Document |
beanToDocument(java.lang.String rootName,
java.lang.Object ob)
Stores a Java bean in an XML document (this is the main method for JOXBeanDOM). |
protected void |
createDocument()
Creates a new Document using a DocumentBuilder |
void |
expandChildElements(com.wutka.dtd.DTDContainer children,
java.util.Hashtable childTransTable)
|
java.lang.String |
getTranslatedChildName(java.lang.String elementName,
java.lang.String childName)
|
java.lang.String |
getTranslatedEntityName(java.lang.String name)
Finds the correct format of a name as given by the DTD. |
protected com.wutka.dtd.DTD |
readDTD(java.lang.String dtdURL)
|
protected void |
setupNameTranslation()
|
void |
storeBasicType(java.lang.String xmlTagName,
java.lang.String propName,
java.lang.Object propValue,
int writeType,
org.w3c.dom.Element parentElement)
Writes out a basic type including the opening and closing tags. |
void |
storeDate(java.lang.String xmlTagName,
java.lang.String propName,
java.lang.Object propValue,
int writeType,
org.w3c.dom.Element parentElement)
Writes out a date including the opening and closing tags |
void |
storeIndexedProperty(java.lang.String xmlTagName,
java.lang.Object ob,
java.beans.IndexedPropertyDescriptor prop,
org.w3c.dom.Element parentElement)
Stores an indexed property (an array of properties) |
org.w3c.dom.Element |
storeObject(java.lang.String rootName,
java.lang.Object ob)
Stores a bean in an XML element and returns the element |
void |
storeObjectFields(java.lang.String xmlTagName,
java.lang.Object ob,
int writeType,
org.w3c.dom.Element parentElement)
Stores the properties of a bean as DOM Elements |
void |
storeProperty(java.lang.String xmlTagName,
java.lang.Object ob,
java.beans.PropertyDescriptor prop,
int writeType,
org.w3c.dom.Element parentElement)
Stores a non-indexed property |
void |
storePropertyValue(java.lang.String xmlTagName,
java.lang.Object propValue,
java.beans.PropertyDescriptor prop,
int writeType,
org.w3c.dom.Element parentElement)
Stores a property value based on the property type |
void |
storeString(java.lang.String xmlTagName,
java.lang.String propName,
java.lang.Object propValue,
int writeType,
org.w3c.dom.Element parentElement)
Writes out a string, using CDATA if the string contains < or & |
java.lang.String |
stripName(java.lang.String name)
Converts a name to lower case and removes any '-' or '_' characters |
boolean |
writeAsAttribute(java.lang.String elementName,
java.lang.String attributeName)
Returns true if a tag name for a particular object should be written as an attribute |
void |
writeBasicType(java.lang.String xmlTagName,
java.lang.String propName,
java.lang.Object propValue,
int writeType)
Writes out a basic type including the opening and closing tags. |
void |
writeDate(java.lang.String xmlTagName,
java.lang.String propName,
java.lang.Object propValue,
int writeType)
Writes out a date including the opening and closing tags |
void |
writeIndexedProperty(java.lang.String xmlTagName,
java.lang.Object ob,
java.beans.IndexedPropertyDescriptor prop)
Writes out an indexed property (an array of properties) |
void |
writeObject(java.lang.String rootName,
java.lang.Object ob)
Writes out an object as XML |
void |
writeObjectFields(java.lang.String xmlTagName,
java.lang.Object ob,
int writeType)
Writes out the properties of a bean as XML |
void |
writeProperty(java.lang.String xmlTagName,
java.lang.Object ob,
java.beans.PropertyDescriptor prop,
int writeType)
Writes out a non-indexed property |
void |
writePropertyValue(java.lang.String xmlTagName,
java.lang.Object propValue,
java.beans.PropertyDescriptor prop,
int writeType)
Writes out a property value based on the property type |
void |
writeString(java.lang.String xmlTagName,
java.lang.String propName,
java.lang.Object propValue,
int writeType)
Writes out a string, using CDATA if the string contains < or & |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected org.w3c.dom.Document document
protected static java.util.Hashtable beanCache
public static final int WRITE_AS_ATTRIBUTE
public static final int WRITE_AS_ELEMENT
public static final int WRITE_AS_INDEXED_ELEMENT
protected static java.text.DateFormat dateFormat
protected static java.lang.Object[] getParams
protected java.util.Hashtable nameTranslation
protected java.util.Hashtable attrTranslation
protected java.util.Hashtable childTranslation
protected com.wutka.dtd.DTD dtd
protected com.wutka.jox.JOXOutput outputStream
protected boolean writeAttributes
| Constructor Detail |
public JOXBeanDOM()
throws java.io.IOException
public JOXBeanDOM(org.w3c.dom.Document aDocument)
throws java.io.IOException
aDocument - The document to store the bean into
public JOXBeanDOM(java.lang.String dtdURL)
throws java.io.IOException
dtdURL - The URL of the DTD
public JOXBeanDOM(com.wutka.dtd.DTD aDTD)
throws java.io.IOException
dtdURL - The URL of the DTD
public JOXBeanDOM(org.w3c.dom.Document aDocument,
java.lang.String dtdURL)
throws java.io.IOException
dtdURL - The URL of the DTDaDocument - The XML document the bean will be stored in
public JOXBeanDOM(org.w3c.dom.Document aDocument,
com.wutka.dtd.DTD aDTD)
dtdURL - The URL of the DTDaDocument - The XML document the bean will be stored in
public JOXBeanDOM(boolean writeAttributesFlag)
throws java.io.IOException
writeAttributesFlag - True if simple properties should be stored as attributes
public JOXBeanDOM(org.w3c.dom.Document aDocument,
boolean writeAttributesFlag)
throws java.io.IOException
aDocument - The XML document the bean will be stored inwriteAttributesFlag - True if simple properties should be stored as attributes| Method Detail |
protected void createDocument()
throws java.io.IOException
public org.w3c.dom.Document beanToDocument(java.lang.String rootName,
java.lang.Object ob)
throws java.io.IOException
rootName - The name of the document's root tagob - The bean to store in the document
public org.w3c.dom.Element storeObject(java.lang.String rootName,
java.lang.Object ob)
throws java.io.IOException
rootName - The name of the element's tagob - The bean to store in the element
public void storeObjectFields(java.lang.String xmlTagName,
java.lang.Object ob,
int writeType,
org.w3c.dom.Element parentElement)
throws java.io.IOException
xmlTagName - The XML tag name of the bean being writtenob - The bean whose properties will be writtenwriteType - The kind of fields being written (attribute or element)java.io.IOException - If there is an error writing the object
public void storeProperty(java.lang.String xmlTagName,
java.lang.Object ob,
java.beans.PropertyDescriptor prop,
int writeType,
org.w3c.dom.Element parentElement)
throws java.io.IOException
xmlTagName - The XML tag name of the bean being writtenob - The object containing the propertyprop - The property descriptor of the propertywriteType - Should we try to write this property
as an attribute? If not, don't write the object if
writeAttributes is true and this object can be written
as an attributejava.io.IOException - If there is an error writing out the property
public void storeIndexedProperty(java.lang.String xmlTagName,
java.lang.Object ob,
java.beans.IndexedPropertyDescriptor prop,
org.w3c.dom.Element parentElement)
throws java.io.IOException
xmlTagName - The XML tag name of the bean being writtenob - The object containing the propertyprop - The descriptor for the property
as an attribute? If not, don't write the object if
writeAttributes is true and this object can be written
as an attributejava.io.IOException - If there is an error writing the properties
public void storePropertyValue(java.lang.String xmlTagName,
java.lang.Object propValue,
java.beans.PropertyDescriptor prop,
int writeType,
org.w3c.dom.Element parentElement)
throws java.io.IOException
xmlTagName - The XML tag name of the bean being writtenpropValue - The value to writeprop - The property descriptor of the propertywriteType - Should we try to write this property
as an attribute? If not, don't write the object if
writeAttributes is true and this object can be written
as an attributejava.io.IOException - If there is an error while writing the property
public void storeBasicType(java.lang.String xmlTagName,
java.lang.String propName,
java.lang.Object propValue,
int writeType,
org.w3c.dom.Element parentElement)
throws java.io.IOException
xmlTagName - The XML tag name of the bean being writtenpropName - The name of the property to writepropValue - The value of the propertyjava.io.IOException - If there is an error while writing the property
public void storeString(java.lang.String xmlTagName,
java.lang.String propName,
java.lang.Object propValue,
int writeType,
org.w3c.dom.Element parentElement)
throws java.io.IOException
xmlTagName - The XML tag name of the bean being writtenpropName - The name of the property to writepropValue - The value of the propertyoutputStream - The output stream or writer where the value
is to be writtenjava.io.IOException - If there is an error while writing the property
public void storeDate(java.lang.String xmlTagName,
java.lang.String propName,
java.lang.Object propValue,
int writeType,
org.w3c.dom.Element parentElement)
throws java.io.IOException
xmlTagName - The XML tag name of the bean being writtenpropName - The name of the property to writepropValue - The value of the propertyoutputStream - The output stream or writer where the value
is to be writtenjava.io.IOException - If there is an error while writing the property
protected com.wutka.dtd.DTD readDTD(java.lang.String dtdURL)
throws java.io.IOException
public void writeObject(java.lang.String rootName,
java.lang.Object ob)
throws java.io.IOException
rootName - The tag name for this object (if this object is a
property of a bean, the tag name will be the property name)ob - The object to write outjava.io.IOException - If there is an error while writing the object
public void writeObjectFields(java.lang.String xmlTagName,
java.lang.Object ob,
int writeType)
throws java.io.IOException
xmlTagName - The XML tag name of the bean being writtenob - The bean whose properties will be writtenwriteType - The kind of fields being written (attribute or element)java.io.IOException - If there is an error writing the object
public void writeProperty(java.lang.String xmlTagName,
java.lang.Object ob,
java.beans.PropertyDescriptor prop,
int writeType)
throws java.io.IOException
xmlTagName - The XML tag name of the bean being writtenob - The object containing the propertyprop - The property descriptor of the propertywriteType - Should we try to write this property
as an attribute? If not, don't write the object if
writeAttributes is true and this object can be written
as an attributejava.io.IOException - If there is an error writing out the property
public void writeIndexedProperty(java.lang.String xmlTagName,
java.lang.Object ob,
java.beans.IndexedPropertyDescriptor prop)
throws java.io.IOException
xmlTagName - The XML tag name of the bean being writtenob - The object containing the propertyprop - The descriptor for the property
as an attribute? If not, don't write the object if
writeAttributes is true and this object can be written
as an attributejava.io.IOException - If there is an error writing the properties
public void writePropertyValue(java.lang.String xmlTagName,
java.lang.Object propValue,
java.beans.PropertyDescriptor prop,
int writeType)
throws java.io.IOException
xmlTagName - The XML tag name of the bean being writtenpropValue - The value to writeprop - The property descriptor of the propertywriteType - Should we try to write this property
as an attribute? If not, don't write the object if
writeAttributes is true and this object can be written
as an attributejava.io.IOException - If there is an error while writing the property
public void writeBasicType(java.lang.String xmlTagName,
java.lang.String propName,
java.lang.Object propValue,
int writeType)
throws java.io.IOException
xmlTagName - The XML tag name of the bean being writtenpropName - The name of the property to writepropValue - The value of the propertyjava.io.IOException - If there is an error while writing the property
public void writeString(java.lang.String xmlTagName,
java.lang.String propName,
java.lang.Object propValue,
int writeType)
throws java.io.IOException
xmlTagName - The XML tag name of the bean being writtenpropName - The name of the property to writepropValue - The value of the propertyoutputStream - The output stream or writer where the value
is to be writtenjava.io.IOException - If there is an error while writing the property
public void writeDate(java.lang.String xmlTagName,
java.lang.String propName,
java.lang.Object propValue,
int writeType)
throws java.io.IOException
xmlTagName - The XML tag name of the bean being writtenpropName - The name of the property to writepropValue - The value of the propertyoutputStream - The output stream or writer where the value
is to be writtenjava.io.IOException - If there is an error while writing the propertypublic java.lang.String stripName(java.lang.String name)
name - The name to stripprotected void setupNameTranslation()
public void expandChildElements(com.wutka.dtd.DTDContainer children,
java.util.Hashtable childTransTable)
public java.lang.String getTranslatedEntityName(java.lang.String name)
The - name to translate
public java.lang.String getTranslatedChildName(java.lang.String elementName,
java.lang.String childName)
public boolean writeAsAttribute(java.lang.String elementName,
java.lang.String attributeName)
elementName - The element whose tag is being writtenattributeName - The potential attribute name
|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||