|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectmoos.ssds.model.XmlBuilder
Generate XML from the model
Use As: // Get an instance XmlBuilder xb = new XmlBuilder(); // Add the elements that are to appear just below the root of the XML doc. // Here we just add an instance of deployment xb.addDeployments(aDeployment) // Transform the object graph to xml xb.marshal() xb.print() // view it in a console. xb.print(anOutputStream) // write it to an OutputStream xb.toFile(aFile) // Write out to a file.
XmlBuilder uses reflection for marshalling XML from objects.
Changes to the model can be handled without requring changes to this class.
However, sometimes the result is undesirable, so some modifications may be
required.
The Monterey Bay Aquarium Research Institute (MBARI) provides this documentation and code "as is", with no warranty, express or implied, of its quality or consistency. It is provided without support and without obligation on the part of MBARI to assist in its use, correction, modification, or enhancement. This information should not be published or distributed to third parties without specific written permission from MBARI.
| Constructor Summary | |
XmlBuilder()
|
|
| Method Summary | |
void |
add(java.lang.Object obj)
|
void |
addAll(java.util.Collection c)
|
void |
addDataProducer(DataProducer dataProducer)
|
void |
addDeployment(Deployment deployment)
|
void |
addDevice(Device device)
|
void |
addHumanIntervention(HumanIntervention humanIntervention)
|
void |
addProcessRun(ProcessRun processRun)
|
void |
build()
Deprecated. use marshall instead |
nu.xom.Document |
getDocument()
|
java.util.Collection |
getRootElements()
|
void |
marshal()
Generates XML tree. |
void |
print()
Print the XMl document to System.out |
void |
print(java.io.OutputStream out)
|
void |
print(java.io.OutputStream out,
java.lang.String encoding)
Write the formated xml out to a stream |
void |
remove(java.lang.Object obj)
|
void |
removeAll(java.util.Collection c)
|
void |
removeDataProducer(DataProducer dataProducer)
|
void |
removeDeployment(Deployment deployment)
|
void |
removeDevice(Device device)
|
void |
removeHumanIntervention(HumanIntervention humanIntervention)
|
void |
removeProcessRun(ProcessRun processRun)
|
void |
toFile(java.io.File file)
Write formated xml to a file using "ISO-8859-1" encoding |
void |
toFile(java.io.File file,
java.lang.String encoding)
Write formated xml to a file using the specified encoding |
java.lang.String |
toFormattedXML()
|
java.lang.String |
toString()
|
java.lang.String |
toXML()
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public XmlBuilder()
| Method Detail |
public void build()
public void marshal()
XmlBuilder xb = new XmlBuilder(); xb.addDeployment(aDeployment); xb.marshal(); // Generate the xml tree xb.print(); // do something with the xml tree. Here we dump it to stdout
public java.lang.String toXML()
public java.lang.String toFormattedXML()
throws java.io.IOException,
java.io.UnsupportedEncodingException
java.io.IOException
java.io.UnsupportedEncodingExceptionpublic java.lang.String toString()
public nu.xom.Document getDocument()
public void toFile(java.io.File file)
throws java.io.IOException,
java.io.UnsupportedEncodingException
file - The file to write into.
java.io.IOException
java.io.UnsupportedEncodingException
public void toFile(java.io.File file,
java.lang.String encoding)
throws java.io.IOException,
java.io.UnsupportedEncodingException
file - The file to write into.encoding - the encodinb to use
java.io.IOException
java.io.UnsupportedEncodingException
public void print(java.io.OutputStream out,
java.lang.String encoding)
throws java.io.IOException,
java.io.UnsupportedEncodingException
out - An outstream to write toencoding - the encodinb to use
java.io.IOException
java.io.UnsupportedEncodingException
public void print(java.io.OutputStream out)
throws java.io.IOException,
java.io.UnsupportedEncodingException
java.io.IOException
java.io.UnsupportedEncodingException
public void print()
throws java.io.IOException,
java.io.UnsupportedEncodingException
java.io.IOException
java.io.UnsupportedEncodingExceptionpublic void addDevice(Device device)
public void addDeployment(Deployment deployment)
public void addDataProducer(DataProducer dataProducer)
public void addHumanIntervention(HumanIntervention humanIntervention)
public void addProcessRun(ProcessRun processRun)
public void removeDevice(Device device)
public void removeDeployment(Deployment deployment)
public void removeDataProducer(DataProducer dataProducer)
public void removeHumanIntervention(HumanIntervention humanIntervention)
public void removeProcessRun(ProcessRun processRun)
public void add(java.lang.Object obj)
public void remove(java.lang.Object obj)
public void addAll(java.util.Collection c)
public void removeAll(java.util.Collection c)
public java.util.Collection getRootElements()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||