Package org.opensaml.core.xml
Class NamespaceManager
java.lang.Object
org.opensaml.core.xml.NamespaceManager
A class which is responsible for managing XML namespace-related data for an
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.
-
Field Summary
FieldsModifier and TypeFieldDescriptionRegistered namespaces of attribute names.Registered namespaces of attribute values.private Namespace
Registered namespaces of content values.Explicitly declared namespaces.static final String
The token used to represent the default namespace ingetNonVisibleNamespacePrefixes()
.private Namespace
XMLObject name namespace.private Namespace
XMLObject type namespace.private final XMLObject
The owning XMLObject.private static final Namespace
The 'xml' namespace.private static final Namespace
The 'xsi' namespace. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate 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
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 inregisterAttributeValue(String, QName)
andderegisterAttributeValue(String)
.Get the set of all namespaces which are in scope within the subtree rooted at the owning XMLObject.private Namespace
Return a Namespace instance representing the namespace of the element name.private Namespace
Return a Namespace instance representing the namespace of the element type, if known.Get the set of namespace declarations registered on the owning XMLObject.Get the set of namespaces currently in use on the owning XMLObject.Get the set of non-visibly used namespaces used on the owning XMLObject (only the owner, not the owner's children).Obtain the set of namespace prefixes used in a non-visible manner on owning XMLObject and its children.Obtain the set of namespaces used in a non-visible manner on owning XMLObject and its children.getOwner()
Get the owning XMLObject instance.Get the set of namespaces which are currently visibly-used on the owning XMLObject (only the owner, not its children).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.
-
Field Details
-
DEFAULT_NS_TOKEN
The token used to represent the default namespace ingetNonVisibleNamespacePrefixes()
.- See Also:
-
XML_NAMESPACE
The 'xml' namespace. -
XSI_NAMESPACE
The 'xsi' namespace. -
owner
The owning XMLObject. -
elementName
XMLObject name namespace. -
elementType
XMLObject type namespace. -
decls
Explicitly declared namespaces. -
attrNames
Registered namespaces of attribute names. -
attrValues
Registered namespaces of attribute values. -
contentValue
Registered namespaces of content values.
-
-
Constructor Details
-
NamespaceManager
Constructor.- Parameters:
owningObject
- the XMLObject whose namespace info is to be managed
-
-
Method Details
-
generateAttributeID
From a QName representing a qualified attribute name, generate an attribute ID suitable for use inregisterAttributeValue(String, QName)
andderegisterAttributeValue(String)
.- Parameters:
name
- attribute name as a QName- Returns:
- a string attribute ID
-
getOwner
Get the owning XMLObject instance.- Returns:
- the owning XMLObject
-
getNamespaces
Get the set of namespaces currently in use on the owning XMLObject.- Returns:
- the unmodifiable set of namespaces
-
registerNamespaceDeclaration
Register a namespace declaration.- Parameters:
namespace
- the namespace to register
-
deregisterNamespaceDeclaration
Deregister a namespace declaration.- Parameters:
namespace
- the namespace to deregister
-
getNamespaceDeclarations
Get the set of namespace declarations registered on the owning XMLObject.- Returns:
- the set of namespace declarations
-
registerAttributeName
Register a namespace-qualified attribute name.- Parameters:
attributeName
- the attribute name to register
-
deregisterAttributeName
Deregister a namespace-qualified attribute name.- Parameters:
attributeName
- the attribute name to deregister
-
registerAttributeValue
Register a QName attribute value.- Parameters:
attributeID
- unique identifier for the attribute within the XMLObject's content modelattributeValue
- the QName value to register
-
deregisterAttributeValue
Deregister a QName attribute value.- Parameters:
attributeID
- unique identifier for the attribute within the XMLObject's content model
-
registerContentValue
Register a QName element content value.- Parameters:
content
- the QName value to register
-
deregisterContentValue
public void deregisterContentValue()Deregister a QName content value. -
getNonVisibleNamespacePrefixes
Obtain the set of namespace prefixes used in a non-visible manner on owning XMLObject and its children.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.
- Returns:
- the set of non-visibly used namespace prefixes
-
getNonVisibleNamespaces
Obtain the set of namespaces used in a non-visible manner on owning XMLObject and its children.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.
- Returns:
- the set of non-visibly used namespaces
-
getAllNamespacesInSubtreeScope
Get the set of all namespaces which are in scope within the subtree rooted at the owning XMLObject.- Returns:
- set of all namespaces in scope for the owning object
-
registerElementName
Register the owning XMLObject's element name.- Parameters:
name
- the element name to register
-
registerElementType
Register the owning XMLObject's element type, if explicitly declared via an xsi:type.- Parameters:
type
- the element type to register
-
getElementNameNamespace
Return a Namespace instance representing the namespace of the element name.- Returns:
- the element name's namespace
-
getElementTypeNamespace
Return a Namespace instance representing the namespace of the element type, if known.- Returns:
- the element type's namespace
-
buildNamespace
- Parameters:
name
- the source QName- Returns:
- a Namespace built using the information in the QName
-
addNamespace
Add a Namespace to a set of Namespaces. Namespaces with identical URI and prefix will be treated as equivalent.- Parameters:
namespaces
- the set of namespacesnewNamespace
- the namespace to add to the set
-
removeNamespace
Remove a Namespace from a set of Namespaces.- Parameters:
namespaces
- the set of namespacesoldNamespace
- the namespace to add to the set
-
mergeNamespaceCollections
Merge 2 or more Namespace collections into a single set.- Parameters:
namespaces
- list of Namespaces to merge- Returns:
- the a new set of merged Namespaces
-
getVisibleNamespaces
Get the set of namespaces which are currently visibly-used on the owning XMLObject (only the owner, not its children).- Returns:
- the set of visibly-used namespaces
-
getNonVisibleNamespaceCandidates
Get the set of non-visibly used namespaces used on the owning XMLObject (only the owner, not the owner's children).- Returns:
- the set of non-visibly-used namespaces
-
addPrefixes
Add the prefixes from a collection of namespaces to a set of prefixes. The value used to represent the default namespace will be normalized toDEFAULT_NS_TOKEN
.- Parameters:
prefixes
- the set of prefixes to which to addnamespaces
- the source set of Namespaces
-
checkQName
Check whether the supplied QName contains non-empty namespace info and should be managed by the namespace manager.- Parameters:
name
- the QName to check- Returns:
- true if the QName contains non-empty namespace info and should be managed, false otherwise
-