|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object wyvern.kernel.properties.XMLWrapper
This class hides some of the sordid details of the underlying XML parser. A client of this class still needs to be aware of the standard XML DOM API, so that it can traverse the parse tree. However, this class shields them from having to know how the individual parser implementation handles streams, files, etc.
The primary reason for having this class is that we don't want to store an absolute path or URL to the map.dtd and arch.dtd files used to validate the archetype & map xml files. The dtd files are relative to the game installation tree, so we need to insert the appropriate XML entity reference at the head of the input stream for each archetype & mapfile before handing them over to the parser.
Method Summary | |
static java.lang.String |
constructXMLDoc(java.lang.String dtdPath,
java.lang.String data)
Constructs an XML document on the fly, given the path to the DTD and the XML data for the document. |
static java.lang.String |
encodeXMLStream(java.lang.String input)
Escapes any latin-1 characters or Unicode characters. |
static org.w3c.dom.Node |
getCDATASectionNode(org.w3c.dom.Node node)
Goes through the children of the passed node until it finds a CDATASection node, and returns it. |
static org.w3c.dom.Element |
getFirstChildElement(org.w3c.dom.Node node)
Removes and returns the first child element of this node, if any. |
static java.util.LinkedList |
getTextFromNode(org.w3c.dom.Node node)
Returns a list of lines of text contained by this Node. |
static org.w3c.dom.Element |
getXMLBeanDocumentRoot(java.lang.Object obj,
org.w3c.dom.Node bean)
High-level utility method for SelfExternalizable beans. |
static void |
main(java.lang.String[] args)
Tests the class. |
static org.w3c.dom.Document |
parseArchetypeFile(java.lang.String archfile)
Parses a Wyvern archetype file into a DOM tree. |
static org.w3c.dom.Document |
parseCustomXMLDocument(java.lang.String input)
Utility function to parse an XML document in a string. |
static org.w3c.dom.Document |
parseMapFile(java.lang.String mapfile)
Parses a Wyvern map file into a DOM tree. |
static org.w3c.dom.Document |
parseXMLNoValidation(java.lang.String input)
Parses some XML with no DTD. |
static org.w3c.dom.Document |
parseXMLString(java.lang.String input)
Parses an XML definition using the game's "arch.dtd". |
static java.lang.String |
print(org.w3c.dom.Node node)
Prints the specified node, recursively. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public static org.w3c.dom.Document parseCustomXMLDocument(java.lang.String input) throws java.lang.Exception
input
- an XML document to parse
java.lang.Exception
public static org.w3c.dom.Document parseXMLString(java.lang.String input) throws java.lang.Exception
input
- the input string
java.lang.Exception
public static org.w3c.dom.Document parseArchetypeFile(java.lang.String archfile) throws java.lang.Exception
archfile
- - the absolute path to the archetype to parse.
java.lang.Exception
public static org.w3c.dom.Document parseMapFile(java.lang.String mapfile) throws java.lang.Exception
mapfile
- - the full path to the map file to parse
java.lang.Exception
public static org.w3c.dom.Element getFirstChildElement(org.w3c.dom.Node node)
node
- the DOM Node to check for element children
public static org.w3c.dom.Node getCDATASectionNode(org.w3c.dom.Node node)
public static java.util.LinkedList getTextFromNode(org.w3c.dom.Node node)
node
- a DOM Node to grab the text from
public static java.lang.String print(org.w3c.dom.Node node)
public static java.lang.String constructXMLDoc(java.lang.String dtdPath, java.lang.String data)
dtdPath
- the location of the DTD file within the
Wyvern directory structure (an absolute path that should
be constructed by calling wyvern.common.config.Wyvern to
get the absolute part of the path).data
- the XML datapublic static org.w3c.dom.Document parseXMLNoValidation(java.lang.String input) throws java.lang.Exception
input
- the input XML snippet
java.lang.Exception
public static org.w3c.dom.Element getXMLBeanDocumentRoot(java.lang.Object obj, org.w3c.dom.Node bean) throws java.lang.Exception
bean
- an XML node for a SelfExternalizable beanobj
- the Bean object, for error-reporting purposes
java.lang.Exception
public static java.lang.String encodeXMLStream(java.lang.String input)
public static void main(java.lang.String[] args)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |