public class ScopedNamespaceContext extends AbstractNamespaceContext
NamespaceContext
implementation that supports nested scopes. A scope is typically
associated with a start tag / end tag pair. The implementation takes care of correctly
handling masked namespace bindings. Masking occurs when the same prefix is bound to a different
namespace URI in a nested scope.Constructor and Description |
---|
ScopedNamespaceContext() |
Modifier and Type | Method and Description |
---|---|
protected String |
doGetNamespaceURI(String prefix)
Get namespace URI bound to a prefix in the current scope.
|
protected String |
doGetPrefix(String namespaceURI)
Get prefix bound to namespace URI in the current scope.
|
protected Iterator |
doGetPrefixes(String namespaceURI)
Get all prefixes bound to a namespace URI in the current scope.
|
void |
endScope()
End the current scope and restore the scope in which the current scope was nested.
|
int |
getBindingsCount()
Get the number of namespace bindings defined in this context, in all scopes.
|
int |
getFirstBindingInCurrentScope()
Get the index of the first namespace binding defined in the current scope.
|
String |
getNamespaceURI(int index)
Get the namespace URI of the binding with the given index.
|
String |
getPrefix(int index)
Get the prefix of the binding with the given index.
|
void |
setPrefix(String prefix,
String namespaceURI)
Define a prefix binding in the current scope.
|
void |
startScope()
Start a new scope.
|
getNamespaceURI, getPrefix, getPrefixes
public void setPrefix(String prefix, String namespaceURI)
prefix
- the prefix to bind or the empty string to set the default namespace; may not
be null
namespaceURI
- the corresponding namespace URI; may not be null
public void startScope()
public void endScope()
startScope()
method.public int getBindingsCount()
setPrefix(String, String)
is called. It decreases when
endScope()
is called (unless no bindings have been added in the current scope).public int getFirstBindingInCurrentScope()
getBindingsCount()
this method can be used to iterate over the namespace bindings
defined in the current scope.public String getPrefix(int index)
index
- the index of the bindingpublic String getNamespaceURI(int index)
index
- the index of the bindingprotected String doGetNamespaceURI(String prefix)
AbstractNamespaceContext
NamespaceContext.getNamespaceURI(String)
, except that the
implementation is not required to handle the implicit namespace bindings.doGetNamespaceURI
in class AbstractNamespaceContext
prefix
- prefix to look upprotected String doGetPrefix(String namespaceURI)
AbstractNamespaceContext
NamespaceContext.getPrefix(String)
,
except that the implementation is not required to handle the implicit
namespace bindings.doGetPrefix
in class AbstractNamespaceContext
namespaceURI
- URI of namespace to lookupprotected Iterator doGetPrefixes(String namespaceURI)
AbstractNamespaceContext
NamespaceContext.getPrefixes(String)
, except that the
implementation is not required to handle the implicit namespace bindings.doGetPrefixes
in class AbstractNamespaceContext
namespaceURI
- URI of namespace to lookupCopyright © The Apache Software Foundation. All Rights Reserved.