unsw.cse.mica.util
Class StackableHandler

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by unsw.cse.mica.util.StackableHandler
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler
Direct Known Subclasses:
AgentXMLHandler, BlackboardXMLHandler, LocalTypeManagerXMLHandler, MobXMLHandler

public abstract class StackableHandler
extends org.xml.sax.helpers.DefaultHandler

A class providing support for XML handlers to be added and removed from a stack. This enables a handler to delegate parsing by placing a new handler above it on the stack, which allows re-using of handler components.

Author:
jhw

Constructor Summary
StackableHandler()
           
 
Method Summary
 void onPopped(StackableHandler handler, java.lang.Object obj)
          Notify this handler that the handler above this one on the stack has popped itself off the stack.
 void pop()
          Tell this handler to pop itself of the stack This method just calls pop(null)
 void pop(java.lang.Object msg)
          Pop this handler off the stack, passing the object msg to the next handler down.
 void push(StackableHandler handler)
          Push a child handler onto the stack associated with this handler
 void setStackHandler(StackHandler stack)
          Set the stack for this handler
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
characters, endDocument, endElement, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startElement, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StackableHandler

public StackableHandler()
Method Detail

setStackHandler

public void setStackHandler(StackHandler stack)
Set the stack for this handler

Parameters:
stack -

push

public void push(StackableHandler handler)
Push a child handler onto the stack associated with this handler

Parameters:
handler -

pop

public void pop()
         throws org.xml.sax.SAXException
Tell this handler to pop itself of the stack This method just calls pop(null)

Throws:
org.xml.sax.SAXException

pop

public void pop(java.lang.Object msg)
         throws org.xml.sax.SAXException
Pop this handler off the stack, passing the object msg to the next handler down. Includes a null check to allow standalone use outside of a StackHandler, which is useful for debugging.

Parameters:
msg - the message to be passed from this handler to the one below.
Throws:
org.xml.sax.SAXException

onPopped

public void onPopped(StackableHandler handler,
                     java.lang.Object obj)
              throws org.xml.sax.SAXException
Notify this handler that the handler above this one on the stack has popped itself off the stack. The default implementation does nothing, but child classes may wish to override this method to obtain information from the child handler once it has finished parsing.

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