|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectorg.bifrost.xmlio.XmlReader
public class XmlReader
Read data from an XML file into a graph of objects. One or more objects get created as a result of parsing an XML file.
Created: Feb 22, 2003
Copyright: Copyright (c) 2003
Assumptions: none
Requires: ReaderContentHandler, XmlException
Required by: nothing
Revision History:
2003-04-21 Changed to use JAXP instead of Xerces.
2004-04-14 Support for a configuration object
Example:
XmlReader reader = new XmlReader("filename.xml", "base.pkg.of.classes");
SalesLot rootObject = (SalesLot)reader.getRootObject();
Could read a structure like this (where SalesLot is the root Java object
and the root XML element):
<SalesLot>
<Car>
<make>Saab</make>
<model>93</model>
<year>2001</year>
</Car>
<Car>
<make>Saab</make>
<model>95</model>
<year>2002</year>
</Car>
</SalesLot>
The SalesLot object would implement a method called addCar(Car newCar)
which would add each of the Car elements to a Collection.
Car would implement setMake(String theMake), setModel(String theModel)
and setYear(String theYear).
| Field Summary | |
|---|---|
static java.lang.String |
EX_FILE
Exception error messages |
static java.lang.String |
EX_NULL_READER
|
static java.lang.String |
EX_PARSING
|
static java.lang.String |
EX_URL
|
| Constructor Summary | |
|---|---|
XmlReader(java.io.InputStream reader,
java.lang.String targetPackage)
Constructor. |
|
XmlReader(java.lang.String fileName,
java.lang.String targetPackage)
Constructor. |
|
XmlReader(java.net.URL url,
java.lang.String targetPackage)
Constructor. |
|
| Method Summary | |
|---|---|
org.bifrost.xmlio.config.XmlIOConfig |
getConfig()
Get the configuration object |
java.lang.Object |
getRootObject()
Returns the root object derived from the xml. |
void |
setConfig(org.bifrost.xmlio.config.XmlIOConfig config)
Set the configuration object |
| 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_FILE
public static final java.lang.String EX_URL
public static final java.lang.String EX_PARSING
public static final java.lang.String EX_NULL_READER
| Constructor Detail |
|---|
public XmlReader(java.lang.String fileName,
java.lang.String targetPackage)
throws XmlException
fileName - The path and filename of the xml filetargetPackage - The package where the classes representing the xml
are located
XmlException - when a file or parsing error occurs
public XmlReader(java.net.URL url,
java.lang.String targetPackage)
throws XmlException
url - The url for the xml filetargetPackage - The package where the classes representing the xml
are located
XmlException - when a file or parsing error occurs
public XmlReader(java.io.InputStream reader,
java.lang.String targetPackage)
throws XmlException
reader - The input reader for the xml filetargetPackage - The package where the classes representing the xml
are located
XmlException - when a file or parsing error occurs| Method Detail |
|---|
public org.bifrost.xmlio.config.XmlIOConfig getConfig()
public void setConfig(org.bifrost.xmlio.config.XmlIOConfig config)
config - the configuration objectpublic java.lang.Object getRootObject()
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||