tomp.xtcl.filter
Class XTFilterImpl

java.lang.Object
  extended bytomp.xtcl.filter.XTFilterImpl
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler, org.xml.sax.ext.LexicalHandler, Parametrized, org.xml.sax.XMLFilter, org.xml.sax.XMLReader, XTFilter
Direct Known Subclasses:
AnswerFilter, CSSPIAdder, DerivationFilter, DynamicFilterImpl, DynamicMultiFilterImpl, FilteringSAXFilter, IDAttributeAdder, PokusXTFilter, QAAppender, QALinkAppender, QuestionFilter, TeeFilterImpl, TypeDetectorFilter, XIncludeFilter, XSLTFilter

public class XTFilterImpl
extends java.lang.Object
implements XTFilter


Field Summary
protected  org.xml.sax.ContentHandler contentHandler
           
protected  org.xml.sax.DTDHandler dtdHandler
           
protected  org.xml.sax.EntityResolver entityResolver
           
protected  org.xml.sax.ErrorHandler errorHandler
           
protected  org.xml.sax.ext.LexicalHandler lexicalHandler
           
protected  org.xml.sax.Locator locator
           
protected  org.xml.sax.XMLReader parent
           
 
Constructor Summary
XTFilterImpl()
          Construct an empty XML filter, with no parent.
XTFilterImpl(org.xml.sax.XMLReader parent)
          Construct an XML filter with the specified parent.
 
Method Summary
 void comment(char[] ch, int start, int length)
          Callback interface for SAX (part of LexicalHandler interface): not for application use
 void endCDATA()
           
 void endDocument()
          Filter an end document event.
 void endDTD()
          Register the end of the DTD.
 void endElement(java.lang.String uri, java.lang.String localName, java.lang.String qName)
          Filter an end element event.
 void endEntity(java.lang.String name)
           
 void endPrefixMapping(java.lang.String prefix)
          Filter an end Namespace prefix mapping event.
 void error(org.xml.sax.SAXParseException e)
          Filter an error event.
 void fatalError(org.xml.sax.SAXParseException e)
          Filter a fatal error event.
 org.xml.sax.ContentHandler getContentHandler()
          Get the content event handler.
 org.xml.sax.DTDHandler getDTDHandler()
          Get the current DTD event handler.
 org.xml.sax.EntityResolver getEntityResolver()
          Get the current entity resolver.
 org.xml.sax.ErrorHandler getErrorHandler()
          Get the current error event handler.
 boolean getFeature(java.lang.String name)
          Look up the value of a feature.
 org.xml.sax.ext.LexicalHandler getLexicalHandler()
          Get the lexical event handler.
 org.xml.sax.XMLReader getParent()
          Get the parent reader.
 java.lang.Object getProperty(java.lang.String name)
          Look up the value of a property.
 void characters(char[] ch, int start, int length)
          Filter a character data event.
 void ignorableWhitespace(char[] ch, int start, int length)
          Filter an ignorable whitespace event.
 void notationDecl(java.lang.String name, java.lang.String publicId, java.lang.String systemId)
          Filter a notation declaration event.
 void parse(org.xml.sax.InputSource input)
          Parse a document.
 void parse(java.lang.String systemId)
          Parse a document.
 void processingInstruction(java.lang.String target, java.lang.String data)
          Filter a processing instruction event.
 org.xml.sax.InputSource resolveEntity(java.lang.String publicId, java.lang.String systemId)
          Filter an external entity resolution.
 void setContentHandler(org.xml.sax.ContentHandler handler)
          Set the content event handler.
 void setDocumentLocator(org.xml.sax.Locator locator)
          Filter a new document locator event.
 void setDTDHandler(org.xml.sax.DTDHandler handler)
          Set the DTD event handler.
 void setEntityResolver(org.xml.sax.EntityResolver resolver)
          Set the entity resolver.
 void setErrorHandler(org.xml.sax.ErrorHandler handler)
          Set the error event handler.
 void setFeature(java.lang.String name, boolean value)
          Set the value of a feature.
 void setLexicalHandler(org.xml.sax.ext.LexicalHandler handler)
          Set the lexical event handler.
 void setParameter(java.lang.String k, java.lang.Object v)
           
 void setParent(org.xml.sax.XMLReader parent)
          Set the parent reader.
 void setProperty(java.lang.String name, java.lang.Object value)
          Set the value of a property.
