|
xml2class XML data structures |
|||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||
java.lang.Object | +--xml2class.XML2ClassParser
The XML2ClassParser extracts data about a present data
structure (i.e. it must already be implemented) out of XML code
and instantiates a new instance of it with the values
available from an XML source. To be precise: it is just a tool which
should help to program clear and easy maintainable structures, as it won't
do all the work for you.
Simply speaking is all you need a data structure and an XML file
describing it. Now you create a new XML2ClassParser and parse
the file through a FileReader (or any other Reader
. You'll get then the data structure's root element back (as you
indicated it), with which you can proceed as usual.
In general, it will be more comfortable to use XMLFile for
parsing (and saving). XML2ClassParser just allows you to
control the process somewhat better (input not from a file, output not to
System.out, using different root elements).
For a more accurate description of its functioning and its limits, please have a look at the xml2class Introduction.
Beware: this parser is no XML validator. Not well-formed or invalid XML may be accepted without error messages. Well-formed and valid XML however may help by omitting future trouble.
XMLFile,
X2cTools,
X2cException,
GNU General Public License| Constructor Summary | |
XML2ClassParser()
Creates a new XML2ClassParser.
|
|
XML2ClassParser(java.lang.String classPaths)
Creates a new XML2ClassParser for the given classpath(s). |
|
XML2ClassParser(java.lang.String[] classPaths)
Creates a new XML2ClassParser for the given classpath(s). |
|
| Method Summary | |
java.lang.Object |
parse(java.io.Reader reader)
Parses a data structure by extracting data from the Reader, beginning with the first instance of the first element, which is found. |
java.lang.Object |
parse(java.io.Reader reader,
java.lang.String elementName)
Parses a data structure by extracting data from the Reader, beginning with the first instance of the indicated element which is found. The reader should be buffered (it must support mark/reset). |
static void |
printPackageInfo(java.io.PrintWriter out)
Writes the package's version and copyleft to a PrintWriter. |
void |
setVerbose(java.io.PrintWriter verbose)
Sets the parser's verbose output destination (null = not verbose). |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public XML2ClassParser()
XML2ClassParser.
Beware: Any classpath information will have to be included in the element tags!public XML2ClassParser(java.lang.String classPaths)
XML2ClassParser for the given classpath(s).classPaths - Where any indicated class will be searched (separated by whitespace).public XML2ClassParser(java.lang.String[] classPaths)
XML2ClassParser for the given classpath(s).classPaths - Where any indicated class will be searched.| Method Detail |
public java.lang.Object parse(java.io.Reader reader)
throws X2cException
Parses a data structure by extracting data from the
Reader, beginning with the first instance of the first element,
which is found. The reader should be buffered (it must support
mark/reset).
reader - Where the data should come from (usually an XML file).X2cException - Any exception will be led into a X2cException (or a class extending it).
public java.lang.Object parse(java.io.Reader reader,
java.lang.String elementName)
throws X2cException
Parses a data structure by extracting data from the Reader, beginning with the first instance of the indicated element which is found.
The reader should be buffered (it must support
mark/reset). In order to get several second (or higher)
level elements, you'll have to reuse the same reader.
reader - Where the data should come from (usually an XML file).elementName - The name of the element / class, which you want to start parsing with.X2cException - Any exception will be led into a X2cException (or a class extending it).public void setVerbose(java.io.PrintWriter verbose)
verbose - Where verbose output will be written to, if null, there won't be any.public static void printPackageInfo(java.io.PrintWriter out)
out - Where the package info should be written to.
|
xml2class XML data structures |
|||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||