|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object tribble.xml.schema.XmlData
Methods to convert a Java class to an XML data document.
Example
Consider the following class:
public class CustOrder { public String m_custName = "Acme Rockets & Fun, Inc."; public int m_p_o_number = 100627; public int m_cost = 14995; public String m_address = "1450 Desert Plain"; public Integer m_count = new Integer(10); private int m_refId = 7528; transient int m_addln = 149; public Address m_addr = new Address("123 Anywhere St", "Boston", "MA", "02134"); public static class Address { public String m_street; public String m_city; public String m_state; public String m_zip; ... } }
This class object would be written as the following XML document:
<CustOrder> <custName>Acme Rockets & Fun, Inc.</custName> <p-o-number>100627</p-o-number> <cost>14995</cost> <address>1450 Desert Plain</address> <count>10</count> <addr> <street>123 Anywhere St</street> <city>Boston</city> <state>MA</state> <zip>02134</zip> </addr> </CustOrder>
Method Summary | |
static void |
main(java.lang.String[] args)
Test driver for this class. |
static void |
writeObjectXml(java.lang.Object obj,
java.io.OutputStream out)
Write the contents of an object as an XML data document. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public static void main(java.lang.String[] args) throws java.lang.Exception
Usage
java tribble.xml.schema.XmlData [-o out.xml] pkg.class
Loads the class named pkg.class (which should be located somewhere in the CLASSPATH), then creates a new object instance of that type, then writes its contents as an XML data document to the file out.xml, or to the standard output if no output file is specified.
args
- Command line arguments.
java.lang.Exception
- Thrown if an I/O (write) error occurs,
or if class pkg.class could not be loaded,
or if an object of that type could not be instantiated.public static void writeObjectXml(java.lang.Object obj, java.io.OutputStream out) throws java.io.IOException, java.lang.IllegalAccessException
See the example above for more details.
obj
- Object to write.out
- Output stream to write the XML document to.
If this is null, no action is performed.
For efficiency, it is recommended that this object be a type derived from
java.io.PrintStream.
java.io.IOException
- Thrown if an I/O (write) error occurs.
java.lang.IllegalArgumentException
- (unchecked)
Thrown if obj cannot be written as XML.
java.lang.IllegalAccessException
- Thrown if obj or one of its members cannot be accessed.
java.lang.NullPointerException
- (unchecked)
Thrown if obj is null.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |