org.cyberneko.html.filters
Class DefaultFilter

java.lang.Object
  extended by org.cyberneko.html.filters.DefaultFilter
All Implemented Interfaces:
HTMLComponent
Direct Known Subclasses:
ElementRemover, Identity, NamespaceBinder, Purifier, Writer

public class DefaultFilter
extends java.lang.Object
implements 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: DefaultFilter.java,v 1.7 2005/02/14 03:56:54 andyc Exp $
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(java.lang.String root, java.lang.String publicId, java.lang.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(java.lang.String name, Augmentations augs)
          End general entity.
 void endPrefixMapping(java.lang.String prefix, Augmentations augs)
          End prefix mapping.
 XMLDocumentHandler getDocumentHandler()
          Returns the document handler.
 XMLDocumentSource getDocumentSource()
          Returns the document source.
 java.lang.Boolean getFeatureDefault(java.lang.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.
 java.lang.Object getPropertyDefault(java.lang.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.
 java.lang.String[] getRecognizedFeatures()
          Returns a list of feature identifiers that are recognized by this component.
 java.lang.String[] getRecognizedProperties()
          Returns a list of property identifiers that are recognized by this component.
 void ignorableWhitespace(XMLString text, Augmentations augs)
          Ignorable whitespace.
protected static java.lang.String[] merge(java.lang.String[] array1, java.lang.String[] array2)
          Utility method for merging string arrays for recognized features and recognized properties.
 void processingInstruction(java.lang.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(java.lang.String featureId, boolean state)
          Sets the state of a feature.
 void setProperty(java.lang.String propertyId, java.lang.Object value)
          Sets the value of a property.
 void startCDATA(Augmentations augs)
          Start CDATA section.
 void startDocument(XMLLocator locator, java.lang.String encoding, Augmentations augs)
          Start document.
 void startDocument(XMLLocator locator, java.lang.String encoding, NamespaceContext nscontext, Augmentations augs)
          Start document.
 void startElement(QName element, XMLAttributes attributes, Augmentations augs)
          Start element.
 void startGeneralEntity(java.lang.String name, XMLResourceIdentifier id, java.lang.String encoding, Augmentations augs)
          Start general entity.
 void startPrefixMapping(java.lang.String prefix, java.lang.String uri, Augmentations augs)
          Start prefix mapping.
 void textDecl(java.lang.String version, java.lang.String encoding, Augmentations augs)
          Text declaration.
 void xmlDecl(java.lang.String version, java.lang.String encoding, java.lang.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.


getDocumentHandler

public XMLDocumentHandler getDocumentHandler()
Returns the document handler.


setDocumentSource

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


getDocumentSource

public XMLDocumentSource getDocumentSource()
Returns the document source.


startDocument

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

Throws:
XNIException

xmlDecl

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

Throws:
XNIException

doctypeDecl

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

Throws:
XNIException

comment

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

Throws:
XNIException

processingInstruction

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

Throws:
XNIException

startElement

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

Throws:
XNIException

emptyElement

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

Throws:
XNIException

characters

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

Throws:
XNIException

ignorableWhitespace

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

Throws:
XNIException

startGeneralEntity

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

Throws:
XNIException

textDecl

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

Throws:
XNIException

endGeneralEntity

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

Throws:
XNIException

startCDATA

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

Throws:
XNIException

endCDATA

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

Throws:
XNIException

endElement

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

Throws:
XNIException

endDocument

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

Throws:
XNIException

startDocument

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

Throws:
XNIException

startPrefixMapping

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

Throws:
XNIException

endPrefixMapping

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

Throws:
XNIException

getRecognizedFeatures

public java.lang.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.


getFeatureDefault

public java.lang.Boolean getFeatureDefault(java.lang.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 java.lang.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.


getPropertyDefault

public java.lang.Object getPropertyDefault(java.lang.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.

Parameters:
componentManager - The component manager.
Throws:
XNIException - Thrown by component on initialization error.
XMLConfigurationException

setFeature

public void setFeature(java.lang.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.

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(java.lang.String propertyId,
                        java.lang.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.

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 java.lang.String[] merge(java.lang.String[] array1,
                                          java.lang.String[] array2)
Utility method for merging string arrays for recognized features and recognized properties.



(C) Copyright 2002-2010, Andy Clark, Marc Guillemot. All rights reserved.