nbi.xmlsec.biocase.protocol.filter
Class ContentObjectFilter

java.lang.Object
  extended byorg.xml.sax.helpers.XMLFilterImpl
      extended bynbi.xmlsec.biocase.protocol.filter.ProtocolFilter
          extended bynbi.xmlsec.biocase.protocol.filter.ContentObjectFilter
All Implemented Interfaces:
ContentHandler, DTDHandler, EntityResolver, ErrorHandler, XMLFilter, XMLReader

public class ContentObjectFilter
extends ProtocolFilter

This filter simply reads in all incoming SaxElements and stores them in an internal Buffer. The content of this internal Buffer may be retrieved using getContentObject(). The SaxElements are stored using the XMLWriterclass as content handler to write the SaxElements to the internal Buffer.

Since:
Version:
$Revision: 1.5 $
Author:
Lutz Suhrbier

Field Summary
private  ByteArrayOutputStream contentObjectOut
          The buffer to write the content object to.
private  nbi.xml.sax.XMLWriter contentObjectWriter
          The content handler to write the content to the internal buffer.
(package private) static Logger logger
           
private  ContentHandler origContentHandler
          Variable to store the original ContentHandler of this filter.
(package private) static int trackMode
          Track mode for the filter stack
 
Fields inherited from class nbi.xmlsec.biocase.protocol.filter.ProtocolFilter
elementStack, filterMode, FILTERMODE_FILTER, FILTERMODE_NONE, FILTERMODE_PARSER, filterRoot, PROT_URI_13, PROT_URI_20
 
Fields inherited from class org.xml.sax.helpers.XMLFilterImpl
 
Constructor Summary
ContentObjectFilter(String protocolURI, int filterMode)
          Inits the filter instance.
ContentObjectFilter(XMLReader parent, String protocolURI, int filterMode)
          Inits the filter instance with specified parent.
 
Method Summary
 byte[] getContentObject()
          Retrieves the content object from the internal buffer.
private  void initBuffer()
           
private  void initSubFilter()
          Registers subfilters for subelements.
protected  nbi.xml.sax.SAXElement parseComplete(nbi.xml.sax.SAXElement element)
          Reactivates the orignal ContenHandler deactivated to read the content object into the buffer in parseInit(SAXElement).
protected  nbi.xml.sax.SAXElement parseInit(nbi.xml.sax.SAXElement element)
          Sets the protocolURI of the filter to the URI of the document to parse and activates the contentObjectWriter as ContenHandler to read the content object into the buffer.
 
Methods inherited from class nbi.xmlsec.biocase.protocol.filter.ProtocolFilter
characters, checkFilterParameter, endElement, filterCharacters, filterElement, getFilterMode, getFilterParameter, getProtocolURI, isParsingComplete, parseElement, registerSubFilter, setFilterParameter, setProtocolURI, startElement, unregisterSubFilter
 
Methods inherited from class org.xml.sax.helpers.XMLFilterImpl
endDocument, endPrefixMapping, error, fatalError, getContentHandler, getDTDHandler, getEntityResolver, getErrorHandler, getFeature, getParent, getProperty, ignorableWhitespace, notationDecl, parse, parse, processingInstruction, resolveEntity, setContentHandler, setDocumentLocator, setDTDHandler, setEntityResolver, setErrorHandler, setFeature, setParent, setProperty, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

static Logger logger

trackMode

static final int trackMode
Track mode for the filter stack

See Also:
Constant Field Values

contentObjectOut

private ByteArrayOutputStream contentObjectOut
The buffer to write the content object to.


contentObjectWriter

private nbi.xml.sax.XMLWriter contentObjectWriter
The content handler to write the content to the internal buffer.


origContentHandler

private ContentHandler origContentHandler
Variable to store the original ContentHandler of this filter.

Constructor Detail

ContentObjectFilter

public ContentObjectFilter(String protocolURI,
                           int filterMode)
Inits the filter instance.

Parameters:
protocolURI - protocol version URI of this filter.
filterMode - filterMode of this filter ProtocolFilter.filterMode.

ContentObjectFilter

public ContentObjectFilter(XMLReader parent,
                           String protocolURI,
                           int filterMode)
Inits the filter instance with specified parent.

Parameters:
parent - parent reader.
protocolURI - protocol version URI of this filter.
filterMode - filterMode of this filter ProtocolFilter.filterMode.
Method Detail

initSubFilter

private void initSubFilter()
Registers subfilters for subelements.


initBuffer

private void initBuffer()

parseInit

protected nbi.xml.sax.SAXElement parseInit(nbi.xml.sax.SAXElement element)
                                    throws SAXException
Sets the protocolURI of the filter to the URI of the document to parse and activates the contentObjectWriter as ContenHandler to read the content object into the buffer.

Overrides:
parseInit in class ProtocolFilter
Parameters:
element - The element of the startElement event (contains no value).
Returns:
The (modified) element or null when the event shall be removed.
Throws:
SAXException - If any parsing error occurs.
See Also:
ProtocolFilter.parseInit(SAXElement)

parseComplete

protected nbi.xml.sax.SAXElement parseComplete(nbi.xml.sax.SAXElement element)
                                        throws SAXException
Reactivates the orignal ContenHandler deactivated to read the content object into the buffer in parseInit(SAXElement).

Overrides:
parseComplete in class ProtocolFilter
Parameters:
element - The complete root element (including the value).
Returns:
The (modified) element or null when element shall be removed.
Throws:
SAXException - If any parsing error occurs.
See Also:
ProtocolFilter.parseComplete(SAXElement)

getContentObject

public byte[] getContentObject()
Retrieves the content object from the internal buffer.

Returns:
The content object from the internal buffer.


Copyright © 2006 Lutz Suhrbier, Freie Universität Berlin. All Rights Reserved.