public class NamespaceManager extends Object
XMLObject
.
Code which mutates the state of an XMLObject such that XML namespace-related data is also logically changed, should call the appropriate method, based on the type of change being made.
Modifier and Type | Field and Description |
---|---|
private Set<Namespace> |
attrNames
Registered namespaces of attribute names.
|
private Map<String,Namespace> |
attrValues
Registered namespaces of attribute values.
|
private Namespace |
contentValue
Registered namespaces of content values.
|
private Set<Namespace> |
decls
Explicitly declared namespaces.
|
static String |
DEFAULT_NS_TOKEN
The token used to represent the default namespace in
getNonVisibleNamespacePrefixes() . |
private Namespace |
elementName
XMLObject name namespace.
|
private Namespace |
elementType
XMLObject type namespace.
|
private XMLObject |
owner
The owning XMLObject.
|
private static Namespace |
XML_NAMESPACE
The 'xml' namespace.
|
private static Namespace |
XSI_NAMESPACE
The 'xsi' namespace.
|
Constructor and Description |
---|
NamespaceManager(XMLObject owningObject)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
private void |
addNamespace(Set<Namespace> namespaces,
Namespace newNamespace)
Add a Namespace to a set of Namespaces.
|
private void |
addPrefixes(Set<String> prefixes,
Collection<Namespace> namespaces)
Add the prefixes from a collection of namespaces to a set of prefixes.
|
private Namespace |
buildNamespace(QName name)
|
private boolean |
checkQName(QName name)
Check whether the supplied QName contains non-empty namespace info and should
be managed by the namespace manager.
|
void |
deregisterAttributeName(QName attributeName)
Deregister a namespace-qualified attribute name.
|
void |
deregisterAttributeValue(String attributeID)
Deregister a QName attribute value.
|
void |
deregisterContentValue()
Deregister a QName content value.
|
void |
deregisterNamespaceDeclaration(Namespace namespace)
Deregister a namespace declaration.
|
static String |
generateAttributeID(QName name)
From a QName representing a qualified attribute name, generate an attribute ID
suitable for use in
registerAttributeValue(String, QName)
and deregisterAttributeValue(String) . |
Set<Namespace> |
getAllNamespacesInSubtreeScope()
Get the set of all namespaces which are in scope within the subtree rooted
at the owning XMLObject.
|
private Namespace |
getElementNameNamespace()
Return a Namespace instance representing the namespace of the element name.
|
private Namespace |
getElementTypeNamespace()
Return a Namespace instance representing the namespace of the element type, if known.
|
Set<Namespace> |
getNamespaceDeclarations()
Get the set of namespace declarations registered on the owning XMLObject.
|
Set<Namespace> |
getNamespaces()
Get the set of namespaces currently in use on the owning XMLObject.
|
private Set<Namespace> |
getNonVisibleNamespaceCandidates()
Get the set of non-visibly used namespaces used on the owning XMLObject (only the owner,
not the owner's children).
|
Set<String> |
getNonVisibleNamespacePrefixes()
Obtain the set of namespace prefixes used in a non-visible manner on owning XMLObject
and its children.
|
Set<Namespace> |
getNonVisibleNamespaces()
Obtain the set of namespaces used in a non-visible manner on owning XMLObject
and its children.
|
XMLObject |
getOwner()
Get the owning XMLObject instance.
|
private Set<Namespace> |
getVisibleNamespaces()
Get the set of namespaces which are currently visibly-used on the owning XMLObject (only the owner,
not its children).
|
private Set<Namespace> |
mergeNamespaceCollections(Collection<Namespace>... namespaces)
Merge 2 or more Namespace collections into a single set.
|
void |
registerAttributeName(QName attributeName)
Register a namespace-qualified attribute name.
|
void |
registerAttributeValue(String attributeID,
QName attributeValue)
Register a QName attribute value.
|
void |
registerContentValue(QName content)
Register a QName element content value.
|
void |
registerElementName(QName name)
Register the owning XMLObject's element name.
|
void |
registerElementType(QName type)
Register the owning XMLObject's element type, if explicitly declared via an xsi:type.
|
void |
registerNamespaceDeclaration(Namespace namespace)
Register a namespace declaration.
|
private void |
removeNamespace(Set<Namespace> namespaces,
Namespace oldNamespace)
Remove a Namespace from a set of Namespaces.
|
public static final String DEFAULT_NS_TOKEN
getNonVisibleNamespacePrefixes()
.private static final Namespace XML_NAMESPACE
private static final Namespace XSI_NAMESPACE
private Namespace elementName
private Namespace elementType
@Nonnull private final Map<String,Namespace> attrValues
private Namespace contentValue
@Nonnull @NotEmpty public static String generateAttributeID(@Nonnull QName name)
registerAttributeValue(String, QName)
and deregisterAttributeValue(String)
.name
- attribute name as a QName@Nonnull public XMLObject getOwner()
@Nonnull public Set<Namespace> getNamespaces()
public void registerNamespaceDeclaration(@Nonnull Namespace namespace)
namespace
- the namespace to registerpublic void deregisterNamespaceDeclaration(@Nonnull Namespace namespace)
namespace
- the namespace to deregister@Nonnull public Set<Namespace> getNamespaceDeclarations()
public void registerAttributeName(@Nonnull QName attributeName)
attributeName
- the attribute name to registerpublic void deregisterAttributeName(@Nonnull QName attributeName)
attributeName
- the attribute name to deregisterpublic void registerAttributeValue(@Nonnull String attributeID, @Nonnull QName attributeValue)
attributeID
- unique identifier for the attribute within the XMLObject's content modelattributeValue
- the QName value to registerpublic void deregisterAttributeValue(@Nonnull String attributeID)
attributeID
- unique identifier for the attribute within the XMLObject's content modelpublic void registerContentValue(@Nonnull QName content)
content
- the QName value to registerpublic void deregisterContentValue()
@Nonnull public Set<String> getNonVisibleNamespacePrefixes()
The primary use case for this information is to support the inclusive prefixes information that may optionally be supplied as a part of XML exclusive canonicalization.
@Nonnull public Set<Namespace> getNonVisibleNamespaces()
The primary use case for this information is to support the inclusive prefixes information that may optionally be supplied as a part of XML exclusive canonicalization.
@Nonnull public Set<Namespace> getAllNamespacesInSubtreeScope()
public void registerElementName(@Nonnull QName name)
name
- the element name to registerpublic void registerElementType(@Nullable QName type)
type
- the element type to register@Nullable private Namespace getElementNameNamespace()
@Nullable private Namespace getElementTypeNamespace()
@Nonnull private Namespace buildNamespace(@Nonnull QName name)
name
- the source QNameprivate void addNamespace(@Nonnull Set<Namespace> namespaces, @Nullable Namespace newNamespace)
namespaces
- the set of namespacesnewNamespace
- the namespace to add to the setprivate void removeNamespace(@Nonnull Set<Namespace> namespaces, @Nullable Namespace oldNamespace)
namespaces
- the set of namespacesoldNamespace
- the namespace to add to the set@Nonnull private Set<Namespace> mergeNamespaceCollections(Collection<Namespace>... namespaces)
namespaces
- list of Namespaces to merge@Nonnull private Set<Namespace> getVisibleNamespaces()
@Nonnull private Set<Namespace> getNonVisibleNamespaceCandidates()
private void addPrefixes(@Nonnull Set<String> prefixes, @Nonnull Collection<Namespace> namespaces)
DEFAULT_NS_TOKEN
.prefixes
- the set of prefixes to which to addnamespaces
- the source set of Namespacesprivate boolean checkQName(@Nullable QName name)
name
- the QName to checkCopyright © 1999–2015 JBoss by Red Hat. All rights reserved.