public final class NSAwareAttributeMatcher extends Object implements AttributeMatcher
AttributeMatcher implementation that matches attributes based on their namespace URI and
local name. Parameters are defined as follows:
namespaceURI
name
value
prefix
NamespaceDeclarationMatcher can be used).| Constructor and Description |
|---|
NSAwareAttributeMatcher(Semantics semantics,
boolean matchNSUnawareAttributes,
boolean updatePrefix)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
CoreAttribute |
createAttribute(CoreElement element,
String namespaceURI,
String name,
String prefix,
String value)
Create a new attribute node.
|
String |
getName(CoreAttribute attr)
Get the name parameter for an existing attribute.
|
String |
getNamespaceURI(CoreAttribute attr)
Get the namespaceURI parameter for an existing attribute.
|
boolean |
matches(CoreAttribute attr,
String namespaceURI,
String name)
Check if the given attribute matches.
|
void |
update(CoreAttribute attr,
String prefix,
String value)
Update an existing attribute.
|
public NSAwareAttributeMatcher(Semantics semantics, boolean matchNSUnawareAttributes, boolean updatePrefix)
semantics - Specifies the Semantics to be used by
update(CoreAttribute, String, String).matchNSUnawareAttributes - Specifies if CoreNSUnawareAttribute instances can also be matched. Only
applies to the case where namespaceURI is the empty string.updatePrefix - Specifies if the prefix of an existing attribute should be updated (based on the
value of the prefix parameter. If this is false, then
prefix is only used when creating new attributes and prefixes of
existing attributes are preserved (i.e. only their value is updated).public boolean matches(CoreAttribute attr, String namespaceURI, String name)
AttributeMatchernamespaceURI and
name parameters are those passed to
CoreElement.coreGetAttribute(AttributeMatcher, String, String) or
CoreElement.coreSetAttribute(AttributeMatcher, String, String, String, String), or
they are determined by the return values of AttributeMatcher.getNamespaceURI(CoreAttribute) and
AttributeMatcher.getName(CoreAttribute) if
CoreElement.coreSetAttribute(AttributeMatcher, CoreAttribute, Semantics)
is used. It is
not required that these parameters strictly represent the namespace URI and local name of the
attribute. Their exact meaning is defined by the particular AttributeMatcher
implementation.matches in interface AttributeMatcherattr - the attribute to checknamespaceURI - see abovename - see abovetrue if the attribute matches, false otherwisepublic String getNamespaceURI(CoreAttribute attr)
AttributeMatcherCoreElement.coreSetAttribute(AttributeMatcher, CoreAttribute, Semantics)
which passes its return value as parameter to AttributeMatcher.matches(CoreAttribute, String, String).getNamespaceURI in interface AttributeMatcherattr - the attributeAttributeMatcher.matches(CoreAttribute, String, String)public String getName(CoreAttribute attr)
AttributeMatcherCoreElement.coreSetAttribute(AttributeMatcher, CoreAttribute, Semantics)
which passes its return value as parameter to AttributeMatcher.matches(CoreAttribute, String, String).getName in interface AttributeMatcherattr - the attributeAttributeMatcher.matches(CoreAttribute, String, String)public CoreAttribute createAttribute(CoreElement element, String namespaceURI, String name, String prefix, String value)
AttributeMatchernamespaceURI, name,
prefix and value parameters are those passed to
CoreElement.coreSetAttribute(AttributeMatcher, String, String, String, String).createAttribute in interface AttributeMatcherelement - the instance to be used to invoke CoreNode.coreCreateNode(Class)namespaceURI - see abovename - see aboveprefix - see abovevalue - see abovepublic void update(CoreAttribute attr, String prefix, String value)
AttributeMatcherprefix and value
parameters are those passed to
CoreElement.coreSetAttribute(AttributeMatcher, String, String, String, String).update in interface AttributeMatcherattr - the attribute to updateprefix - see abovevalue - see aboveCopyright © The Apache Software Foundation. All Rights Reserved.