org.cyberneko.html.filters
Class DefaultFilter

java.lang.Object
  extended byorg.cyberneko.html.filters.DefaultFilter
All Implemented Interfaces:
HTMLComponent, XMLComponent, XMLDocumentFilter, XMLDocumentHandler, XMLDocumentSource
Direct Known Subclasses:
ElementRemover, Identity, NamespaceBinder, Purifier, Writer

public class DefaultFilter
extends Object
implements XMLDocumentFilter, HTMLComponent

This class implements a filter that simply passes document events to the next handler. It can be used as a base class to simplify the development of new document filters.

Version:
$Id$
Author:
Andy Clark

Field Summary
protected  XMLDocumentHandler fDocumentHandler
          Document handler.
protected  XMLDocumentSource fDocumentSource
          Document source.
 
Constructor Summary
DefaultFilter()
           
 
Method Summary
 void characters(XMLString text, Augmentations augs)
          Characters.
 void comment(XMLString text, Augmentations augs)
          Comment.
 void doctypeDecl(String root, String publicId, String systemId, Augmentations augs)
          Doctype declaration.
 void emptyElement(QName element, XMLAttributes attributes, Augmentations augs)
          Empty element.
 void endCDATA(Augmentations augs)
          End CDATA section.
 void endDocument(Augmentations augs)
          End document.
 void endElement(QName element, Augmentations augs)
          End element.
 void endGeneralEntity(String name, Augmentations augs)
          End general entity.
 void endPrefixMapping(String prefix, Augmentations augs)
          End prefix mapping.
 XMLDocumentHandler getDocumentHandler()
          Returns the document handler.
 XMLDocumentSource getDocumentSource()
          Returns the document source.
 Boolean getFeatureDefault(String featureId)
          Returns the default state for a feature, or null if this component does not want to report a default value for this feature.
 Object getPropertyDefault(String propertyId)
          Returns the default state for a property, or null if this component does not want to report a default value for this property.
 String[] getRecognizedFeatures()
          Returns a list of feature identifiers that are recognized by this component.
 String[] getRecognizedProperties()
          Returns a list of property identifiers that are recognized by this component.
 void ignorableWhitespace(XMLString text, Augmentations augs)
          Ignorable whitespace.
protected static String[] merge(String[] array1, String[] array2)
          Utility method for merging string arrays for recognized features and recognized properties.
 void processingInstruction(String target, XMLString data, Augmentations augs)
          Processing instruction.
 void reset(XMLComponentManager componentManager)
          Resets the component.
 void setDocumentHandler(XMLDocumentHandler handler)
          Sets the document handler.
 void setDocumentSource(XMLDocumentSource source)
          Sets the document source.
 void setFeature(String featureId, boolean state)
          Sets the state of a feature.
 void setProperty(String propertyId, Object value)
          Sets the value of a property.
 void startCDATA(Augmentations augs)
          Start CDATA section.
 void startDocument(XMLLocator locator, String encoding, Augmentations augs)
          Start document.
 void startDocument(XMLLocator locator, String encoding, NamespaceContext nscontext, Augmentations augs)
          Start document.
 void startElement(QName element, XMLAttributes attributes, Augmentations augs)
          Start element.
 void startGeneralEntity(String name, XMLResourceIdentifier id, String encoding, Augmentations augs)
          Start general entity.
 void startPrefixMapping(String prefix, String uri, Augmentations augs)
          Start prefix mapping.
 void textDecl(String version, String encoding, Augmentations augs)
          Text declaration.
 void xmlDecl(String version, String encoding, String standalone, Augmentations augs)
          XML declaration.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fDocumentHandler

protected XMLDocumentHandler fDocumentHandler
Document handler.


fDocumentSource

protected XMLDocumentSource fDocumentSource
Document source.

Constructor Detail

DefaultFilter

public DefaultFilter()
Method Detail

setDocumentHandler

public void setDocumentHandler(XMLDocumentHandler handler)
Sets the document handler.

Specified by:
setDocumentHandler in interface XMLDocumentSource

getDocumentHandler

public XMLDocumentHandler getDocumentHandler()
Returns the document handler.

Specified by:
getDocumentHandler in interface XMLDocumentSource

setDocumentSource

public void setDocumentSource(XMLDocumentSource source)
Sets the document source.

Specified by:
setDocumentSource in interface XMLDocumentHandler

getDocumentSource

public XMLDocumentSource getDocumentSource()
Returns the document source.

Specified by:
getDocumentSource in interface XMLDocumentHandler

startDocument

public void startDocument(XMLLocator locator,
                          String encoding,
                          NamespaceContext nscontext,
                          Augmentations augs)
                   throws XNIException
Start document.

Specified by:
startDocument in interface XMLDocumentHandler
Throws:
XNIException

xmlDecl

public void xmlDecl(String version,
                    String encoding,
                    String standalone,
                    Augmentations augs)
             throws XNIException
XML declaration.

Specified by:
xmlDecl in interface XMLDocumentHandler
Throws:
XNIException

doctypeDecl

public void doctypeDecl(String root,
                        String publicId,
                        String systemId,
                        Augmentations augs)
                 throws XNIException
Doctype declaration.

Specified by:
doctypeDecl in interface XMLDocumentHandler
Throws:
XNIException

comment

public void comment(XMLString text,
                    Augmentations augs)
             throws XNIException
Comment.

Specified by:
comment in interface XMLDocumentHandler
Throws:
XNIException

