Class NamespaceContextImpl
- java.lang.Object
-
- com.sun.identity.wsfederation.jaxb.entityconfig.impl.runtime.NamespaceContextImpl
-
- All Implemented Interfaces:
NamespaceContext2,NamespaceContext
public class NamespaceContextImpl extends 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.
-
-
Constructor Summary
Constructors Constructor Description NamespaceContextImpl(com.sun.xml.bind.marshaller.NamespacePrefixMapper _prefixMapper)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringdeclareNamespace(String namespaceUri, String preferedPrefix, boolean requirePrefix)Declares a new namespace binding within the current context.voidendElement()Ends the current element context and gets back to the parent context.voidendNamespaceDecls()Reconciles the namespace URI/prefix mapping requests since the last startElement method invocation and finalizes them.com.sun.xml.bind.marshaller.NamespacePrefixMappergetNamespacePrefixMapper()StringgetNamespaceURI(String prefix)Obtains the namespace URI currently associated to the given prefix.StringgetPrefix(String namespaceUri)IteratorgetPrefixes(String namespaceUri)voiditerateDeclaredPrefixes(PrefixCallback callback)Iterates all newly declared namespace prefixes for this element.voidstartElement()Sets the current bindings aside and starts a new element context.
-
-
-
Method Detail
-
getNamespacePrefixMapper
public final com.sun.xml.bind.marshaller.NamespacePrefixMapper getNamespacePrefixMapper()
-
declareNamespace
public String declareNamespace(String namespaceUri, String preferedPrefix, boolean requirePrefix)
Description copied from interface:NamespaceContext2Declares 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:
declareNamespacein interfaceNamespaceContext2- Parameters:
requirePrefix- true if this is called for attribute name. false otherwise.preferedPrefix- If the caller has any particular preference to the prefix, pass that as a parameter. The callee will try to honor it. Set null if there's no particular preference.- Returns:
- returns the assigned prefix. If the namespace is bound to the default namespace, null is returned.
-
getPrefix
public String getPrefix(String namespaceUri)
- Specified by:
getPrefixin interfaceNamespaceContext
-
getNamespaceURI
public String getNamespaceURI(String prefix)
Obtains the namespace URI currently associated to the given prefix. If no namespace URI is associated, return null.- Specified by:
getNamespaceURIin interfaceNamespaceContext
-
getPrefixes
public Iterator getPrefixes(String namespaceUri)
- Specified by:
getPrefixesin interfaceNamespaceContext
-
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 SAXException
Iterates all newly declared namespace prefixes for this element.- Throws:
SAXException
-
-