com.perdues
Class XP
java.lang.Object
|
+--com.perdues.XP
- public class XP
- extends java.lang.Object
XML subset parser. The primary entry points are the load()
and loadResource() methods.
Constructor Summary |
XP(java.io.Reader reader)
Constructs an XP parser from the given reader. |
Method Summary |
XP.Expectation |
expectation(java.lang.String msg)
|
static XMLTag[] |
load(java.io.File file)
This method loads XML from the given file, returning an
array of XMLTag objects representing the top-level XML tags
in the file. |
static XMLTag[] |
load(java.io.Reader reader)
This method loads XML from the given Reader, returning an
array of XMLTag objects representing the top-level XML tags
in the input. |
static XMLTag[] |
loadResource(java.lang.String resourceName)
Loads an XML file or archive member given a "system resource"
name referring to a file or archive member of some
element of CLASSPATH. |
static void |
main(java.lang.String[] args)
|
XMLTag[] |
parse()
Parses the text from this XP's input, returning an
array of XMLTag objects representing the top-level XML
tags in the document. |
XMLTag |
parseTag()
Parse an XML tag and return a XMLTag object representing it. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
XP
public XP(java.io.Reader reader)
- Constructs an XP parser from the given reader. This
in all cases reads to end of file, but does not parse
the input.
loadResource
public static XMLTag[] loadResource(java.lang.String resourceName)
throws java.io.IOException
- Loads an XML file or archive member given a "system resource"
name referring to a file or archive member of some
element of CLASSPATH. A "system resource name" is a path relative
to some element of CLASSPATH, with elements of the path
separated by "/". This returns an array of XMLTag objects
representing the top-level XML tags in the document.
Referring to configuration files using system resource
names can be handy for distribution of default or pre-built
configurations, because the config file can be distributed
with Java classes, and setting up the CLASSPATH automatically
configures the path to the config file. A pre-built config file
can even be distributed as part of a JAR.
load
public static XMLTag[] load(java.io.File file)
throws java.io.FileNotFoundException,
java.io.IOException
- This method loads XML from the given file, returning an
array of XMLTag objects representing the top-level XML tags
in the file.
load
public static XMLTag[] load(java.io.Reader reader)
throws java.io.IOException
- This method loads XML from the given Reader, returning an
array of XMLTag objects representing the top-level XML tags
in the input. This will read to end of file, but you must
close the reader yourself.
parse
public XMLTag[] parse()
throws java.io.IOException
- Parses the text from this XP's input, returning an
array of XMLTag objects representing the top-level XML
tags in the document.
parseTag
public XMLTag parseTag()
- Parse an XML tag and return a XMLTag object representing it.
This does not parse any content for nonempty tags, nor any
tags that might be contained between this and a matching end
tag. This does not read past the end of the first tag in
the remaining input.
expectation
public XP.Expectation expectation(java.lang.String msg)
main
public static void main(java.lang.String[] args)