vooga.engine.util
Class XMLFileParser

java.lang.Object
  extended by vooga.engine.util.XMLFileParser
All Implemented Interfaces:
XMLDocumentCreator

public class XMLFileParser
extends java.lang.Object
implements XMLDocumentCreator

Creates a Document directly from an XML file. Elements within the XML file are represented by nodes in a tree data structure. All elements in the XML document will be loaded into working memory so consider file size when using this parser. Generally, this will be the XML parser used by VOOGA. Can be initialized without a file, but then the file must be set before attempting to parse anything. Generally it is safer to initialize with a file. Example code for parsing a Document using a file path:

XMLDocumentCreator xmlCreator = new XMLFileParser(defaultPath + resourcesXMLFilepath);
 Document doc = xmlCreator.getDocument();
 


Constructor Summary
XMLFileParser()
          Create without reference to a file.
XMLFileParser(java.io.File xmlFile)
          Create with a reference to a file to be parsed
XMLFileParser(java.lang.String xmlFileLocation)
          Create with a reference to a file to be parsed
 
Method Summary
 org.w3c.dom.Document getDocument()
          Produce a Document from some XML source
 void setParseFile(java.io.File xmlFile)
          Set reference to file to be parsed
 void setParseFile(java.lang.String xmlFileLocation)
          Set reference to file to be parsed
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLFileParser

public XMLFileParser()
Create without reference to a file. Must set a file before parsing using set methods.


XMLFileParser

public XMLFileParser(java.lang.String xmlFileLocation)
Create with a reference to a file to be parsed

Parameters:
xmlFileLocation - String representing the file path to XML file to be parsed

XMLFileParser

public XMLFileParser(java.io.File xmlFile)
Create with a reference to a file to be parsed

Parameters:
xmlFile - XML file to be parsed
Method Detail

setParseFile

public void setParseFile(java.lang.String xmlFileLocation)
Set reference to file to be parsed

Parameters:
xmlFileLocation - String representing the file path to XML file to be parsed

setParseFile

public void setParseFile(java.io.File xmlFile)
Set reference to file to be parsed

Parameters:
xmlFileLocation - XML file to be parsed

getDocument

public org.w3c.dom.Document getDocument()
                                 throws javax.xml.parsers.ParserConfigurationException,
                                        org.xml.sax.SAXException,
                                        java.io.IOException
Description copied from interface: XMLDocumentCreator
Produce a Document from some XML source

Specified by:
getDocument in interface XMLDocumentCreator
Returns:
Document representing XML source
Throws:
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException
java.io.IOException