org.cyberneko.html.filters
Class DefaultFilter

java.lang.Object
  extended by org.cyberneko.html.filters.DefaultFilter
All Implemented Interfaces:
org.apache.xerces.xni.parser.XMLComponent, org.apache.xerces.xni.parser.XMLDocumentFilter, org.apache.xerces.xni.parser.XMLDocumentSource, org.apache.xerces.xni.XMLDocumentHandler, HTMLComponent
Direct Known Subclasses:
ElementRemover, Identity, NamespaceBinder, Purifier, Writer

public class DefaultFilter
extends java.lang.Object
implements org.apache.xerces.xni.parser.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: DefaultFilter.java,v 1.7 2005/02/14 03:56:54 andyc Exp $
Author:
Andy Clark

Field Summary
protected  org.apache.xerces.xni.XMLDocumentHandler fDocumentHandler
          Document handler.
protected  org.apache.xerces.xni.parser.XMLDocumentSource fDocumentSource
          Document source.
 
Constructor Summary
DefaultFilter()
           
 
Method Summary
 void characters(org.apache.xerces.xni.XMLString text, org.apache.xerces.xni.Augmentations augs)
          Characters.
 void comment(org.apache.xerces.xni.XMLString text, org.apache.xerces.xni.Augmentations augs)
          Comment.
 void doctypeDecl(java.lang.String root, java.lang.String publicId, java.lang.String systemId, org.apache.xerces.xni.Augmentations augs)
          Doctype declaration.
 void emptyElement(org.apache.xerces.xni.QName element, org.apache.xerces.xni.XMLAttributes attributes, org.apache.xerces.xni.Augmentations augs)
          Empty element.
 void endCDATA(org.apache.xerces.xni.Augmentations augs)
          End CDATA section.
 void endDocument(org.apache.xerces.xni.Augmentations augs)
          End document.
 void endElement(org.apache.xerces.xni.QName element, org.apache.xerces.xni.Augmentations augs)
          End element.
 void endGeneralEntity(java.lang.String name, org.apache.xerces.xni.Augmentations augs)
          End general entity.
 void endPrefixMapping(java.lang.String prefix, org.apache.xerces.xni.Augmentations augs)
          End prefix mapping.
 org.apache.xerces.xni.XMLDocumentHandler getDocumentHandler()
          Returns the document handler.
 org.apache.xerces.xni.parser.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(org.apache.xerces.xni.XMLString text, org.apache.xerces.xni.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, org.apache.xerces.xni.XMLString data, org.apache.xerces.xni.Augmentations augs)
          Processing instruction.
 void reset(org.apache.xerces.xni.parser.XMLComponentManager componentManager)
          Resets the component.
 void setDocumentHandler(org.apache.xerces.xni.XMLDocumentHandler handler)
          Sets the document handler.
 void setDocumentSource(org.apache.xerces.xni.parser.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(org.apache.xerces.xni.Augmentations augs)
          Start CDATA section.
 void startDocument(org.apache.xerces.xni.XMLLocator locator, java.lang.String encoding, org.apache.xerces.xni.Augmentations augs)
          Start document.
 void startDocument(org.apache.xerces.xni.XMLLocator locator, java.lang.String encoding, org.apache.xerces.xni.NamespaceContext nscontext, org.apache.xerces.xni.Augmentations augs)
          Start document.
 void startElement(org.apache.xerces.xni.QName element, org.apache.xerces.xni.XMLAttributes attributes, org.apache.xerces.xni.Augmentations augs)
          Start element.
 void startGeneralEntity(java.lang.String name, org.apache.xerces.xni.XMLResourceIdentifier id, java.lang.String encoding, org.apache.xerces.xni.Augmentations augs)
          Start general entity.
 void startPrefixMapping(java.lang.String prefix, java.lang.String uri, org.apache.xerces.xni.Augmentations augs)
          Start prefix mapping.
 void textDecl(java.lang.String version, java.lang.String encoding, org.apache.xerces.xni.Augmentations augs)
          Text declaration.
 void xmlDecl(java.lang.String version, java.lang.String encoding, java.lang.String standalone, org.apache.xerces.xni.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 org.apache.xerces.xni.XMLDocumentHandler fDocumentHandler
Document handler.


fDocumentSource

protected org.apache.xerces.xni.parser.XMLDocumentSource fDocumentSource
Document source.

Constructor Detail

DefaultFilter

public DefaultFilter()
Method Detail

setDocumentHandler

public void setDocumentHandler(org.apache.xerces.xni.XMLDocumentHandler handler)
Sets the document handler.

Specified by:
setDocumentHandler in interface org.apache.xerces.xni.parser.XMLDocumentSource

getDocumentHandler

public org.apache.xerces.xni.XMLDocumentHandler getDocumentHandler()
Returns the document handler.

Specified by:
getDocumentHandler in interface org.apache.xerces.xni.parser.XMLDocumentSource

setDocumentSource

public void setDocumentSource(org.apache.xerces.xni.parser.XMLDocumentSource source)
Sets the document source.

Specified by:
setDocumentSource in interface org.apache.xerces.xni.XMLDocumentHandler

getDocumentSource

public org.apache.xerces.xni.parser.XMLDocumentSource getDocumentSource()
Returns the document source.

Specified by:
getDocumentSource in interface org.apache.xerces.xni.XMLDocumentHandler

startDocument

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

Specified by:
startDocument in interface org.apache.xerces.xni.XMLDocumentHandler
Throws:
org.apache.xerces.xni.XNIException

xmlDecl

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

Specified by:
xmlDecl in interface org.apache.xerces.xni.XMLDocumentHandler
Throws:
org.apache.xerces.xni.XNIException

doctypeDecl

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

Specified by:
doctypeDecl in interface org.apache.xerces.xni.XMLDocumentHandler
Throws:
org.apache.xerces.xni.XNIException

comment

public void comment(org.apache.xerces.xni.XMLString text,
                    org.apache.xerces.xni.Augmentations augs)
             throws org.apache.xerces.xni.XNIException
Comment.

Specified by:
comment in interface org.apache.xerces.xni.XMLDocumentHandler
Throws:
org.apache.xerces.xni.XNIException

processingInstruction

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

Specified by:
processingInstruction in interface org.apache.xerces.xni.XMLDocumentHandler
Throws:
org.apache.xerces.xni.XNIException

startElement

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

Specified by:
startElement in interface org.apache.xerces.xni.XMLDocumentHandler
Throws:
org.apache.xerces.xni.XNIException

emptyElement

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

Specified by:
emptyElement in interface org.apache.xerces.xni.XMLDocumentHandler
Throws:
org.apache.xerces.xni.XNIException

characters

public void characters(org.apache.xerces.xni.XMLString text,
                       org.apache.xerces.xni.Augmentations augs)
                throws org.apache.xerces.xni.XNIException
Characters.

Specified by:
characters in interface org.apache.xerces.xni.XMLDocumentHandler
Throws:
org.apache.xerces.xni.XNIException

ignorableWhitespace

public void ignorableWhitespace(org.apache.xerces.xni.XMLString text,
                                org.apache.xerces.xni.Augmentations augs)
                         throws org.apache.xerces.xni.XNIException
Ignorable whitespace.

Specified by:
ignorableWhitespace in interface org.apache.xerces.xni.XMLDocumentHandler
Throws:
org.apache.xerces.xni.XNIException

startGeneralEntity

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

Specified by:
startGeneralEntity in interface org.apache.xerces.xni.XMLDocumentHandler
Throws:
org.apache.xerces.xni.XNIException

textDecl

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

Specified by:
textDecl in interface org.apache.xerces.xni.XMLDocumentHandler
Throws:
org.apache.xerces.xni.XNIException

endGeneralEntity

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

Specified by:
endGeneralEntity in interface org.apache.xerces.xni.XMLDocumentHandler
Throws:
org.apache.xerces.xni.XNIException

startCDATA

public void startCDATA(org.apache.xerces.xni.Augmentations augs)
                throws org.apache.xerces.xni.XNIException
Start CDATA section.

Specified by:
startCDATA in interface org.apache.xerces.xni.XMLDocumentHandler
Throws:
org.apache.xerces.xni.XNIException

endCDATA

public void endCDATA(org.apache.xerces.xni.Augmentations augs)
              throws org.apache.xerces.xni.XNIException
End CDATA section.

Specified by:
endCDATA in interface org.apache.xerces.xni.XMLDocumentHandler
Throws:
org.apache.xerces.xni.XNIException

endElement

public void endElement(org.apache.xerces.xni.QName element,
                       org.apache.xerces.xni.Augmentations augs)
                throws org.apache.xerces.xni.XNIException
End element.

Specified by:
endElement in interface org.apache.xerces.xni.XMLDocumentHandler
Throws:
org.apache.xerces.xni.XNIException

endDocument

public void endDocument(org.apache.xerces.xni.Augmentations augs)
                 throws org.apache.xerces.xni.XNIException
End document.

Specified by:
endDocument in interface org.apache.xerces.xni.XMLDocumentHandler
Throws:
org.apache.xerces.xni.XNIException

startDocument

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

Throws:
org.apache.xerces.xni.XNIException

startPrefixMapping

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

Throws:
org.apache.xerces.xni.XNIException

endPrefixMapping

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

Throws:
org.apache.xerces.xni.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.

Specified by:
getRecognizedFeatures in interface org.apache.xerces.xni.parser.XMLComponent

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 org.apache.xerces.xni.parser.XMLComponent
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.

Specified by:
getRecognizedProperties in interface org.apache.xerces.xni.parser.XMLComponent

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 org.apache.xerces.xni.parser.XMLComponent
Specified by:
getPropertyDefault in interface HTMLComponent

reset

public void reset(org.apache.xerces.xni.parser.XMLComponentManager componentManager)
           throws org.apache.xerces.xni.parser.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 org.apache.xerces.xni.parser.XMLComponent
Parameters:
componentManager - The component manager.
Throws:
org.apache.xerces.xni.XNIException - Thrown by component on initialization error.
org.apache.xerces.xni.parser.XMLConfigurationException

setFeature

public void setFeature(java.lang.String featureId,
                       boolean state)
                throws org.apache.xerces.xni.parser.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 org.apache.xerces.xni.parser.XMLComponent
Parameters:
featureId - The feature identifier.
state - The state of the feature.
Throws:
org.apache.xerces.xni.parser.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 org.apache.xerces.xni.parser.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 org.apache.xerces.xni.parser.XMLComponent
Parameters:
propertyId - The property identifier.
value - The value of the property.
Throws:
org.apache.xerces.xni.parser.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-2008, Andy Clark. All rights reserved.