protected  void setupParse()
          Set up before a parse.
 void skippedEntity(java.lang.String name)
          Filter a skipped entity event.
 void startCDATA()
           
 void startDocument()
          Filter a start document event.
 void startDTD(java.lang.String name, java.lang.String publicId, java.lang.String systemId)
          Register the start of the DTD.
 void startElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes atts)
          Filter a start element event.
 void startEntity(java.lang.String name)
           
 void startPrefixMapping(java.lang.String prefix, java.lang.String uri)
          Filter a start Namespace prefix mapping event.
 void unparsedEntityDecl(java.lang.String name, java.lang.String publicId, java.lang.String systemId, java.lang.String notationName)
          Filter an unparsed entity declaration event.
 void warning(org.xml.sax.SAXParseException e)
          Filter a warning event.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

parent

protected org.xml.sax.XMLReader parent

locator

protected org.xml.sax.Locator locator

entityResolver

protected org.xml.sax.EntityResolver entityResolver

dtdHandler

protected org.xml.sax.DTDHandler dtdHandler

contentHandler

protected org.xml.sax.ContentHandler contentHandler

errorHandler

protected org.xml.sax.ErrorHandler errorHandler

lexicalHandler

protected org.xml.sax.ext.LexicalHandler lexicalHandler
Constructor Detail

XTFilterImpl

public XTFilterImpl()
Construct an empty XML filter, with no parent.

This filter will have no parent: you must assign a parent before you start a parse or do any configuration with setFeature or setProperty, unless you use this as a pure event consumer rather than as an XMLReader.

See Also:
XMLReader.setFeature(java.lang.String, boolean), XMLReader.setProperty(java.lang.String, java.lang.Object), setParent(org.xml.sax.XMLReader)

XTFilterImpl

public XTFilterImpl(org.xml.sax.XMLReader parent)
Construct an XML filter with the specified parent.

See Also:
setParent(org.xml.sax.XMLReader), getParent()
Method Detail

setParameter

public void setParameter(java.lang.String k,
                         java.lang.Object v)
Specified by:
setParameter in interface Parametrized

setParent

public void setParent(org.xml.sax.XMLReader parent)
Set the parent reader.

This is the XMLReader from which this filter will obtain its events and to which it will pass its configuration requests. The parent may itself be another filter.

If there is no parent reader set, any attempt to parse or to set or get a feature or property will fail.

Specified by:
setParent in interface org.xml.sax.XMLFilter
Parameters:
parent - The parent XML reader.
See Also:
getParent()

getParent

public org.xml.sax.XMLReader getParent()
Get the parent reader.

Specified by:
getParent in interface org.xml.sax.XMLFilter
Returns:
The parent XML reader, or null if none is set.
See Also:
setParent(org.xml.sax.XMLReader)

setFeature

public void setFeature(java.lang.String name,
                       boolean value)
                throws org.xml.sax.SAXNotRecognizedException,
                       org.xml.sax.SAXNotSupportedException
Set the value of a feature.

This will always fail if the parent is null.

Specified by:
setFeature in interface org.xml.sax.XMLReader
Parameters:
name - The feature name.
value - The requested feature value.
Throws:
org.xml.sax.SAXNotRecognizedException - If the feature value can't be assigned or retrieved from the parent.
org.xml.sax.SAXNotSupportedException - When the parent recognizes the feature name but cannot set the requested value.

getFeature

public boolean getFeature(java.lang.String name)
                   throws org.xml.sax.SAXNotRecognizedException,
                          org.xml.sax.SAXNotSupportedException
Look up the value of a feature.

This will always fail if the parent is null.

Specified by:
getFeature in interface org.xml.sax.XMLReader
Parameters:
name - The feature name.
Returns:
The current value of the feature.
Throws:
org.xml.sax.SAXNotRecognizedException - If the feature value can't be assigned or retrieved from the parent.
org.xml.sax.SAXNotSupportedException - When the parent recognizes the feature name but cannot determine its value at this time.

setProperty

public void setProperty(java.lang.String name,
                        java.lang.Object value)
                 throws org.xml.sax.SAXNotRecognizedException,
                        org.xml.sax.SAXNotSupportedException