processingInstruction

public void processingInstruction(String target,
                                  XMLString data,
                                  Augmentations augs)
                           throws XNIException
Processing instruction.

Specified by:
processingInstruction in interface XMLDocumentHandler
Throws:
XNIException

startElement

public void startElement(QName element,
                         XMLAttributes attributes,
                         Augmentations augs)
                  throws XNIException
Start element.

Specified by:
startElement in interface XMLDocumentHandler
Throws:
XNIException

emptyElement

public void emptyElement(QName element,
                         XMLAttributes attributes,
                         Augmentations augs)
                  throws XNIException
Empty element.

Specified by:
emptyElement in interface XMLDocumentHandler
Throws:
XNIException

characters

public void characters(XMLString text,
                       Augmentations augs)
                throws XNIException
Characters.

Specified by:
characters in interface XMLDocumentHandler
Throws:
XNIException

ignorableWhitespace

public void ignorableWhitespace(XMLString text,
                                Augmentations augs)
                         throws XNIException
Ignorable whitespace.

Specified by:
ignorableWhitespace in interface XMLDocumentHandler
Throws:
XNIException

startGeneralEntity

public void startGeneralEntity(String name,
                               XMLResourceIdentifier id,
                               String encoding,
                               Augmentations augs)
                        throws XNIException
Start general entity.

Specified by:
startGeneralEntity in interface XMLDocumentHandler
Throws:
XNIException

textDecl

public void textDecl(String version,
                     String encoding,
                     Augmentations augs)
              throws XNIException
Text declaration.

Specified by:
textDecl in interface XMLDocumentHandler
Throws:
XNIException

endGeneralEntity

public void endGeneralEntity(String name,
                             Augmentations augs)
                      throws XNIException
End general entity.

Specified by:
endGeneralEntity in interface XMLDocumentHandler
Throws:
XNIException

startCDATA

public void startCDATA(Augmentations augs)
                throws XNIException
Start CDATA section.

Specified by:
startCDATA in interface XMLDocumentHandler
Throws:
XNIException

endCDATA

public void endCDATA(Augmentations augs)
              throws XNIException
End CDATA section.

Specified by:
endCDATA in interface XMLDocumentHandler
Throws:
XNIException

endElement

public void endElement(QName element,
                       Augmentations augs)
                throws XNIException
End element.

Specified by:
endElement in interface XMLDocumentHandler
Throws:
XNIException

endDocument

public void endDocument(Augmentations augs)
                 throws XNIException
End document.

Specified by:
endDocument in interface XMLDocumentHandler
Throws:
XNIException

startDocument

public void startDocument(XMLLocator locator,
                          String encoding,
                          Augmentations augs)
                   throws XNIException
Start document.

Throws:
XNIException

startPrefixMapping

public void startPrefixMapping(String prefix,
                               String uri,
                               Augmentations augs)
                        throws XNIException
Start prefix mapping.

Throws:
XNIException

endPrefixMapping

public void endPrefixMapping(String prefix,
                             Augmentations augs)
                      throws XNIException
End prefix mapping.

Throws:
XNIException

getRecognizedFeatures

public String[] getRecognizedFeatures()
Returns a list of feature identifiers that are recognized by this component. This method may return null if no features are recognized by this component.

Specified by:
getRecognizedFeatures in interface XMLComponent

getFeatureDefault

public Boolean getFeatureDefault(String featureId)
Returns the default state for a feature, or null if this component does not want to report a default value for this feature.

Specified by:
getFeatureDefault in interface HTMLComponent

getRecognizedProperties

public String[] getRecognizedProperties()
Returns a list of property identifiers that are recognized by this component. This method may return null if no properties are recognized by this component.

Specified by:
getRecognizedProperties in interface XMLComponent

getPropertyDefault

public Object getPropertyDefault(String propertyId)
Returns the default state for a property, or null if this component does not want to report a default value for this property.

Specified by:
getPropertyDefault in interface HTMLComponent

reset

public void reset(XMLComponentManager componentManager)
           throws XMLConfigurationException
Resets the component. The component can query the component manager about any features and properties that affect the operation of the component.

Specified by:
reset in interface XMLComponent
Parameters:
componentManager - The component manager.
Throws:
XNIException - Thrown by component on initialization error.
XMLConfigurationException

setFeature

public void setFeature(String featureId,
                       boolean state)
                throws XMLConfigurationException
Sets the state of a feature. This method is called by the component manager any time after reset when a feature changes state.

Note: Components should silently ignore features that do not affect the operation of the component.

Specified by:
setFeature in interface XMLComponent
Parameters:
featureId - The feature identifier.
state - The state of the feature.
Throws:
XMLConfigurationException - Thrown for configuration error. In general, components should only throw this exception if it is really a critical error.

setProperty

public void setProperty(String propertyId,
                        Object value)
                 throws XMLConfigurationException
Sets the value of a property. This method is called by the component manager any time after reset when a property changes value.

Note: Components should silently ignore properties that do not affect the operation of the component.

Specified by:
setProperty in interface XMLComponent
Parameters:
propertyId - The property identifier.
value - The value of the property.
Throws:
XMLConfigurationException - Thrown for configuration error. In general, components should only throw this exception if it is really a critical error.

merge

protected static String[] merge(String[] array1,
                                String[] array2)
Utility method for merging string arrays for recognized features and recognized properties.



(C) Copyright 2002-2004, Andy Clark. All rights reserved.