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
nullprotected 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 ExtendedNamespaceContextnull 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 NamespaceContextpublic String getPrefix(String nsURI)
getPrefix in interface NamespaceContextpublic boolean isPrefixDeclared(String prefix)
isPrefixDeclared in interface ExtendedNamespaceContextprefix - The prefix to check.true if the prefix is declared in this context,
false otherwise.public Iterator getDeclaredPrefixes()
ExtendedNamespaceContextIterator of all namespace prefixes declared within this
context, irrespective of any ancestor contexts.getDeclaredPrefixes in interface ExtendedNamespaceContextIterator of prefix Strings.public int getDeclaredPrefixCount()
public Iterator getPrefixes()
ExtendedNamespaceContextIterator of all namespace prefixes in scope within this
context, including those inherited from ancestor contexts.getPrefixes in interface ExtendedNamespaceContextIterator of prefix Strings.public Iterator getPrefixes(String nsURI)
getPrefixes in interface NamespaceContextpublic String setDefaultNamespace(String nsURI)
nsURI - The default namespace URI.null if the
default prefix wasn't previously declared in this context.Copyright © 2019. All rights reserved.