edu.ksi.virtualclassroom.mappers.jaxb.xmlwrapper.impl.runtime
Class NamespaceContextImpl

java.lang.Object
  extended byedu.ksi.virtualclassroom.mappers.jaxb.xmlwrapper.impl.runtime.NamespaceContextImpl
All Implemented Interfaces:
javax.xml.namespace.NamespaceContext, NamespaceContext2

public class NamespaceContextImpl
extends java.lang.Object
implements NamespaceContext2

Implementation of the NamespaceContext2. This class also provides several utility methods for XMLSerializer-derived classes. The startElement method and the endElement method need to be called appropriately when used. See javadoc for those methods for details.

Version:
$Revision$
Author:
Administrator

Field Summary
private  java.util.Map decls
          Used during the collecting mode to sort out the namespace URIs we need for this element.
private  boolean inCollectingMode
          A flag that indicates the current mode of this object.
private  int iota
          Sequence generator.
private  com.sun.xml.bind.marshaller.NamespaceSupport nss
          Used to maintain association between prefixes and URIs.
private  com.sun.xml.bind.marshaller.NamespacePrefixMapper prefixMapper
          Assigns prefixes to URIs.
private  java.util.Map reverseDecls
          Field reverseDecls
 
Constructor Summary
NamespaceContextImpl(com.sun.xml.bind.marshaller.NamespacePrefixMapper _prefixMapper)
          Constructor for NamespaceContextImpl
 
Method Summary
 java.lang.String declareNamespace(java.lang.String namespaceUri, java.lang.String preferedPrefix, boolean requirePrefix)
          Declares a new namespace binding within the current context.
 void endElement()
          Ends the current element context and gets back to the parent context.
 void endNamespaceDecls()
          Reconciles the namespace URI/prefix mapping requests since the last startElement method invocation and finalizes them.
 com.sun.xml.bind.marshaller.NamespacePrefixMapper getNamespacePrefixMapper()
          Method getNamespacePrefixMapper
 java.lang.String getNamespaceURI(java.lang.String prefix)
          Obtains the namespace URI currently associated to the given prefix.
 java.lang.String getPrefix(java.lang.String namespaceUri)
          Method getPrefix
 java.util.Iterator getPrefixes(java.lang.String namespaceUri)
          Method getPrefixes
 void iterateDeclaredPrefixes(PrefixCallback callback)
          Iterates all newly declared namespace prefixes for this element.
 void startElement()
          Sets the current bindings aside and starts a new element context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

iota

private int iota
Sequence generator. Used as the last resort to generate unique prefix.


nss

private final com.sun.xml.bind.marshaller.NamespaceSupport nss
Used to maintain association between prefixes and URIs.


inCollectingMode

private boolean inCollectingMode
A flag that indicates the current mode of this object.


prefixMapper

private final com.sun.xml.bind.marshaller.NamespacePrefixMapper prefixMapper
Assigns prefixes to URIs. Can be null.


decls

private final java.util.Map decls
Used during the collecting mode to sort out the namespace URIs we need for this element. A map from prefixes to namespace URIs.


reverseDecls

private final java.util.Map reverseDecls
Field reverseDecls

Constructor Detail

NamespaceContextImpl

public NamespaceContextImpl(com.sun.xml.bind.marshaller.NamespacePrefixMapper _prefixMapper)
Constructor for NamespaceContextImpl

Parameters:
_prefixMapper - NamespacePrefixMapper
Method Detail

getNamespacePrefixMapper

public final com.sun.xml.bind.marshaller.NamespacePrefixMapper getNamespacePrefixMapper()
Method getNamespacePrefixMapper

Returns:
NamespacePrefixMapper

declareNamespace

public java.lang.String declareNamespace(java.lang.String namespaceUri,
                                         java.lang.String preferedPrefix,
                                         boolean requirePrefix)
Description copied from interface: NamespaceContext2
Declares a new namespace binding within the current context.

The prefix is automatically assigned by MarshallingContext. If a given namespace URI is already declared, nothing happens.

It is NOT an error to declare the same namespace URI more than once.

For marshalling to work correctly, all namespace bindings for an element must be declared between its startElement method and its endAttributes event. Calling the same method with the same parameter between the endAttributes and the endElement returns the same prefix.

Specified by:
declareNamespace in interface NamespaceContext2
Parameters:
namespaceUri - String
preferedPrefix - String
requirePrefix - true if this is called for attribute name. false otherwise.
Returns:
String
See Also:
NamespaceContext2.declareNamespace(String, String, boolean)

getPrefix

public java.lang.String getPrefix(java.lang.String namespaceUri)
Method getPrefix

Specified by:
getPrefix in interface javax.xml.namespace.NamespaceContext
Parameters:
namespaceUri - String
Returns:
String
See Also:
NamespaceContext.getPrefix(String)

getNamespaceURI

public java.lang.String getNamespaceURI(java.lang.String prefix)
Obtains the namespace URI currently associated to the given prefix. If no namespace URI is associated, return null.

Specified by:
getNamespaceURI in interface javax.xml.namespace.NamespaceContext
Parameters:
prefix - String
Returns:
String
See Also:
NamespaceContext.getNamespaceURI(String)

getPrefixes

public java.util.Iterator getPrefixes(java.lang.String namespaceUri)
Method getPrefixes

Specified by:
getPrefixes in interface javax.xml.namespace.NamespaceContext
Parameters:
namespaceUri - String
Returns:
Iterator
See Also:
NamespaceContext.getPrefixes(String)

startElement

public void startElement()
Sets the current bindings aside and starts a new element context. This method should be called at the beginning of the startElement method of the Serializer implementation.


endNamespaceDecls

public void endNamespaceDecls()
Reconciles the namespace URI/prefix mapping requests since the last startElement method invocation and finalizes them. This method must be called after all the necessary namespace URIs for this element is reported through the declareNamespace method or the getPrefix method.


endElement

public void endElement()
Ends the current element context and gets back to the parent context. This method should be called at the end of the endElement method of derived classes.


iterateDeclaredPrefixes

public void iterateDeclaredPrefixes(PrefixCallback callback)
                             throws org.xml.sax.SAXException
Iterates all newly declared namespace prefixes for this element. * @param callback PrefixCallback

Parameters:
callback - PrefixCallback
Throws:
org.xml.sax.SAXException