public class Namespace
extends java.lang.Object
All XML names are eventually defined within some Namespace or other. All names with the distinguishing prefix "abc" are associated with the nearest enclosing Namespace that maps the local name "xmlns:abc" to some longer URI pathname. Names with no prefix are associated with the nearest default Namespace that maps the reserved local name "xmlns" to some longer URI pathname. If no matching Namespace is found in any enclosing scope, names belong to the empty Namespace.
Modifier and Type | Field and Description |
---|---|
private static java.util.Map<java.lang.String,Namespace> |
namespaces
The collection of all Namespace objects that were created during the
current Java runtime.
|
private Attribute |
node
The wrapped attribute defining this Namespace, which is an adapter
offering type-safe access to the local name and full identifier.
|
private static java.lang.String |
xmlns
The name of the default Namespace, used in comparisons.
|
Modifier | Constructor and Description |
---|---|
private |
Namespace(Attribute node)
Creates a Namespace by wrapping an Attribute.
|
Modifier and Type | Method and Description |
---|---|
static Namespace |
createNamespace()
Factory method for creating the empty Namespace.
|
static Namespace |
createNamespace(Attribute node)
The factory method for creating a unique Namespace from an Attribute.
|
static Namespace |
createNamespace(java.lang.String identifier,
java.lang.String pathname)
The factory method for creating a unique Namespace with an identifier
mapping to a pathname.
|
java.lang.String |
getIdentifier()
Returns the full local identifier of this Namespace, including any
'xmlns' prefix and short name.
|
java.lang.String |
getName()
Returns the short local name of this Namespace, used as a prefix by
Elements in this Namespace.
|
java.lang.String |
getPathname()
Returns the global pathname of this Namespace, a unique identifier.
|
java.net.URI |
getURI()
Returns the URI corresponding to the global pathname, which defines
this Namespace.
|
boolean |
isDefault()
Reports whether this Namespace is a default Namespace.
|
boolean |
isEmpty()
Reports whether this Namespace is the empty Namespace.
|
private static java.util.Map<java.lang.String,Namespace> namespaces
private static java.lang.String xmlns
private Attribute node
private Namespace(Attribute node) throws SemanticError
node
- the Attribute.SemanticError
- if the Attribute does not define a namespace.public static Namespace createNamespace()
public static Namespace createNamespace(Attribute node) throws SemanticError
node
- the Attribute.SemanticError
- if the Attribute does not define a Namespace.public static Namespace createNamespace(java.lang.String identifier, java.lang.String pathname) throws SemanticError
identifier
- the namespace identifier.pathname
- the URI pathname.SemanticError
- if the identifier and pathname do not define a
well-formed Namespace.public java.lang.String getName()
public java.lang.String getIdentifier()
public java.lang.String getPathname()
public java.net.URI getURI()
public boolean isDefault()
public boolean isEmpty()