Package org.htmlunit.cyberneko.filters
Class DefaultFilter
- java.lang.Object
-
- org.htmlunit.cyberneko.filters.DefaultFilter
-
- All Implemented Interfaces:
HTMLComponent
,XMLComponent
,XMLDocumentFilter
,XMLDocumentSource
,XMLDocumentHandler
- Direct Known Subclasses:
HTMLWriterFilter
,NamespaceBinder
public class DefaultFilter extends java.lang.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.
-
-
Field Summary
Fields Modifier and Type Field Description private XMLDocumentHandler
documentHandler_
Document handler.private XMLDocumentSource
documentSource_
-
Constructor Summary
Constructors Constructor Description DefaultFilter()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.XMLDocumentHandler
getDocumentHandler()
Returns the document handler.XMLDocumentSource
getDocumentSource()
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.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, NamespaceContext nscontext, Augmentations augs)
Start document.void
startElement(QName element, XMLAttributes attributes, Augmentations augs)
Start element.void
xmlDecl(java.lang.String version, java.lang.String encoding, java.lang.String standalone, Augmentations augs)
XML declaration.
-
-
-
Field Detail
-
documentHandler_
private XMLDocumentHandler documentHandler_
Document handler.
-
documentSource_
private XMLDocumentSource documentSource_
-
-
Method Detail
-
setDocumentHandler
public void setDocumentHandler(XMLDocumentHandler handler)
Sets the document handler.- Specified by:
setDocumentHandler
in interfaceXMLDocumentSource
- Parameters:
handler
- the new handler
-
getDocumentHandler
public XMLDocumentHandler getDocumentHandler()
Returns the document handler.- Specified by:
getDocumentHandler
in interfaceXMLDocumentSource
- Returns:
- the document handler
-
setDocumentSource
public void setDocumentSource(XMLDocumentSource source)
Sets the document source.- Specified by:
setDocumentSource
in interfaceXMLDocumentHandler
- Parameters:
source
- the new source
-
getDocumentSource
public XMLDocumentSource getDocumentSource()
- Specified by:
getDocumentSource
in interfaceXMLDocumentHandler
- Returns:
- the document source.
-
startDocument
public void startDocument(XMLLocator locator, java.lang.String encoding, NamespaceContext nscontext, Augmentations augs) throws XNIException
Start document.- Specified by:
startDocument
in interfaceXMLDocumentHandler
- Parameters:
locator
- The document locator, or null if the document location cannot be reported during the parsing of this document. However, it is strongly recommended that a locator be supplied that can at least report the system identifier of the document.encoding
- The auto-detected IANA encoding name of the entity stream. This value will be null in those situations where the entity encoding is not auto-detected (e.g. internal entities or a document entity that is parsed from a java.io.Reader).nscontext
- The namespace context in effect at the start of this document. This object represents the current context. Implementors of this class are responsible for copying the namespace bindings from the the current context (and its parent contexts) if that information is important.augs
- Additional information that may include infoset augmentations- Throws:
XNIException
- Thrown by handler to signal an error.
-
xmlDecl
public void xmlDecl(java.lang.String version, java.lang.String encoding, java.lang.String standalone, Augmentations augs) throws XNIException
XML declaration.- Specified by:
xmlDecl
in interfaceXMLDocumentHandler
- Parameters:
version
- The XML version.encoding
- The IANA encoding name of the document, or null if not specified.standalone
- The standalone value, or null if not specified.augs
- Additional information that may include infoset augmentations- Throws:
XNIException
- Thrown by handler to signal an error.
-
doctypeDecl
public void doctypeDecl(java.lang.String root, java.lang.String publicId, java.lang.String systemId, Augmentations augs) throws XNIException
Doctype declaration.- Specified by:
doctypeDecl
in interfaceXMLDocumentHandler
- Parameters:
root
- The name of the root element.publicId
- The public identifier if an external DTD or null if the external DTD is specified using SYSTEM.systemId
- The system identifier if an external DTD, null otherwise.augs
- Additional information that may include infoset augmentations- Throws:
XNIException
- Thrown by handler to signal an error.
-
comment
public void comment(XMLString text, Augmentations augs) throws XNIException
Comment.- Specified by:
comment
in interfaceXMLDocumentHandler
- Parameters:
text
- The text in the comment.augs
- Additional information that may include infoset augmentations- Throws:
XNIException
- Thrown by application to signal an error.
-
processingInstruction
public void processingInstruction(java.lang.String target, XMLString data, Augmentations augs) throws XNIException
Processing instruction.- Specified by:
processingInstruction
in interfaceXMLDocumentHandler
- Parameters:
target
- The target.data
- The data or null if none specified.augs
- Additional information that may include infoset augmentations- Throws:
XNIException
- Thrown by handler to signal an error.
-
startElement
public void startElement(QName element, XMLAttributes attributes, Augmentations augs) throws XNIException
Start element.- Specified by:
startElement
in interfaceXMLDocumentHandler
- Parameters:
element
- The name of the element.attributes
- The element attributes.augs
- Additional information that may include infoset augmentations- Throws:
XNIException
- Thrown by handler to signal an error.
-
emptyElement
public void emptyElement(QName element, XMLAttributes attributes, Augmentations augs) throws XNIException
Empty element.- Specified by:
emptyElement
in interfaceXMLDocumentHandler
- Parameters:
element
- The name of the element.attributes
- The element attributes.augs
- Additional information that may include infoset augmentations- Throws:
XNIException
- Thrown by handler to signal an error.
-
characters
public void characters(XMLString text, Augmentations augs) throws XNIException
Characters.- Specified by:
characters
in interfaceXMLDocumentHandler
- Parameters:
text
- The content.augs
- Additional information that may include infoset augmentations- Throws:
XNIException
- Thrown by handler to signal an error.
-
startCDATA
public void startCDATA(Augmentations augs) throws XNIException
Start CDATA section.- Specified by:
startCDATA
in interfaceXMLDocumentHandler
- Parameters:
augs
- Additional information that may include infoset augmentations- Throws:
XNIException
- Thrown by handler to signal an error.
-
endCDATA
public void endCDATA(Augmentations augs) throws XNIException
End CDATA section.- Specified by:
endCDATA
in interfaceXMLDocumentHandler
- Parameters:
augs
- Additional information that may include infoset augmentations- Throws:
XNIException
- Thrown by handler to signal an error.
-
endElement
public void endElement(QName element, Augmentations augs) throws XNIException
End element.- Specified by:
endElement
in interfaceXMLDocumentHandler
- Parameters:
element
- The name of the element.augs
- Additional information that may include infoset augmentations- Throws:
XNIException
- Thrown by handler to signal an error.
-
endDocument
public void endDocument(Augmentations augs) throws XNIException
End document.- Specified by:
endDocument
in interfaceXMLDocumentHandler
- Parameters:
augs
- Additional information that may include infoset augmentations- Throws:
XNIException
- Thrown by handler to signal an error.
-
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 interfaceXMLComponent
- Returns:
- an array 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 interfaceHTMLComponent
- Specified by:
getFeatureDefault
in interfaceXMLComponent
- Parameters:
featureId
- The feature identifier.- Returns:
- the default state for a feature, or null if this component does not want to report a default value for this feature.
-
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 interfaceXMLComponent
- Returns:
- an array 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 interfaceHTMLComponent
- Specified by:
getPropertyDefault
in interfaceXMLComponent
- Parameters:
propertyId
- The property identifier.- Returns:
- the default state for a property, or null if this component does not want to report a default value for this property
-
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 interfaceXMLComponent
- 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.
- Specified by:
setFeature
in interfaceXMLComponent
- 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.
- Specified by:
setProperty
in interfaceXMLComponent
- 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.- Parameters:
array1
- array1array2
- array2- Returns:
- the merged array
-
-