Set the value of a property.

This will always fail if the parent is null.

Specified by:
setProperty in interface org.xml.sax.XMLReader
Parameters:
name - The property name.
value - The requested property value.
Throws:
org.xml.sax.SAXNotRecognizedException - If the property value can't be assigned or retrieved from the parent.
org.xml.sax.SAXNotSupportedException - When the parent recognizes the property name but cannot set the requested value.

getProperty

public java.lang.Object getProperty(java.lang.String name)
                             throws org.xml.sax.SAXNotRecognizedException,
                                    org.xml.sax.SAXNotSupportedException
Look up the value of a property.

Specified by:
getProperty in interface org.xml.sax.XMLReader
Parameters:
name - The property name.
Returns:
The current value of the property.
Throws:
org.xml.sax.SAXNotRecognizedException - If the property value can't be assigned or retrieved from the parent.
org.xml.sax.SAXNotSupportedException - When the parent recognizes the property name but cannot determine its value at this time.

setEntityResolver

public void setEntityResolver(org.xml.sax.EntityResolver resolver)
Set the entity resolver.

Specified by:
setEntityResolver in interface org.xml.sax.XMLReader
Parameters:
resolver - The new entity resolver.

getEntityResolver

public org.xml.sax.EntityResolver getEntityResolver()
Get the current entity resolver.

Specified by:
getEntityResolver in interface org.xml.sax.XMLReader
Returns:
The current entity resolver, or null if none was set.

setDTDHandler

public void setDTDHandler(org.xml.sax.DTDHandler handler)
Set the DTD event handler.

Specified by:
setDTDHandler in interface org.xml.sax.XMLReader

getDTDHandler

public org.xml.sax.DTDHandler getDTDHandler()
Get the current DTD event handler.

Specified by:
getDTDHandler in interface org.xml.sax.XMLReader
Returns:
The current DTD handler, or null if none was set.

setContentHandler

public void setContentHandler(org.xml.sax.ContentHandler handler)
Set the content event handler.

Specified by:
setContentHandler in interface org.xml.sax.XMLReader

getContentHandler

public org.xml.sax.ContentHandler getContentHandler()
Get the content event handler.

Specified by:
getContentHandler in interface org.xml.sax.XMLReader
Returns:
The current content handler, or null if none was set.

setLexicalHandler

public void setLexicalHandler(org.xml.sax.ext.LexicalHandler handler)
Set the lexical event handler.

Parameters:
handler - The new lexical handler.

getLexicalHandler

public org.xml.sax.ext.LexicalHandler getLexicalHandler()
Get the lexical event handler.

Returns:
The current lexical handler, or null if none was set.

setErrorHandler

public void setErrorHandler(org.xml.sax.ErrorHandler handler)
Set the error event handler.

Specified by:
setErrorHandler in interface org.xml.sax.XMLReader

getErrorHandler

public org.xml.sax.ErrorHandler getErrorHandler()
Get the current error event handler.

Specified by:
getErrorHandler in interface org.xml.sax.XMLReader
Returns:
The current error handler, or null if none was set.

parse

public void parse(org.xml.sax.InputSource input)
           throws org.xml.sax.SAXException,
                  java.io.IOException
Parse a document.

Specified by:
parse in interface org.xml.sax.XMLReader
Parameters:
input - The input source for the document entity.
Throws:
org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.
java.io.IOException - An IO exception from the parser, possibly from a byte stream or character stream supplied by the application.

parse

public void parse(java.lang.String systemId)
           throws org.xml.sax.SAXException,
                  java.io.IOException
Parse a document.

Specified by:
parse in interface org.xml.sax.XMLReader
Parameters:
systemId - The system identifier as a fully-qualified URI.
Throws:
org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.
java.io.IOException - An IO exception from the parser, possibly from a byte stream or character stream supplied by the application.

resolveEntity

public org.xml.sax.InputSource resolveEntity(java.lang.String publicId,
                                             java.lang.String systemId)
                                      throws org.xml.sax.SAXException,
                                             java.io.IOException
Filter an external entity resolution.

