org.jagatoo.util.xml
Class SimpleXMLParser

java.lang.Object
  extended by org.jagatoo.util.xml.SimpleXMLParser

public class SimpleXMLParser
extends java.lang.Object

This class invokes simple XML parsing.

This not only provides full XML path information at every state of the parsing process, but also gives you the opportunity to fork the entity handling and delegate it to another handler. The fork is automatically undone when the root of the fork is detected.

An example:
Implement SimpleXMLHandlerFork and call the instance f.
Implement SimpleXMLHandler and call the instance h.
Invoke the parser and pass it h.
In the h implementation you would then detect a certain element start and invoke the handler's fork() method and pass f.
All the elements inside of this element are now handled by f which doesn't need to know anything about the parent elements and even gets an XMLPath, that roots to the forking element.

Author:
Marvin Froehlich (aka Qudus)

Constructor Summary
SimpleXMLParser()
           
 
Method Summary
static void parseXML(java.io.File file, java.nio.charset.Charset charset, SimpleXMLHandler handler)
          Parses the given file.
static void parseXML(java.io.File file, SimpleXMLHandler handler)
          Parses the given file.
static void parseXML(java.io.File file, java.lang.String charset, SimpleXMLHandler handler)
          Parses the given file.
static void parseXML(java.io.InputStream in, java.nio.charset.Charset charset, SimpleXMLHandler handler)
          Parses the given file.
static void parseXML(java.io.InputStream in, SimpleXMLHandler handler)
          Parses the given file.
static void parseXML(java.io.InputStream in, java.lang.String charset, SimpleXMLHandler handler)
          Parses the given file.
static void parseXML(java.lang.String filename, java.nio.charset.Charset charset, SimpleXMLHandler handler)
          Parses the given file.
static void parseXML(java.lang.String filename, SimpleXMLHandler handler)
          Parses the given file.
static void parseXML(java.lang.String filename, java.lang.String charset, SimpleXMLHandler handler)
          Parses the given file.
static void parseXML(java.net.URL url, java.nio.charset.Charset charset, SimpleXMLHandler handler)
          Parses the given file.
static void parseXML(java.net.URL url, SimpleXMLHandler handler)
          Parses the given file.
static void parseXML(java.net.URL url, java.lang.String charset, SimpleXMLHandler handler)
          Parses the given file.
protected static void parseXMLImpl(java.io.InputStream in, java.lang.String codepage, java.nio.charset.Charset charset, SimpleXMLHandler handler)
          Parses the given file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleXMLParser

public SimpleXMLParser()
Method Detail

parseXMLImpl

protected static void parseXMLImpl(java.io.InputStream in,
                                   java.lang.String codepage,
                                   java.nio.charset.Charset charset,
                                   SimpleXMLHandler handler)
                            throws java.io.IOException,
                                   javax.xml.parsers.ParserConfigurationException,
                                   org.xml.sax.SAXException
Parses the given file.
This method implements the actual parsing code.

Parameters:
in -
codepage -
charset -
handler -
Throws:
java.io.IOException
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException

parseXML

public static final void parseXML(java.io.InputStream in,
                                  java.lang.String charset,
                                  SimpleXMLHandler handler)
                           throws java.io.IOException,
                                  javax.xml.parsers.ParserConfigurationException,
                                  org.xml.sax.SAXException
Parses the given file.

Parameters:
in -
charset -
handler -
Throws:
java.io.IOException
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException

parseXML

public static final void parseXML(java.io.InputStream in,
                                  java.nio.charset.Charset charset,
                                  SimpleXMLHandler handler)
                           throws java.io.IOException,
                                  javax.xml.parsers.ParserConfigurationException,
                                  org.xml.sax.SAXException
Parses the given file.

Parameters:
in -
charset -
handler -
Throws:
java.io.IOException
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException

parseXML

public static final void parseXML(java.io.InputStream in,
                                  SimpleXMLHandler handler)
                           throws java.io.IOException,
                                  javax.xml.parsers.ParserConfigurationException,
                                  org.xml.sax.SAXException
Parses the given file.

Parameters:
in -
handler -
Throws:
java.io.IOException
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException

parseXML

public static final void parseXML(java.net.URL url,
                                  java.lang.String charset,
                                  SimpleXMLHandler handler)
                           throws java.io.IOException,
                                  javax.xml.parsers.ParserConfigurationException,
                                  org.xml.sax.SAXException
Parses the given file.

Parameters:
url -
charset -
handler -
Throws:
java.io.IOException
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException

parseXML

public static final void parseXML(java.net.URL url,
                                  java.nio.charset.Charset charset,
                                  SimpleXMLHandler handler)
                           throws java.io.IOException,
                                  javax.xml.parsers.ParserConfigurationException,
                                  org.xml.sax.SAXException
Parses the given file.

Parameters:
url -
charset -
handler -
Throws:
java.io.IOException
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException

parseXML

public static final void parseXML(java.net.URL url,
                                  SimpleXMLHandler handler)
                           throws java.io.IOException,
                                  javax.xml.parsers.ParserConfigurationException,
                                  org.xml.sax.SAXException
Parses the given file.

Parameters:
url -
handler -
Throws:
java.io.IOException
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException

parseXML

public static final void parseXML(java.io.File file,
                                  java.lang.String charset,
                                  SimpleXMLHandler handler)
                           throws java.io.IOException,
                                  javax.xml.parsers.ParserConfigurationException,
                                  org.xml.sax.SAXException
Parses the given file.

Parameters:
file -
charset -
handler -
Throws:
java.io.IOException
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException

parseXML

public static final void parseXML(java.io.File file,
                                  java.nio.charset.Charset charset,
                                  SimpleXMLHandler handler)
                           throws java.io.IOException,
                                  javax.xml.parsers.ParserConfigurationException,
                                  org.xml.sax.SAXException
Parses the given file.

Parameters:
file -
charset -
handler -
Throws:
java.io.IOException
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException

parseXML

public static final void parseXML(java.io.File file,
                                  SimpleXMLHandler handler)
                           throws java.io.IOException,
                                  javax.xml.parsers.ParserConfigurationException,
                                  org.xml.sax.SAXException
Parses the given file.

Parameters:
file -
handler -
Throws:
java.io.IOException
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException

parseXML

public static final void parseXML(java.lang.String filename,
                                  java.lang.String charset,
                                  SimpleXMLHandler handler)
                           throws java.io.IOException,
                                  javax.xml.parsers.ParserConfigurationException,
                                  org.xml.sax.SAXException
Parses the given file.

Parameters:
filename -
charset -
handler -
Throws:
java.io.IOException
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException

parseXML

public static final void parseXML(java.lang.String filename,
                                  java.nio.charset.Charset charset,
                                  SimpleXMLHandler handler)
                           throws java.io.IOException,
                                  javax.xml.parsers.ParserConfigurationException,
                                  org.xml.sax.SAXException
Parses the given file.

Parameters:
filename -
charset -
handler -
Throws:
java.io.IOException
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException

parseXML

public static final void parseXML(java.lang.String filename,
                                  SimpleXMLHandler handler)
                           throws java.io.IOException,
                                  javax.xml.parsers.ParserConfigurationException,
                                  org.xml.sax.SAXException
Parses the given file.

Parameters:
filename -
handler -
Throws:
java.io.IOException
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException