INRIA & FluxMedia

fr.fluxmedia.transmorpher.TProcessFactory
Class BufferingHandler

java.lang.Object
  |
  +--fr.fluxmedia.transmorpher.TProcessFactory.BufferingHandler
All Implemented Interfaces:
org.xml.sax.ContentHandler, TmHandler
Direct Known Subclasses:
LoopHandler

class BufferingHandler
extends java.lang.Object
implements TmHandler

Concatenate homogeneous XML file. BufferingHandler does buffer all SAX events. once it is called with flushBuffer(ContentHandler) it will send all buffered events to the given handler MAIN CRITICISM: Why not using a dom tree! Since the system works assynchronously from the input, it is delicate to avoid deadlock (e.g., if a process has to output to a merge, it will not start until there is two consumer for the SAX events). To that extent, the class above make the first handler as Current and not the others. A current handler flushes the outpout to the output channel, a non current one put stacks it! Once a handler becomes Current (see IsFinished()) it starts by flushing its stack and then process normally. Of course, this should not be a stack...

Author:
laurent.tardif@inrialpes.fr, jerome.euzenat@inrialpes.fr
See Also:
"SAX 2.0 & JDK 1.3"

Field Summary
(package private)  boolean isCurrent
          true if the content handler is the current one
(package private)  boolean isDone
          true if the handler is finished
(package private)  Fifo iStack
          the stack of events info
(package private)  org.xml.sax.ContentHandler outputHandler
          The handler to which the output will be flushed
 
Constructor Summary
BufferingHandler()
          the constructor
BufferingHandler(org.xml.sax.ContentHandler h)
          the constructor.
 
Method Summary
 void add(ContentHandlerInfo p)
          Add an element in the stack
 void characters(char[] ch, int start, int length)
          The characters command
 void endDocument()
          The endDocument command
 void endElement(java.lang.String ns, java.lang.String localName, java.lang.String name)
          The endElement command
 void endPrefixMapping(java.lang.String prefix)
          The endPrefixMapping command
 void flushBuffer()
          Compute the stack of contentHandlerInfo
 void ignorableWhitespace(char[] ch, int start, int length)
          The ignorableWhitespace command
 boolean isCurrent()
          test if the mixer is the current mixer
 boolean isDone()
          Test if the handling is done
 ContentHandlerInfo pop()
          Remove the first element in the stack
 void processingInstruction(java.lang.String target, java.lang.String data)
          The processingInstruction command
 void setCurrent(boolean pCurrent)
          set the curent attribut
 void setDocumentLocator(org.xml.sax.Locator locator)
          The setDocumentLocator command
 void setDone(boolean pDone)
          Set the done attribute
 int size()
          return the size of the stack
 void skippedEntity(java.lang.String name)
          The skippedEntity command
 void startDocument()
          The startDocument command
 void startElement(java.lang.String ns, java.lang.String localName, java.lang.String name, org.xml.sax.Attributes atts)
          The startElement command
 void startPrefixMapping(java.lang.String prefix, java.lang.String uri)
          The startPrefixMapping command
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

iStack

Fifo iStack
the stack of events info

outputHandler

org.xml.sax.ContentHandler outputHandler
The handler to which the output will be flushed

isCurrent

boolean isCurrent
true if the content handler is the current one

isDone

boolean isDone
true if the handler is finished
Constructor Detail

BufferingHandler

public BufferingHandler()
the constructor

BufferingHandler

public BufferingHandler(org.xml.sax.ContentHandler h)
the constructor. Sets the output handler with h
Parameters:
h - the output handler
Method Detail

add

public final void add(ContentHandlerInfo p)
Add an element in the stack
Parameters:
p - The ContentHandlerInfo to add to the stack

pop

public final ContentHandlerInfo pop()
Remove the first element in the stack
Returns:
The ContentHandlerInfo at the top of the stack

size

public final int size()
return the size of the stack
Returns:
The size of the stack

startElement

public void startElement(java.lang.String ns,
                         java.lang.String localName,
                         java.lang.String name,
                         org.xml.sax.Attributes atts)
                  throws org.xml.sax.SAXException
The startElement command
Specified by:
startElement in interface org.xml.sax.ContentHandler
Parameters:
ns - The Namespace URI.
localName - The local name without prefix.
name - The local name with prefix.
atts - The attributes attached to the element.
Throws:
org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.

endElement

public void endElement(java.lang.String ns,
                       java.lang.String localName,
                       java.lang.String name)
                throws org.xml.sax.SAXException
The endElement command
Specified by:
endElement in interface org.xml.sax.ContentHandler
Parameters:
ns - The Namespace URI.
localName - The local name without prefix.
name - The local name with prefix.
Throws:
org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.

startDocument

public void startDocument()
                   throws org.xml.sax.SAXException
The startDocument command
Specified by:
startDocument in interface org.xml.sax.ContentHandler
Throws:
org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.

setDocumentLocator

public void setDocumentLocator(org.xml.sax.Locator locator)
The setDocumentLocator command
Specified by:
setDocumentLocator in interface org.xml.sax.ContentHandler
Parameters:
locator - - An object that can return the location of any SAX document event.

endDocument

public void endDocument()
                 throws org.xml.sax.SAXException
The endDocument command
Specified by:
endDocument in interface org.xml.sax.ContentHandler
Throws:
org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.

skippedEntity

public void skippedEntity(java.lang.String name)
                   throws org.xml.sax.SAXException
The skippedEntity command
Specified by:
skippedEntity in interface org.xml.sax.ContentHandler
Parameters:
name - The name of the skipped entity. If it is a parameter entity, the name will begin with '%', and if it is the external DTD subset, it will be the string "[dtd]".
Throws:
org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.

processingInstruction

public void processingInstruction(java.lang.String target,
                                  java.lang.String data)
                           throws org.xml.sax.SAXException
The processingInstruction command
Specified by:
processingInstruction in interface org.xml.sax.ContentHandler
Parameters:
target - The processing instruction target.
data - The processing instruction data, or null if none was supplied. The data does not include any whitespace separating it from the target.
Throws:
org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.

ignorableWhitespace

public void ignorableWhitespace(char[] ch,
                                int start,
                                int length)
                         throws org.xml.sax.SAXException
The ignorableWhitespace command
Specified by:
ignorableWhitespace in interface org.xml.sax.ContentHandler
Parameters:
ch - The characters from the XML document.
start - The start position in the array.
length - The number of characters to read from the array.
Throws:
org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.

characters

public void characters(char[] ch,
                       int start,
                       int length)
                throws org.xml.sax.SAXException
The characters command
Specified by:
characters in interface org.xml.sax.ContentHandler
Parameters:
ch - The characters from the XML document.
start - The start position in the array.
length - The number of characters to read from the array.
Throws:
org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.

startPrefixMapping

public void startPrefixMapping(java.lang.String prefix,
                               java.lang.String uri)
                        throws org.xml.sax.SAXException
The startPrefixMapping command
Specified by:
startPrefixMapping in interface org.xml.sax.ContentHandler
Parameters:
prefix - The prefix that was being mapping.
uri - The Namespace URI the prefix is mapped to.
Throws:
org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.

endPrefixMapping

public void endPrefixMapping(java.lang.String prefix)
                      throws org.xml.sax.SAXException
The endPrefixMapping command
Specified by:
endPrefixMapping in interface org.xml.sax.ContentHandler
Parameters:
prefix - The prefix that was being mapping.
Throws:
org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.

setDone

public void setDone(boolean pDone)
Set the done attribute
Parameters:
pDone - The new done value

isDone

public final boolean isDone()
Test if the handling is done
Returns:
The done value

isCurrent

public final boolean isCurrent()
test if the mixer is the current mixer
Specified by:
isCurrent in interface TmHandler
Returns:
The current value

setCurrent

public final void setCurrent(boolean pCurrent)
set the curent attribut
Specified by:
setCurrent in interface TmHandler
Parameters:
pCurrent - The new current value

flushBuffer

public void flushBuffer()
                 throws org.xml.sax.SAXException
Compute the stack of contentHandlerInfo
Throws:
org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.

INRIA & FluxMedia

..no bottom yet...