org.inria.ns.reflex.xml.sax
Class SAXBuffer

java.lang.Object
  extended by org.xml.sax.helpers.XMLFilterImpl
      extended by org.inria.ns.reflex.xml.sax.SAXFilter
          extended by org.inria.ns.reflex.xml.sax.SAXBuffer
All Implemented Interfaces:
Localizable, Pluggable, ContentHandler, DTDHandler, EntityResolver, ErrorHandler, DeclHandler, LexicalHandler, XMLFilter, XMLReader

public class SAXBuffer
extends SAXFilter
implements Pluggable

A SAXBuffer bufferize all its input events until it is connected to an output handler.

Once connected, its bufferized events must be fired to the target handler.

This is not a synchronized buffer : it can't receive more events while flushing its buffer.

Author:
Philippe Poulard

Constructor Summary
SAXBuffer(ParserConfiguration parserConfiguration)
          Create a filter.
 
Method Summary
 void attributeDecl(String eName, String aName, String type, String valueDefault, String value)
          Bufferize this event or fire it if the buffer has been flushed.
 void characters(char[] ch, int start, int length)
          Bufferize this event or fire it if the buffer has been flushed.
 void comment(char[] ch, int start, int length)
          Bufferize this event or fire it if the buffer has been flushed.
 void connected()
          When this buffer receives this notification, it flushes its buffer.
 void elementDecl(String name, String model)
          Bufferize this event or fire it if the buffer has been flushed.
 void endCDATA()
          Bufferize this event or fire it if the buffer has been flushed.
 void endDocument()
          Bufferize this event or fire it if the buffer has been flushed.
 void endDTD()
          Bufferize this event or fire it if the buffer has been flushed.
 void endElement(String uri, String localName, String qName)
          Bufferize this event or fire it if the buffer has been flushed.
 void endEntity(String name)
          Bufferize this event or fire it if the buffer has been flushed.
 void endPrefixMapping(String prefix)
          Bufferize this event or fire it if the buffer has been flushed.
 void externalEntityDecl(String name, String publicId, String systemId)
          Bufferize this event or fire it if the buffer has been flushed.
 void flushEvents()
          Flush all bufferized events, causing firing several SAX events.
 void ignorableWhitespace(char[] ch, int start, int length)
          Bufferize this event or fire it if the buffer has been flushed.
 void internalEntityDecl(String name, String value)
          Bufferize this event or fire it if the buffer has been flushed.
 boolean isBuffering()
          Indicates whether this filter is currently buffering events or not.
 void notationDecl(String name, String publicId, String systemId)
          Bufferize this event or fire it if the buffer has been flushed.
 void processingInstruction(String target, String data)
          Bufferize this event or fire it if the buffer has been flushed.
 void skippedEntity(String name)
          Bufferize this event or fire it if the buffer has been flushed.
 void startCDATA()
          Bufferize this event or fire it if the buffer has been flushed.
 void startDocument()
          Bufferize this event or fire it if the buffer has been flushed.
 void startDTD(String name, String publicId, String systemId)
          Bufferize this event or fire it if the buffer has been flushed.
 void startElement(String uri, String localName, String qName, Attributes atts)
          Bufferize this event or fire it if the buffer has been flushed.
 void startEntity(String name)
          Bufferize this event or fire it if the buffer has been flushed.
 void startPrefixMapping(String prefix, String uri)
          Bufferize this event or fire it if the buffer has been flushed.
 void unparsedEntityDecl(String name, String publicId, String systemId, String notationName)
          Bufferize this event or fire it if the buffer has been flushed.
 
Methods inherited from class org.inria.ns.reflex.xml.sax.SAXFilter
getDeclHandler, getLexicalHandler, getLocation, getProperty, isLocalizable, parse, setDeclHandler, setLexicalHandler, setLocation, setProperty
 
Methods inherited from class org.xml.sax.helpers.XMLFilterImpl
error, fatalError, getContentHandler, getDTDHandler, getEntityResolver, getErrorHandler, getFeature, getParent, parse, resolveEntity, setContentHandler, setDocumentLocator, setDTDHandler, setEntityResolver, setErrorHandler, setFeature, setParent, warning
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.xml.sax.ContentHandler
setDocumentLocator
 

Constructor Detail

SAXBuffer

public SAXBuffer(ParserConfiguration parserConfiguration)
Create a filter.

Parameters:
configuration - The non-null configuration expected for the parser, if one is needed.
See Also:
ContentHandler, DTDHandler, LexicalHandler, DeclHandler
Method Detail

flushEvents

public void flushEvents()
Flush all bufferized events, causing firing several SAX events.


isBuffering

public boolean isBuffering()
Indicates whether this filter is currently buffering events or not.

Returns:
true if the events received are buffered, false if this filter has flushed them.

connected

public void connected()
When this buffer receives this notification, it flushes its buffer.

Specified by:
connected in interface Pluggable
See Also:
flushEvents(), Pluggable.connected()

attributeDecl

public void attributeDecl(String eName,
                          String aName,
                          String type,
                          String valueDefault,
                          String value)
                   throws SAXException
Bufferize this event or fire it if the buffer has been flushed.

Specified by:
attributeDecl in interface DeclHandler
Overrides:
attributeDecl in class SAXFilter
Throws:
SAXException
See Also:
DeclHandler.attributeDecl(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)

comment

public void comment(char[] ch,
                    int start,
                    int length)
             throws SAXException
Bufferize this event or fire it if the buffer has been flushed.

Specified by:
comment in interface LexicalHandler
Overrides:
comment in class SAXFilter
Throws:
SAXException
See Also:
LexicalHandler.comment(char[], int, int)

elementDecl

public void elementDecl(String name,
                        String model)
                 throws SAXException
Bufferize this event or fire it if the buffer has been flushed.

Specified by:
elementDecl in interface DeclHandler
Overrides:
elementDecl in class SAXFilter
Throws:
SAXException
See Also:
DeclHandler.elementDecl(java.lang.String, java.lang.String)

endCDATA

public void endCDATA()
              throws SAXException
Bufferize this event or fire it if the buffer has been flushed.

Specified by:
endCDATA in interface LexicalHandler
Overrides:
endCDATA in class SAXFilter
Throws:
SAXException
See Also:
LexicalHandler.endCDATA()

endDTD

public void endDTD()
            throws SAXException
Bufferize this event or fire it if the buffer has been flushed.

Specified by:
endDTD in interface LexicalHandler
Overrides:
endDTD in class SAXFilter
Throws:
SAXException
See Also:
LexicalHandler.endDTD()

endEntity

public void endEntity(String name)
               throws SAXException
Bufferize this event or fire it if the buffer has been flushed.

Specified by:
endEntity in interface LexicalHandler
Overrides:
endEntity in class SAXFilter
Throws:
SAXException
See Also:
LexicalHandler.endEntity(java.lang.String)

externalEntityDecl

public void externalEntityDecl(String name,
                               String publicId,
                               String systemId)
                        throws SAXException
Bufferize this event or fire it if the buffer has been flushed.

Specified by:
externalEntityDecl in interface DeclHandler
Overrides:
externalEntityDecl in class SAXFilter
Throws:
SAXException
See Also:
DeclHandler.externalEntityDecl(java.lang.String, java.lang.String, java.lang.String)

internalEntityDecl

public void internalEntityDecl(String name,
                               String value)
                        throws SAXException
Bufferize this event or fire it if the buffer has been flushed.

Specified by:
internalEntityDecl in interface DeclHandler
Overrides:
internalEntityDecl in class SAXFilter
Throws:
SAXException
See Also:
DeclHandler.internalEntityDecl(java.lang.String, java.lang.String)

startCDATA

public void startCDATA()
                throws SAXException
Bufferize this event or fire it if the buffer has been flushed.

Specified by:
startCDATA in interface LexicalHandler
Overrides:
startCDATA in class SAXFilter
Throws:
SAXException
See Also:
LexicalHandler.startCDATA()

startDTD

public void startDTD(String name,
                     String publicId,
                     String systemId)
              throws SAXException
Bufferize this event or fire it if the buffer has been flushed.

