public abstract class

AbstractHandler

extends DefaultHandler
java.lang.Object
   ↳ org.xml.sax.helpers.DefaultHandler
     ↳ com.microstrategy.utils.xml.AbstractHandler
Known Direct Subclasses

Class Overview

A base class for content handlers

Summary

Fields
protected StringBuffer buf This field is deprecated. use getText() to acquire String of internal buffer
protected int depth The element depth count.
protected SAXSupport parser A reference to the SAX parser to which the handler is attached
Protected Constructors
AbstractHandler()
Default constructor.
AbstractHandler(SAXSupport pParser)
Initializes the handler and attaches it to the parser.
Public Methods
void characters(char[] ch, int start, int length)
void clearText()
void endDocument()
This is a safegurd against forgetting to pop out inner handlers.
void endElement(String uri, String local, String qName)
The default implementation that calls doEndElement then reduces the depth count.
int getIntValue()
String getText()
void startElement(String uri, String local, String qName, Attributes attrs)
The default implementation that simply increases the depth count.
Protected Methods
abstract void doEndElement(String uri, String local, String qName)
Override this method insted of endElement to process end element event.
void doStartElement(String uri, String local, String qName, AttributesXt attrsXt)
void doStartElement(String uri, String local, String qName, Attributes attrs)
Override this method insted of startElement to process start element event.
void popContentHandler(String uri, String local, String qName)
void setLogErrors(boolean value)
[Expand]
Inherited Methods
From class org.xml.sax.helpers.DefaultHandler
From class java.lang.Object
From interface org.xml.sax.ContentHandler
From interface org.xml.sax.DTDHandler
From interface org.xml.sax.EntityResolver
From interface org.xml.sax.ErrorHandler

Fields

protected StringBuffer buf

This field is deprecated.
use getText() to acquire String of internal buffer

A buffer to accumulate element text.

protected int depth

The element depth count. It is relative to the handler's root element, an element at which this handler was attached to the parser. Whenever a handler receives the startElement event it increases this counter. Whenever the handler receives the endElement event it decreases the counter. When the counter becomes zero the handler pops itself from the handler stack. Real handler shall use this variable to optimize content handlers. They shall first check the depth and then check for tag names that are expected at this depth.

protected SAXSupport parser

A reference to the SAX parser to which the handler is attached

Protected Constructors

protected AbstractHandler ()

Default constructor.

protected AbstractHandler (SAXSupport pParser)

Initializes the handler and attaches it to the parser.

Parameters
pParser - a SAX parser to which this handler needs to be attached

Public Methods

public void characters (char[] ch, int start, int length)

Parameters
ch The characters.
start The start position in the character array.
length The number of characters to use from the character array.
Throws
SAXException Any SAX exception, possibly wrapping another exception.

public void clearText ()

public void endDocument ()

This is a safegurd against forgetting to pop out inner handlers. It throws an exception when end document event happens for inner handlers.

Throws
IllegalStateException when called for inner handler
SAXException Any SAX exception, possibly wrapping another exception.
See Also

public void endElement (String uri, String local, String qName)

The default implementation that calls doEndElement then reduces the depth count. If this is an event for the handler's root element (depth count goes to zero), then the handlers is detached from (popped out of) the parser.

Override the doEndElement method insted of this one to process end element event. This way you will not have problems with depth counter while subclassing your event handlers.

When overriding this method always call super at the end of your code.

Parameters
uri The Namespace URI, or the empty string if the element has no Namespace URI or if Namespace processing is not being performed.
local The local name (without prefix), or the empty string if Namespace processing is not being performed.
qName The qualified name (with prefix), or the empty string if qualified names are not available.
Throws
SAXException Any SAX exception, possibly wrapping another exception

public int getIntValue ()

public String getText ()

public void startElement (String uri, String local, String qName, Attributes attrs)

The default implementation that simply increases the depth count. and then calls doStartElement method. Override the doStartElement method insted of this one to process start element event. This way you will not have problems with depth counter while subclassing your event handlers.

When overriding this method you shall either call supper or simply start your code with depth++; statement (which is faster).

Parameters
uri The Namespace URI, or the empty string if the element has no Namespace URI or if Namespace processing is not being performed.
local The local name (without prefix), or the empty string if Namespace processing is not being performed.
qName The qualified name (with prefix), or the empty string if qualified names are not available.
attrs The attributes attached to the element. If there are no attributes, it shall be an empty Attributes object
Throws
SAXException Any SAX exception, possibly wrapping another exception

Protected Methods

protected abstract void doEndElement (String uri, String local, String qName)

Override this method insted of endElement to process end element event. This way you will not have problems with depth counter while subclassing your event handlers.

Throws
SAXException Any SAX exception, possibly wrapping another exception
Exception

protected void doStartElement (String uri, String local, String qName, AttributesXt attrsXt)

Throws
Exception

protected void doStartElement (String uri, String local, String qName, Attributes attrs)

Override this method insted of startElement to process start element event. This way you will not have problems with depth counter while subclassing your event handlers.

Throws
SAXException Any SAX exception, possibly wrapping another exception
Exception

protected void popContentHandler (String uri, String local, String qName)

Throws
SAXException

protected void setLogErrors (boolean value)