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
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
FieldsModifier and TypeFieldDescriptionprivate XMLDocumentHandler
Document handler.private XMLDocumentSource
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
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.Returns the document handler.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.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[]
Returns a list of feature identifiers that are recognized by this component.String[]
Returns a list of property identifiers that are recognized by this component.protected static String[]
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, NamespaceContext nscontext, Augmentations augs) Start document.void
startElement
(QName element, XMLAttributes attributes, Augmentations augs) Start element.void
xmlDecl
(String version, String encoding, String standalone, Augmentations augs) XML declaration.
-
Field Details
-
documentHandler_
Document handler. -
documentSource_
-
-
Constructor Details
-
DefaultFilter
public DefaultFilter()
-
-
Method Details
-
setDocumentHandler
Sets the document handler.- Specified by:
setDocumentHandler
in interfaceXMLDocumentSource
- Parameters:
handler
- the new handler
-
getDocumentHandler
Returns the document handler.- Specified by:
getDocumentHandler
in interfaceXMLDocumentSource
- Returns:
- the document handler
-
setDocumentSource
Sets the document source.- Specified by:
setDocumentSource
in interfaceXMLDocumentHandler
- Parameters:
source
- the new source
-
getDocumentSource
- Specified by:
getDocumentSource
in interfaceXMLDocumentHandler
- Returns:
- the document source.
-
startDocument
public void startDocument(XMLLocator locator, 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(String version, String encoding, 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(String root, String publicId, 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
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(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
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
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
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
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
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
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
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
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
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
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
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
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
Utility method for merging string arrays for recognized features and recognized properties.- Parameters:
array1
- array1array2
- array2- Returns:
- the merged array
-