Specified by:
startDTD in interface LexicalHandler
Overrides:
startDTD in class SAXFilter
Throws:
SAXException
See Also:
LexicalHandler.startDTD(java.lang.String, java.lang.String, java.lang.String)

startEntity

public void startEntity(String name)
                 throws SAXException
Bufferize this event or fire it if the buffer has been flushed.

Specified by:
startEntity in interface LexicalHandler
Overrides:
startEntity in class SAXFilter
Throws:
SAXException
See Also:
LexicalHandler.startEntity(java.lang.String)

characters

public void characters(char[] ch,
                       int start,
                       int length)
                throws SAXException
Bufferize this event or fire it if the buffer has been flushed.

Specified by:
characters in interface ContentHandler
Overrides:
characters in class XMLFilterImpl
Throws:
SAXException

endDocument

public void endDocument()
                 throws SAXException
Bufferize this event or fire it if the buffer has been flushed.

Specified by:
endDocument in interface ContentHandler
Overrides:
endDocument in class SAXFilter
Throws:
SAXException - The client may throw an exception during processing.
See Also:
ContentHandler.endDocument()

endElement

public void endElement(String uri,
                       String localName,
                       String qName)
                throws SAXException
Bufferize this event or fire it if the buffer has been flushed.

Specified by:
endElement in interface ContentHandler
Overrides:
endElement in class XMLFilterImpl
Throws:
SAXException

endPrefixMapping

public void endPrefixMapping(String prefix)
                      throws SAXException
Bufferize this event or fire it if the buffer has been flushed.

Specified by:
endPrefixMapping in interface ContentHandler
Overrides:
endPrefixMapping in class XMLFilterImpl
Throws:
SAXException

ignorableWhitespace

public void ignorableWhitespace(char[] ch,
                                int start,
                                int length)
                         throws SAXException
Bufferize this event or fire it if the buffer has been flushed.

Specified by:
ignorableWhitespace in interface ContentHandler
Overrides:
ignorableWhitespace in class XMLFilterImpl
Throws:
SAXException

notationDecl

public void notationDecl(String name,
                         String publicId,
                         String systemId)
                  throws SAXException
Bufferize this event or fire it if the buffer has been flushed.

Specified by:
notationDecl in interface DTDHandler
Overrides:
notationDecl in class XMLFilterImpl
Throws:
SAXException

processingInstruction

public void processingInstruction(String target,
                                  String data)
                           throws SAXException
Bufferize this event or fire it if the buffer has been flushed.

Specified by:
processingInstruction in interface ContentHandler
Overrides:
processingInstruction in class XMLFilterImpl
Throws:
SAXException

skippedEntity

public void skippedEntity(String name)
                   throws SAXException
Bufferize this event or fire it if the buffer has been flushed.

Specified by:
skippedEntity in interface ContentHandler
Overrides:
skippedEntity in class XMLFilterImpl
Throws:
SAXException

startDocument

public void startDocument()
                   throws SAXException
Bufferize this event or fire it if the buffer has been flushed.

Specified by:
startDocument in interface ContentHandler
Overrides:
startDocument in class SAXFilter
Throws:
SAXException - The client may throw an exception during processing.
See Also:
ContentHandler.startDocument()

startElement

public void startElement(String uri,
                         String localName,
                         String qName,
                         Attributes atts)
                  throws SAXException
Bufferize this event or fire it if the buffer has been flushed.

Specified by:
startElement in interface ContentHandler
Overrides:
startElement in class XMLFilterImpl
Throws:
SAXException

startPrefixMapping

public void startPrefixMapping(String prefix,
                               String uri)
                        throws SAXException
Bufferize this event or fire it if the buffer has been flushed.

Specified by:
startPrefixMapping in interface ContentHandler
Overrides:
startPrefixMapping in class XMLFilterImpl
Throws:
SAXException

unparsedEntityDecl

public void unparsedEntityDecl(String name,
                               String publicId,
                               String systemId,
                               String notationName)
                        throws SAXException
Bufferize this event or fire it if the buffer has been flushed.

Specified by:
unparsedEntityDecl in interface DTDHandler
Overrides:
unparsedEntityDecl in class XMLFilterImpl
Throws:
SAXException