|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectorg.bifrost.xmlio.XmlWriter
public class XmlWriter
Serialize an xml representation of a graph of objects into a writer.
Created: Feb 24, 2003
Copyright: Copyright (c) 2003
Assumptions: none
Requires: nothing
Required by: nothing
Revision History:
Example:
Config config = new Config();
config.setNumber(123);
config.setString("acb");
XmlWriter writer = new XmlWriter("filename.xml");
writer.setRootObject(config);
Would produce an xml file that might look like:
<Config>
<number>123</number>
<string>abc</string>
</Config>
Conventions:
| Field Summary | |
|---|---|
static java.lang.String |
EX_CLOSE
Exception when there is a problem flushing or closing the writer. |
static java.lang.String |
EX_FILE
Exception when there is an error creating an output file. |
static java.lang.String |
EX_NULL_ATTRIBUTE
Exception when an attribute is null. |
static java.lang.String |
EX_NULL_OBJECT
Exception when a null object is encountered. |
static java.lang.String |
EX_NULL_WRITER
Exception when a writer is null. |
static java.lang.String |
EX_OBJECT_GRAPH
Exception when there is an error calling a getter. |
static java.lang.String |
EX_PRIMATIVE
Exception when a primative object is found in a List or Set. |
static java.lang.String |
EX_WRITING
Exception when there is an error writing to the Writer. |
| Constructor Summary | |
|---|---|
XmlWriter(java.lang.String filename)
Constructor which creates a FileWriter from the supplied filename. |
|
XmlWriter(java.io.Writer writer)
Constructor which initializes the XmlWriter with the supplied writer object. |
|
| Method Summary | |
|---|---|
boolean |
getBeautify()
Gets the flag which controls 'beautifying' the output. |
java.lang.String |
getBreakString()
Gets the string which will be used to break each element/attribute line of the resulting xml if beatifying is true. |
org.bifrost.xmlio.config.XmlIOConfig |
getConfig()
|
boolean |
getDashedNames()
|
boolean |
getIncludePackageName()
Get the flag indicating whether the fully qualified classname should be output as an element or just the classname (without the package). |
java.lang.String |
getIndentString()
Gets the string which will be used to indent each element/attribute of the resulting xml if beatifying is true. |
boolean |
getOutputNulls()
|
void |
setBeautify(boolean beautify)
Sets the flag to control 'beautifying' the output. |
void |
setBreakString(java.lang.String breakString)
Sets the string which will be used to break each element/attribute line of the resulting xml if beatifying is true. |
void |
setConfig(org.bifrost.xmlio.config.XmlIOConfig config)
|
void |
setDashedNames(boolean dashedNames)
|
void |
setIncludePackageName(boolean includePackageName)
Set the flag indicating whether the fully qualified classname should be output as an element or just the classname (without the package). |
void |
setIndentString(java.lang.String indentString)
Sets the string which will be used to indent each element/attribute of the resulting xml if beatifying is true. |
void |
setOutputNulls(boolean outputNulls)
|
void |
setRootObject(java.lang.Object rootObject)
Sets the root object to be serialized out and initiates the process of writing xml out to the writer. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String EX_NULL_OBJECT
public static final java.lang.String EX_PRIMATIVE
public static final java.lang.String EX_WRITING
public static final java.lang.String EX_OBJECT_GRAPH
public static final java.lang.String EX_NULL_ATTRIBUTE
public static final java.lang.String EX_FILE
public static final java.lang.String EX_CLOSE
public static final java.lang.String EX_NULL_WRITER
| Constructor Detail |
|---|
public XmlWriter(java.io.Writer writer)
throws XmlException
writer - the writer to output to.
XmlException - if there was a problem
public XmlWriter(java.lang.String filename)
throws XmlException
filename - the name of the file to write to
XmlException - if there was a problem| Method Detail |
|---|
public boolean getBeautify()
public java.lang.String getBreakString()
public java.lang.String getIndentString()
public boolean getIncludePackageName()
public void setBeautify(boolean beautify)
beautify - the flag controlling whether or not output should be 'beautified'public void setBreakString(java.lang.String breakString)
breakString - the string which will be used to break each element/attribute linepublic void setIndentString(java.lang.String indentString)
indentString - the string which will be used to indent each element/attributepublic void setIncludePackageName(boolean includePackageName)
rootObject -
XmlException
public void setRootObject(java.lang.Object rootObject)
throws XmlException
rootObject - the root object of the graph that will be serialized to xml
XmlException - if there was a problempublic org.bifrost.xmlio.config.XmlIOConfig getConfig()
public void setConfig(org.bifrost.xmlio.config.XmlIOConfig config)
config - The new configuration.public boolean getOutputNulls()
public void setOutputNulls(boolean outputNulls)
public boolean getDashedNames()
public void setDashedNames(boolean dashedNames)
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||