org.apache.axiom.util.namespace
Class ScopedNamespaceContext

java.lang.Object
  extended by org.apache.axiom.util.namespace.AbstractNamespaceContext
      extended by org.apache.axiom.util.namespace.ScopedNamespaceContext
All Implemented Interfaces:
NamespaceContext

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 Summary
ScopedNamespaceContext()
           
 
Method Summary
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.
 void setPrefix(String prefix, String namespaceURI)
          Define a prefix binding in the current scope.
 void startScope()
          Start a new scope.
 
Methods inherited from class org.apache.axiom.util.namespace.AbstractNamespaceContext
getNamespaceURI, getPrefix, getPrefixes
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ScopedNamespaceContext

public ScopedNamespaceContext()
Method Detail

setPrefix

public void setPrefix(String prefix,
                      String namespaceURI)
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 be null
namespaceURI - the corresponding namespace URI; may not be null

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 the startScope() method.


doGetNamespaceURI

protected String doGetNamespaceURI(String prefix)
Description copied from class: AbstractNamespaceContext
Get namespace URI bound to a prefix in the current scope. The contract of this method is the same as NamespaceContext.getNamespaceURI(String), except that the implementation is not required to handle the implicit namespace bindings.

Specified by:
doGetNamespaceURI in class AbstractNamespaceContext
Parameters:
prefix - prefix to look up
Returns:
namespace URI bound to prefix in the current scope

doGetPrefix

protected String doGetPrefix(String namespaceURI)
Description copied from class: AbstractNamespaceContext
Get prefix bound to namespace URI in the current scope. The contract of this method is the same as NamespaceContext.getPrefix(String), except that the implementation is not required to handle the implicit namespace bindings.

Specified by:
doGetPrefix in class AbstractNamespaceContext
Parameters:
namespaceURI - URI of namespace to lookup
Returns:
prefix bound to namespace URI in current context

doGetPrefixes

protected Iterator doGetPrefixes(String namespaceURI)
Description copied from class: AbstractNamespaceContext
Get all prefixes bound to a namespace URI in the current scope. The contract of this method is the same as NamespaceContext.getPrefixes(String), except that the implementation is not required to handle the implicit namespace bindings.

Specified by:
doGetPrefixes in class AbstractNamespaceContext
Parameters:
namespaceURI - URI of namespace to lookup
Returns:
iterator for all prefixes bound to the namespace URI in the current scope


Copyright © 2004-2012 The Apache Software Foundation. All Rights Reserved.