javanet.staxutils
public class SimpleNamespaceContext extends Object implements ExtendedNamespaceContext, StaticNamespaceContext
Modifier and Type | Field and Description |
---|---|
protected Map |
namespaces
map containing bound namespaces, keyed by their prefix.
|
protected NamespaceContext |
parent
The parent context, which may be
null |
Constructor and Description |
---|
SimpleNamespaceContext()
Constructs a SimpleNamespaceContext with no parent context or namespace
declarations.
|
SimpleNamespaceContext(Map namespaces)
Constructs a SimpleNamespaceContext with no parent context that contains
the specified prefixes.
|
SimpleNamespaceContext(NamespaceContext parent)
Constructs an empty SimpleNamespaceContext with the given parent.
|
SimpleNamespaceContext(NamespaceContext parent,
Map namespaces)
Constructs an empty SimpleNamespaceContext with the given parent.
|
Modifier and Type | Method and Description |
---|---|
int |
getDeclaredPrefixCount()
Returns the number of namespace prefixes declared in this context.
|
Iterator |
getDeclaredPrefixes()
Returns an
Iterator of all namespace prefixes declared within
this context, irrespective of any ancestor contexts. |
String |
getNamespaceURI(String prefix) |
NamespaceContext |
getParent()
Returns a reference to the parent of this context.
|
String |
getPrefix(String nsURI) |
Iterator |
getPrefixes()
Returns an
Iterator of all namespace prefixes in scope within this
context, including those inherited from ancestor contexts. |
Iterator |
getPrefixes(String nsURI) |
boolean |
isPrefixDeclared(String prefix)
Determines if the specified prefix is declared within this context,
irrespective of any ancestor contexts.
|
boolean |
isRootContext()
Determines if this is a root context.
|
String |
setDefaultNamespace(String nsURI)
Sets the default namespace in this context.
|
void |
setParent(NamespaceContext parent)
Sets the parent context used to inherit namespace bindings.
|
String |
setPrefix(String prefix,
String nsURI)
Declares a namespace binding in this context.
|
protected NamespaceContext parent
null
protected Map namespaces
getPrefix(String)
always returns the same
prefix, unless that prefix is removed.public SimpleNamespaceContext()
public SimpleNamespaceContext(Map namespaces)
namespaces
- A Map of namespace URIs, keyed by their prefixes.public SimpleNamespaceContext(NamespaceContext parent)
parent
- The parent context.public SimpleNamespaceContext(NamespaceContext parent, Map namespaces)
parent
- The parent context.namespaces
- A Map of namespace URIs, keyed by their prefixes.public NamespaceContext getParent()
getParent
in interface ExtendedNamespaceContext
null
if this is a root
context.public void setParent(NamespaceContext parent)
parent
- The new parent context.public boolean isRootContext()
true
if this is a root context, false
otherwise.public String getNamespaceURI(String prefix)
getNamespaceURI
in interface NamespaceContext
public String getPrefix(String nsURI)
getPrefix
in interface NamespaceContext
public boolean isPrefixDeclared(String prefix)
isPrefixDeclared
in interface ExtendedNamespaceContext
prefix
- The prefix to check.true
if the prefix is declared in this context,
false
otherwise.public Iterator getDeclaredPrefixes()
ExtendedNamespaceContext
Iterator
of all namespace prefixes declared within
this context, irrespective of any ancestor contexts.getDeclaredPrefixes
in interface ExtendedNamespaceContext
Iterator
of prefix String
s.public int getDeclaredPrefixCount()
public Iterator getPrefixes()
ExtendedNamespaceContext
Iterator
of all namespace prefixes in scope within this
context, including those inherited from ancestor contexts.getPrefixes
in interface ExtendedNamespaceContext
Iterator
of prefix String
s.public Iterator getPrefixes(String nsURI)
getPrefixes
in interface NamespaceContext
public String setDefaultNamespace(String nsURI)
nsURI
- The default namespace URI.null
if
the default prefix wasn't previously declared in this context.