org.exolab.castor.xml.parsing
Class NamespaceHandling

java.lang.Object
  extended by org.exolab.castor.xml.parsing.NamespaceHandling

public class NamespaceHandling
extends java.lang.Object

This class is used by the UnmarshalHandler to handle name spaces. It manages a stack of name spaces, keeps track of when an new name space scope is needed and maps name space URIs to package names.

Since:
1.3.2
Author:
Philipp Erlacher

Constructor Summary
NamespaceHandling()
           
 
Method Summary
 void addDefaultNamespace(java.lang.String namespaceURI)
          Binds the namespaceURI to the default namespace.
 void addNamespace(java.lang.String prefix, java.lang.String namespaceURI)
          Binds the namespaceURI to the prefix
 void addNamespaceToPackageMapping(java.lang.String nsURI, java.lang.String packageName)
          Adds a mapping from the given namespace URI to the given package name.
 void createNamespace()
          Creates a new name space.
 java.lang.String getDefaultNamespaceURI()
          Gets the namespace URI that is bound to the default name space.
 java.lang.String getMappedPackage(java.lang.String namespace)
          Looks up the package name from the given namespace URI.
 java.lang.String getNamespacePrefix(java.lang.String namespaceURI)
          Gets the prefix that is bound to a namespaceURI.
 NamespacesStack getNamespaceStack()
          Returns the namespace stack.
 java.lang.String getNamespaceURI(java.lang.String prefix)
          Gets the namespaceURI that is bound to a prefix.
 boolean isNewNamespaceScopeNecessary()
          Indicates whether a new name space scope is needed.
 void processNamespaces(XMLClassDescriptor classDesc, java.lang.Object object)
          Saves local namespace declarations to the object model if necessary.
 void removeCurrentNamespaceInstance()
          Pops the current namespace instance
 java.lang.Object resolveNamespace(java.lang.Object value)
          Extracts the prefix and resolves it to it's associated namespace.
 void setNewNamespaceScopeNecessary(boolean value)
           
 void startNamespaceScope()
          Starts a new name space scope, and resets the corresponding flag.
 void stopNamespaceScope()
          Stops a name space scope, and resets the corresponding flag to false.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NamespaceHandling

public NamespaceHandling()
Method Detail

addNamespaceToPackageMapping

public void addNamespaceToPackageMapping(java.lang.String nsURI,
                                         java.lang.String packageName)
Adds a mapping from the given namespace URI to the given package name.

Parameters:
nsURI - the namespace URI to map from.
packageName - the package name to map to.

getMappedPackage

public java.lang.String getMappedPackage(java.lang.String namespace)
Looks up the package name from the given namespace URI.

Parameters:
namespace - the namespace URI to lookup
Returns:
the package name or null.

processNamespaces

public void processNamespaces(XMLClassDescriptor classDesc,
                              java.lang.Object object)
Saves local namespace declarations to the object model if necessary.

Parameters:
classDesc - the current ClassDescriptor.
object - the Object of the current state

resolveNamespace

public java.lang.Object resolveNamespace(java.lang.Object value)
                                  throws org.xml.sax.SAXException
Extracts the prefix and resolves it to it's associated namespace. If the prefix is 'xml', then no resolution will occur, however in all other cases the resolution will change the prefix:value as {NamespaceURI}value

Parameters:
value - the QName to resolve.
Returns:
Throws:
org.xml.sax.SAXException - if the nammespace associated with the prefix is null

removeCurrentNamespaceInstance

public void removeCurrentNamespaceInstance()
Pops the current namespace instance


addDefaultNamespace

public void addDefaultNamespace(java.lang.String namespaceURI)
Binds the namespaceURI to the default namespace.

Parameters:
namespaceURI - Namespace URI

addNamespace

public void addNamespace(java.lang.String prefix,
                         java.lang.String namespaceURI)
Binds the namespaceURI to the prefix

Parameters:
prefix - XML name space prefix
namespaceURI - XML name space URI.

getNamespacePrefix

public java.lang.String getNamespacePrefix(java.lang.String namespaceURI)
Gets the prefix that is bound to a namespaceURI.

Parameters:
namespaceURI - the namespaceURI to get the prefix from
Returns:
prefix

getNamespaceURI

public java.lang.String getNamespaceURI(java.lang.String prefix)
Gets the namespaceURI that is bound to a prefix.

Parameters:
prefix - the prefix to get the namespaceURI from
Returns:
namespaceURI The corresponding namespace URI.

getDefaultNamespaceURI

public java.lang.String getDefaultNamespaceURI()
Gets the namespace URI that is bound to the default name space.

Returns:
namespaceURI The namespace URI bound to the default namespace.

createNamespace

public void createNamespace()
Creates a new name space.


getNamespaceStack

public NamespacesStack getNamespaceStack()
Returns the namespace stack.

Returns:
the namespace stack.

isNewNamespaceScopeNecessary

public boolean isNewNamespaceScopeNecessary()
Indicates whether a new name space scope is needed.

Returns:
true if a new name space scope is necessary.

startNamespaceScope

public void startNamespaceScope()
Starts a new name space scope, and resets the corresponding flag.


stopNamespaceScope

public void stopNamespaceScope()
Stops a name space scope, and resets the corresponding flag to false.


setNewNamespaceScopeNecessary

public void setNewNamespaceScopeNecessary(boolean value)


Intalio Inc. (C) 1999-2008. All rights reserved http://www.intalio.com