Specified by:
resolveEntity in interface org.xml.sax.EntityResolver
Parameters:
publicId - The entity's public identifier, or null.
systemId - The entity's system identifier.
Returns:
A new InputSource or null for the default.
Throws:
org.xml.sax.SAXException - The client may throw an exception during processing.
java.io.IOException - The client may throw an I/O-related exception while obtaining the new InputSource.

notationDecl

public void notationDecl(java.lang.String name,
                         java.lang.String publicId,
                         java.lang.String systemId)
                  throws org.xml.sax.SAXException
Filter a notation declaration event.

Specified by:
notationDecl in interface org.xml.sax.DTDHandler
Parameters:
name - The notation name.
publicId - The notation's public identifier, or null.
systemId - The notation's system identifier, or null.
Throws:
org.xml.sax.SAXException - The client may throw an exception during processing.

unparsedEntityDecl

public void unparsedEntityDecl(java.lang.String name,
                               java.lang.String publicId,
                               java.lang.String systemId,
                               java.lang.String notationName)
                        throws org.xml.sax.SAXException
Filter an unparsed entity declaration event.

Specified by:
unparsedEntityDecl in interface org.xml.sax.DTDHandler
Parameters:
name - The entity name.
publicId - The entity's public identifier, or null.
systemId - The entity's system identifier, or null.
notationName - The name of the associated notation.
Throws:
org.xml.sax.SAXException - The client may throw an exception during processing.

setDocumentLocator

public void setDocumentLocator(org.xml.sax.Locator locator)
Filter a new document locator event.

Specified by:
setDocumentLocator in interface org.xml.sax.ContentHandler
Parameters:
locator - The document locator.

startDocument

public void startDocument()
                   throws org.xml.sax.SAXException
Filter a start document event.

Specified by:
startDocument in interface org.xml.sax.ContentHandler
Throws:
org.xml.sax.SAXException - The client may throw an exception during processing.

endDocument

public void endDocument()
                 throws org.xml.sax.SAXException
Filter an end document event.

Specified by:
endDocument in interface org.xml.sax.ContentHandler
Throws:
org.xml.sax.SAXException - The client may throw an exception during processing.

startPrefixMapping

public void startPrefixMapping(java.lang.String prefix,
                               java.lang.String uri)
                        throws org.xml.sax.SAXException
Filter a start Namespace prefix mapping event.

Specified by:
startPrefixMapping in interface org.xml.sax.ContentHandler
Parameters:
prefix - The Namespace prefix.
uri - The Namespace URI.
Throws:
org.xml.sax.SAXException - The client may throw an exception during processing.

endPrefixMapping

public void endPrefixMapping(java.lang.String prefix)
                      throws org.xml.sax.SAXException
Filter an end Namespace prefix mapping event.

Specified by:
endPrefixMapping in interface org.xml.sax.ContentHandler
Parameters:
prefix - The Namespace prefix.
Throws:
org.xml.sax.SAXException - The client may throw an exception during processing.

startElement

public void startElement(java.lang.String uri,
                         java.lang.String localName,
                         java.lang.String qName,
                         org.xml.sax.Attributes atts)
                  throws org.xml.sax.SAXException
Filter a start element event.

Specified by:
startElement in interface org.xml.sax.ContentHandler
Parameters:
uri - The element's Namespace URI, or the empty string.
localName - The element's local name, or the empty string.
qName - The element's qualified (prefixed) name, or the empty string.
atts - The element's attributes.
Throws:
org.xml.sax.SAXException - The client may throw an exception during processing.

endElement

public void endElement(java.lang.String uri,
                       java.lang.String localName,
                       java.lang.String qName)
                throws org.xml.sax.SAXException
Filter an end element event.

Specified by:
endElement in interface org.xml.sax.ContentHandler
Parameters:
uri - The element's Namespace URI, or the empty string.
localName - The element's local name, or the empty string.
qName - The element's qualified (prefixed) name, or the empty string.
Throws:
org.xml.sax.SAXException - The client may throw an exception during processing.

characters

public void characters(char[] ch,
                       int start,
                       int length)
                throws org.xml.sax.SAXException
Filter a character data event.

Specified by:
characters in interface org.xml.sax.ContentHandler
Parameters:
ch - An array of characters.
start - The starting position in the array.
length - The number of characters to use from the array.
Throws:
org.xml.sax.SAXException - The client may throw an exception during processing.

