Package org.apache.axiom.util.namespace
Class ScopedNamespaceContext
java.lang.Object
org.apache.axiom.util.namespace.AbstractNamespaceContext
org.apache.axiom.util.namespace.ScopedNamespaceContext
- All Implemented Interfaces:
NamespaceContext
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected StringdoGetNamespaceURI(String prefix) Get namespace URI bound to a prefix in the current scope.protected StringdoGetPrefix(String namespaceURI) Get prefix bound to namespace URI in the current scope.doGetPrefixes(String namespaceURI) Get all prefixes bound to a namespace URI in the current scope.voidendScope()End the current scope and restore the scope in which the current scope was nested.intGet the number of namespace bindings defined in this context, in all scopes.intGet the index of the first namespace binding defined in the current scope.getNamespaceURI(int index) Get the namespace URI of the binding with the given index.getPrefix(int index) Get the prefix of the binding with the given index.voidDefine a prefix binding in the current scope.voidStart a new scope.Methods inherited from class org.apache.axiom.util.namespace.AbstractNamespaceContext
getNamespaceURI, getPrefix, getPrefixes
-
Constructor Details
-
ScopedNamespaceContext
public ScopedNamespaceContext()
-
-
Method Details
-
setPrefix
Define a prefix binding in the current scope. It will be visible in the current scope as well as each nested scope, unless the prefix is bound to a different namespace URI in that scope.- Parameters:
prefix- the prefix to bind or the empty string to set the default namespace; may not benullnamespaceURI- the corresponding namespace URI; may not benull
-
startScope
public void startScope()Start a new scope. Since scopes are nested, this will not end the current scope. -
endScope
public void endScope()End the current scope and restore the scope in which the current scope was nested. This will remove all prefix bindings declared since the corresponding invocation of thestartScope()method. -
getBindingsCount
public int getBindingsCount()Get the number of namespace bindings defined in this context, in all scopes. This number increases every timesetPrefix(String, String)is called. It decreases whenendScope()is called (unless no bindings have been added in the current scope).- Returns:
- the namespace binding count
-
getFirstBindingInCurrentScope
public int getFirstBindingInCurrentScope()Get the index of the first namespace binding defined in the current scope. Together withgetBindingsCount()this method can be used to iterate over the namespace bindings defined in the current scope.- Returns:
- the index of the first namespace binding defined in the current scope
-
getPrefix
Get the prefix of the binding with the given index.- Parameters:
index- the index of the binding- Returns:
- the prefix
-
getNamespaceURI
Get the namespace URI of the binding with the given index.- Parameters:
index- the index of the binding- Returns:
- the namespace URI
-
doGetNamespaceURI
Description copied from class:AbstractNamespaceContextGet namespace URI bound to a prefix in the current scope. The contract of this method is the same asNamespaceContext.getNamespaceURI(String), except that the implementation is not required to handle the implicit namespace bindings.- Specified by:
doGetNamespaceURIin classAbstractNamespaceContext- Parameters:
prefix- prefix to look up- Returns:
- namespace URI bound to prefix in the current scope
-
doGetPrefix
Description copied from class:AbstractNamespaceContextGet prefix bound to namespace URI in the current scope. The contract of this method is the same asNamespaceContext.getPrefix(String), except that the implementation is not required to handle the implicit namespace bindings.- Specified by:
doGetPrefixin classAbstractNamespaceContext- Parameters:
namespaceURI- URI of namespace to lookup- Returns:
- prefix bound to namespace URI in current context
-
doGetPrefixes
Description copied from class:AbstractNamespaceContextGet all prefixes bound to a namespace URI in the current scope. The contract of this method is the same asNamespaceContext.getPrefixes(String), except that the implementation is not required to handle the implicit namespace bindings.- Specified by:
doGetPrefixesin classAbstractNamespaceContext- Parameters:
namespaceURI- URI of namespace to lookup- Returns:
- iterator for all prefixes bound to the namespace URI in the current scope
-