sk.uniba.euromath.tools.xml.sax
Class SaxEventRecorder

java.lang.Object
  extended by sk.uniba.euromath.tools.xml.sax.SaxEventRecorder
All Implemented Interfaces:
ContentHandler

public final class SaxEventRecorder
extends Object
implements ContentHandler

Each event invoked on this handler gets transferred to the underlying content handler and recorded. These events can be then replayed to any chosen ContentHandler.

Author:
Martin Vysny

Constructor Summary
SaxEventRecorder(boolean suppressDocEvents)
          Constructor.
SaxEventRecorder(ContentHandler sink, boolean suppressDocEvents)
          Constructor.
 
Method Summary
 void characters(char[] ch, int start, int length)
           
 void endDocument()
           
 void endElement(String uri, String localName, String qName)
           
 void endPrefixMapping(String prefix)
           
 void ignorableWhitespace(char[] ch, int start, int length)
           
 boolean isFinished()
          Checks if content handler finished recording events.
 void processingInstruction(String target, String data)
           
 void replayEvents(ContentHandler handler)
          Replays recorded events on given handler.
 void reset()
          Resets the recorded history - clears all recorded events.
 void setDocumentLocator(Locator locator)
           
 void setHandler(ContentHandler handler)
          Sets the underlying handler that receives the events.
 void skippedEntity(String name)
           
 void startDocument()
           
 void startElement(String uri, String localName, String qName, Attributes atts)
           
 void startPrefixMapping(String prefix, String uri)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SaxEventRecorder

public SaxEventRecorder(boolean suppressDocEvents)
Constructor.

Parameters:
suppressDocEvents - if true then startDocument() / endDocument() are not given to sink nor replayed.

SaxEventRecorder

public SaxEventRecorder(ContentHandler sink,
                        boolean suppressDocEvents)
Constructor.

Parameters:
sink - initialize handler to this instance.
suppressDocEvents - if true then startDocument() / endDocument() are not given to sink nor replayed.
Method Detail

reset

public void reset()
Resets the recorded history - clears all recorded events.


setHandler

public void setHandler(ContentHandler handler)
Sets the underlying handler that receives the events.

Parameters:
handler - handler that receives the events.

replayEvents

public void replayEvents(ContentHandler handler)
                  throws SAXException
Replays recorded events on given handler.

Parameters:
handler - the handler.
Throws:
SAXException - if event processing fails.

isFinished

public boolean isFinished()
Checks if content handler finished recording events.

Returns:
true if endDocument() was called.

setDocumentLocator

public void setDocumentLocator(Locator locator)
Specified by:
setDocumentLocator in interface ContentHandler

startDocument

public void startDocument()
                   throws SAXException
Specified by:
startDocument in interface ContentHandler
Throws:
SAXException

endDocument

public void endDocument()
                 throws SAXException
Specified by:
endDocument in interface ContentHandler
Throws:
SAXException

startPrefixMapping

public void startPrefixMapping(String prefix,
                               String uri)
                        throws SAXException
Specified by:
startPrefixMapping in interface ContentHandler
Throws:
SAXException

endPrefixMapping

public void endPrefixMapping(String prefix)
                      throws SAXException
Specified by:
endPrefixMapping in interface ContentHandler
Throws:
SAXException

startElement

public void startElement(String uri,
                         String localName,
                         String qName,
                         Attributes atts)
                  throws SAXException
Specified by:
startElement in interface ContentHandler
Throws:
SAXException

endElement

public void endElement(String uri,
                       String localName,
                       String qName)
                throws SAXException
Specified by:
endElement in interface ContentHandler
Throws:
SAXException

characters

public void characters(char[] ch,
                       int start,
                       int length)
                throws SAXException
Specified by:
characters in interface ContentHandler
Throws:
SAXException

ignorableWhitespace

public void ignorableWhitespace(char[] ch,
                                int start,
                                int length)
                         throws SAXException
Specified by:
ignorableWhitespace in interface ContentHandler
Throws:
SAXException

processingInstruction

public void processingInstruction(String target,
                                  String data)
                           throws SAXException
Specified by:
processingInstruction in interface ContentHandler
Throws:
SAXException

skippedEntity

public void skippedEntity(String name)
                   throws SAXException
Specified by:
skippedEntity in interface ContentHandler
Throws:
SAXException


Copyright 2003-2003-2006 null. All Rights Reserved.