ignorableWhitespace

public void ignorableWhitespace(char[] ch,
                                int start,
                                int length)
                         throws org.xml.sax.SAXException
Filter an ignorable whitespace event.

Specified by:
ignorableWhitespace in interface org.xml.sax.ContentHandler
Parameters:
ch - An array of characters.
start - The starting position in the array.
length - The number of characters to use from the array.
Throws:
org.xml.sax.SAXException - The client may throw an exception during processing.

processingInstruction

public void processingInstruction(java.lang.String target,
                                  java.lang.String data)
                           throws org.xml.sax.SAXException
Filter a processing instruction event.

Specified by:
processingInstruction in interface org.xml.sax.ContentHandler
Parameters:
target - The processing instruction target.
data - The text following the target.
Throws:
org.xml.sax.SAXException - The client may throw an exception during processing.

skippedEntity

public void skippedEntity(java.lang.String name)
                   throws org.xml.sax.SAXException
Filter a skipped entity event.

Specified by:
skippedEntity in interface org.xml.sax.ContentHandler
Parameters:
name - The name of the skipped entity.
Throws:
org.xml.sax.SAXException - The client may throw an exception during processing.

warning

public void warning(org.xml.sax.SAXParseException e)
             throws org.xml.sax.SAXException
Filter a warning event.

Specified by:
warning in interface org.xml.sax.ErrorHandler
Parameters:
e - The warning as an exception.
Throws:
org.xml.sax.SAXException - The client may throw an exception during processing.

error

public void error(org.xml.sax.SAXParseException e)
           throws org.xml.sax.SAXException
Filter an error event.

Specified by:
error in interface org.xml.sax.ErrorHandler
Parameters:
e - The error as an exception.
Throws:
org.xml.sax.SAXException - The client may throw an exception during processing.

fatalError

public void fatalError(org.xml.sax.SAXParseException e)
                throws org.xml.sax.SAXException
Filter a fatal error event.

Specified by:
fatalError in interface org.xml.sax.ErrorHandler
Parameters:
e - The error as an exception.
Throws:
org.xml.sax.SAXException - The client may throw an exception during processing.

comment

public void comment(char[] ch,
                    int start,
                    int length)
             throws org.xml.sax.SAXException
Callback interface for SAX (part of LexicalHandler interface): not for application use

Specified by:
comment in interface org.xml.sax.ext.LexicalHandler
Throws:
org.xml.sax.SAXException

startDTD

public void startDTD(java.lang.String name,
                     java.lang.String publicId,
                     java.lang.String systemId)
              throws org.xml.sax.SAXException
Register the start of the DTD. Comments in the DTD are skipped because they are not part of the XPath data model

Specified by:
startDTD in interface org.xml.sax.ext.LexicalHandler
Throws:
org.xml.sax.SAXException

endDTD

public void endDTD()
            throws org.xml.sax.SAXException
Register the end of the DTD. Comments in the DTD are skipped because they are not part of the XPath data model

Specified by:
endDTD in interface org.xml.sax.ext.LexicalHandler
Throws:
org.xml.sax.SAXException

startEntity

public void startEntity(java.lang.String name)
                 throws org.xml.sax.SAXException
Specified by:
startEntity in interface org.xml.sax.ext.LexicalHandler
Throws:
org.xml.sax.SAXException

endEntity

public void endEntity(java.lang.String name)
               throws org.xml.sax.SAXException
Specified by:
endEntity in interface org.xml.sax.ext.LexicalHandler
Throws:
org.xml.sax.SAXException

startCDATA

public void startCDATA()
                throws org.xml.sax.SAXException
Specified by:
startCDATA in interface org.xml.sax.ext.LexicalHandler
Throws:
org.xml.sax.SAXException

endCDATA

public void endCDATA()
              throws org.xml.sax.SAXException
Specified by:
endCDATA in interface org.xml.sax.ext.LexicalHandler
Throws:
org.xml.sax.SAXException

setupParse

protected void setupParse()
                   throws org.xml.sax.SAXException
Set up before a parse.

Before every parse, check whether the parent is non-null, and re-register the filter for all of the events.

Throws:
org.xml.sax.SAXException