org.jagatoo.util.xml
Class SimpleXMLHandlerDelegate

java.lang.Object
  extended by org.jagatoo.util.xml.SimpleXMLHandlerDelegate
Direct Known Subclasses:
SimpleXMLHandler

public abstract class SimpleXMLHandlerDelegate
extends java.lang.Object

This class easily handles XML parsing.

Author:
Marvin Froehlich (aka Qudus)

Nested Class Summary
static class SimpleXMLHandlerDelegate.ExceptionSeverity
           
 
Constructor Summary
SimpleXMLHandlerDelegate()
           
 
Method Summary
protected  void delegate(SimpleXMLHandlerDelegate delegate)
          Start a delegate handler.
 XMLHandlerAdapter getAdapter()
           
protected  java.lang.Object getPathObject(XMLPath path, java.lang.String element)
          Converts the passed element to a path element.
abstract  void handleForkElement(java.lang.String name, java.lang.Object object, org.xml.sax.Attributes attributes)
          Invoked first when this object is used to start a fork.
protected abstract  void onElementData(XMLPath path, org.xml.sax.Attributes attributes, char[] data, int start, int length)
          Invoked when an XML element's character data is available.
protected abstract  void onElementEnded(XMLPath path, java.lang.String name, java.lang.Object object)
          Invoked when an XML element end has been detected.
protected abstract  void onElementStarted(XMLPath path, java.lang.String name, java.lang.Object object, org.xml.sax.Attributes attributes)
          Invoked when an XML element has been detected.
protected  void onParsingException(XMLPath path, SimpleXMLHandlerDelegate.ExceptionSeverity severity, org.xml.sax.SAXParseException ex)
          Invoked when a parsing exception occurred.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleXMLHandlerDelegate

public SimpleXMLHandlerDelegate()
Method Detail

getAdapter

public final XMLHandlerAdapter getAdapter()

delegate

protected final void delegate(SimpleXMLHandlerDelegate delegate)
                       throws org.xml.sax.SAXException
Start a delegate handler.

Parameters:
delegate -
Throws:
org.xml.sax.SAXException

handleForkElement

public abstract void handleForkElement(java.lang.String name,
                                       java.lang.Object object,
                                       org.xml.sax.Attributes attributes)
                                throws org.xml.sax.SAXException
Invoked first when this object is used to start a fork.

Parameters:
name -
object -
attributes -
Throws:
org.xml.sax.SAXException

getPathObject

protected java.lang.Object getPathObject(XMLPath path,
                                         java.lang.String element)
Converts the passed element to a path element. By default the passed element is returned.

Parameters:
path - then current XML element path
element - the element's name
Returns:
the converted path element.

onElementStarted

protected abstract void onElementStarted(XMLPath path,
                                         java.lang.String name,
                                         java.lang.Object object,
                                         org.xml.sax.Attributes attributes)
                                  throws org.xml.sax.SAXException
Invoked when an XML element has been detected.

Parameters:
path - then current XML element path
name - the element's name
object - the path object
attributes - the attributes
Throws:
org.xml.sax.SAXException

onElementData

protected abstract void onElementData(XMLPath path,
                                      org.xml.sax.Attributes attributes,
                                      char[] data,
                                      int start,
                                      int length)
                               throws org.xml.sax.SAXException
Invoked when an XML element's character data is available.

Parameters:
path - then current XML element path
attributes - the attributes
data - the characters
start - the start position in the character array
length - the number of characters to use from the character array
Throws:
org.xml.sax.SAXException

onElementEnded

protected abstract void onElementEnded(XMLPath path,
                                       java.lang.String name,
                                       java.lang.Object object)
                                throws org.xml.sax.SAXException
Invoked when an XML element end has been detected.

Parameters:
path - then current XML element path
name - the element's name
object - the path object
Throws:
org.xml.sax.SAXException

onParsingException

protected void onParsingException(XMLPath path,
                                  SimpleXMLHandlerDelegate.ExceptionSeverity severity,
                                  org.xml.sax.SAXParseException ex)
                           throws org.xml.sax.SAXException
Invoked when a parsing exception occurred.

Parameters:
path - then current XML element path
severity - the exception severity
ex - the exception
Throws:
org.xml.sax.SAXException