Package org.htmlunit.cyberneko.filters
Class NamespaceBinder
- java.lang.Object
-
- org.htmlunit.cyberneko.filters.DefaultFilter
-
- org.htmlunit.cyberneko.filters.NamespaceBinder
-
- All Implemented Interfaces:
HTMLComponent
,XMLComponent
,XMLDocumentFilter
,XMLDocumentSource
,XMLDocumentHandler
public class NamespaceBinder extends DefaultFilter
This filter binds namespaces if namespace processing is turned on by setting the feature "http://xml.org/sax/features/namespaces" is set totrue
.This configuration recognizes the following features:
- http://xml.org/sax/features/namespaces
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
NamespaceBinder.NamespaceSupport
This namespace context object implements the old and new XNINamespaceContext
interface methods so that it can be used across all versions of Xerces2.
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.Boolean[]
FEATURE_DEFAULTS
Feature defaults.private HTMLConfiguration
htmlConfiguration_
private static java.lang.String
INSERT_NAMESPACES
Insert namespace binding URIs.private boolean
insertNamespaces_
Insert namespaces.private static java.lang.String
NAMES_ELEMS
Modify HTML element names: { "upper", "lower", "default" }.private static short
NAMES_LOWERCASE
Lowercase HTML names.private static short
NAMES_NO_CHANGE
Don't modify HTML names.private static short
NAMES_UPPERCASE
Uppercase HTML names.private short
namesElems_
Modify HTML element names.private NamespaceBinder.NamespaceSupport
namespaceContext_
Namespace context.private static java.lang.String
NAMESPACES
Namespaces.private boolean
namespaces_
Namespaces.private static java.lang.String
NAMESPACES_URI
Namespaces URI.private java.lang.String
namespacesURI_
Namespaces URI.private static java.lang.String
OVERRIDE_NAMESPACES
Override namespace binding URI.private boolean
overrideNamespaces_
Override namespaces.private static java.lang.Object[]
PROPERTY_DEFAULTS
Property defaults.private QName
qName_
QName.private static java.lang.String[]
RECOGNIZED_FEATURES
Recognized features.private static java.lang.String[]
RECOGNIZED_PROPERTIES
Recognized properties.static java.lang.String
XHTML_1_0_URI
XHTML 1.0 namespace URI (http://www.w3.org/1999/xhtml).static java.lang.String
XML_URI
XML namespace URI (http://www.w3.org/XML/1998/namespace).static java.lang.String
XMLNS_URI
XMLNS namespace URI (http://www.w3.org/2000/xmlns/).
-
Constructor Summary
Constructors Constructor Description NamespaceBinder(HTMLConfiguration htmlConfiguration)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
bindNamespaces(QName element, XMLAttributes attrs)
void
emptyElement(QName element, XMLAttributes attrs, Augmentations augs)
Empty element.void
endElement(QName element, Augmentations augs)
End element.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.protected static short
getNamesValue(java.lang.String value)
java.lang.Object
getPropertyDefault(java.lang.String propertyId)
Returns the default value 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
modifyName(java.lang.String name, short mode)
void
reset(XMLComponentManager manager)
Resets the component.void
startDocument(XMLLocator locator, java.lang.String encoding, NamespaceContext nscontext, Augmentations augs)
Start document.void
startElement(QName element, XMLAttributes attrs, Augmentations augs)
Start element.-
Methods inherited from class org.htmlunit.cyberneko.filters.DefaultFilter
characters, comment, doctypeDecl, endCDATA, endDocument, getDocumentHandler, getDocumentSource, merge, processingInstruction, setDocumentHandler, setDocumentSource, setFeature, setProperty, startCDATA, xmlDecl
-
-
-
-
Field Detail
-
XHTML_1_0_URI
public static final java.lang.String XHTML_1_0_URI
XHTML 1.0 namespace URI (http://www.w3.org/1999/xhtml).- See Also:
- Constant Field Values
-
XML_URI
public static final java.lang.String XML_URI
XML namespace URI (http://www.w3.org/XML/1998/namespace).- See Also:
- Constant Field Values
-
XMLNS_URI
public static final java.lang.String XMLNS_URI
XMLNS namespace URI (http://www.w3.org/2000/xmlns/).- See Also:
- Constant Field Values
-
NAMESPACES
private static final java.lang.String NAMESPACES
Namespaces.- See Also:
- Constant Field Values
-
OVERRIDE_NAMESPACES
private static final java.lang.String OVERRIDE_NAMESPACES
Override namespace binding URI.- See Also:
- Constant Field Values
-
INSERT_NAMESPACES
private static final java.lang.String INSERT_NAMESPACES
Insert namespace binding URIs.- See Also:
- Constant Field Values
-
RECOGNIZED_FEATURES
private static final java.lang.String[] RECOGNIZED_FEATURES
Recognized features.
-
FEATURE_DEFAULTS
private static final java.lang.Boolean[] FEATURE_DEFAULTS
Feature defaults.
-
NAMES_ELEMS
private static final java.lang.String NAMES_ELEMS
Modify HTML element names: { "upper", "lower", "default" }.- See Also:
- Constant Field Values
-
NAMESPACES_URI
private static final java.lang.String NAMESPACES_URI
Namespaces URI.- See Also:
- Constant Field Values
-
RECOGNIZED_PROPERTIES
private static final java.lang.String[] RECOGNIZED_PROPERTIES
Recognized properties.
-
PROPERTY_DEFAULTS
private static final java.lang.Object[] PROPERTY_DEFAULTS
Property defaults.
-
NAMES_NO_CHANGE
private static final short NAMES_NO_CHANGE
Don't modify HTML names.- See Also:
- Constant Field Values
-
NAMES_UPPERCASE
private static final short NAMES_UPPERCASE
Uppercase HTML names.- See Also:
- Constant Field Values
-
NAMES_LOWERCASE
private static final short NAMES_LOWERCASE
Lowercase HTML names.- See Also:
- Constant Field Values
-
namespaces_
private boolean namespaces_
Namespaces.
-
overrideNamespaces_
private boolean overrideNamespaces_
Override namespaces.
-
insertNamespaces_
private boolean insertNamespaces_
Insert namespaces.
-
namesElems_
private short namesElems_
Modify HTML element names.
-
namespacesURI_
private java.lang.String namespacesURI_
Namespaces URI.
-
namespaceContext_
private final NamespaceBinder.NamespaceSupport namespaceContext_
Namespace context.
-
qName_
private final QName qName_
QName.
-
htmlConfiguration_
private final HTMLConfiguration htmlConfiguration_
-
-
Constructor Detail
-
NamespaceBinder
public NamespaceBinder(HTMLConfiguration htmlConfiguration)
-
-
Method Detail
-
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
- Overrides:
getRecognizedFeatures
in classDefaultFilter
- 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
- Overrides:
getFeatureDefault
in classDefaultFilter
- 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
- Overrides:
getRecognizedProperties
in classDefaultFilter
- 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 value 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
- Overrides:
getPropertyDefault
in classDefaultFilter
- 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 manager) 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
- Overrides:
reset
in classDefaultFilter
- Parameters:
manager
- The component manager.- Throws:
XNIException
- Thrown by component on initialization error.XMLConfigurationException
-
startDocument
public void startDocument(XMLLocator locator, java.lang.String encoding, NamespaceContext nscontext, Augmentations augs) throws XNIException
Start document.- Specified by:
startDocument
in interfaceXMLDocumentHandler
- Overrides:
startDocument
in classDefaultFilter
- 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.
-
startElement
public void startElement(QName element, XMLAttributes attrs, Augmentations augs) throws XNIException
Start element.- Specified by:
startElement
in interfaceXMLDocumentHandler
- Overrides:
startElement
in classDefaultFilter
- Parameters:
element
- The name of the element.attrs
- 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 attrs, Augmentations augs) throws XNIException
Empty element.- Specified by:
emptyElement
in interfaceXMLDocumentHandler
- Overrides:
emptyElement
in classDefaultFilter
- Parameters:
element
- The name of the element.attrs
- The element attributes.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
- Overrides:
endElement
in classDefaultFilter
- Parameters:
element
- The name of the element.augs
- Additional information that may include infoset augmentations- Throws:
XNIException
- Thrown by handler to signal an error.
-
getNamesValue
protected static short getNamesValue(java.lang.String value)
-
modifyName
protected static java.lang.String modifyName(java.lang.String name, short mode)
-
bindNamespaces
protected void bindNamespaces(QName element, XMLAttributes attrs)
-
-