de.ispsoft.jaxme
Class NamespaceSupport

java.lang.Object
  extended byde.ispsoft.jaxme.NamespaceSupport

public class NamespaceSupport
extends java.lang.Object

Similar to org.xml.sax.NamespaceSupport, but optimized for frequent use.

Author:
Jochen Wiedmann

Constructor Summary
NamespaceSupport()
          Creates a new instance of NamespaceSupport.
 
Method Summary
protected  java.lang.String createPrefix()
          Creates a new default mapping for the given namespace URI.
 void endPrefixMapping(java.lang.String pPrefix)
          Implements org.xml.sax.ContentHandler.endPrefixMapping().
 java.lang.String getAttrQName(java.lang.String pNamespaceURI, java.lang.String pLocalName, org.xml.sax.ContentHandler pContentHandler)
          Returns a qualified attribute name for the given namespace URI and local name.
 int getContext()
          Returns the NamespaceSupports current state.
 java.lang.String getDefaultPrefix()
          Returns the String being used to construct a default mapping.
 org.xml.sax.Locator getDocumentLocator()
          Returns a Locator previously set with setDocumentLocator().
 MarshallerImpl getMarshaller()
          Returns the Marshaller that created this instance.
 java.lang.String getPrefix(java.lang.String pNamespaceURI)
          Returns a prefix currently mapped to the given URI or null, if there is no such mapping.
 java.lang.String getQName(java.lang.String pNamespaceURI, java.lang.String pLocalName, org.xml.sax.ContentHandler pContentHandler)
          Returns a qualified element name for the given namespace URI and local name.
 void initPrefixMapping(org.xml.sax.ContentHandler pContentHandler)
          Initializes the given ContentHandler by firing SAX events of type startPrefixMapping.
 void setContext(org.xml.sax.ContentHandler pContentHandler, int pState)
          Restores the Namespacesupports state.
 void setDefaultPrefix(java.lang.String pDefaultPrefix)
          Sets the String being used to construct a default mapping.
 void setDocumentLocator(org.xml.sax.Locator pLocator)
          Implements org.xml.sax.ContentHandler.setDocumentLocator().
 void setMarshaller(MarshallerImpl pMarshaller)
          Sets the Marshaller that created this instance.
 void startPrefixMapping(java.lang.String pPrefix, java.lang.String pNamespaceURI)
          Implements org.xml.sax.ContentHandler.startPrefixMapping().
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NamespaceSupport

public NamespaceSupport()

Creates a new instance of NamespaceSupport.

Method Detail

initPrefixMapping

public void initPrefixMapping(org.xml.sax.ContentHandler pContentHandler)
                       throws org.xml.sax.SAXException

Initializes the given ContentHandler by firing SAX events of type startPrefixMapping.

Throws:
org.xml.sax.SAXException

startPrefixMapping

public void startPrefixMapping(java.lang.String pPrefix,
                               java.lang.String pNamespaceURI)
                        throws org.xml.sax.SAXException

Implements org.xml.sax.ContentHandler.startPrefixMapping().

Throws:
org.xml.sax.SAXException

getPrefix

public java.lang.String getPrefix(java.lang.String pNamespaceURI)

Returns a prefix currently mapped to the given URI or null, if there is no such mapping.

Parameters:
pNamespaceURI - The namespace URI in question

endPrefixMapping

public void endPrefixMapping(java.lang.String pPrefix)
                      throws org.xml.sax.SAXException

Implements org.xml.sax.ContentHandler.endPrefixMapping().

Throws:
org.xml.sax.SAXException

setDocumentLocator

public void setDocumentLocator(org.xml.sax.Locator pLocator)

Implements org.xml.sax.ContentHandler.setDocumentLocator().


getDocumentLocator

public org.xml.sax.Locator getDocumentLocator()

Returns a Locator previously set with setDocumentLocator().


getContext

public int getContext()

Returns the NamespaceSupports current state. The state can later be restored by calling setContext().


setContext

public void setContext(org.xml.sax.ContentHandler pContentHandler,
                       int pState)
                throws org.xml.sax.SAXException

Restores the Namespacesupports state. The argument must have been obtained by a previous call to getContext().

Throws:
org.xml.sax.SAXException

getQName

public java.lang.String getQName(java.lang.String pNamespaceURI,
                                 java.lang.String pLocalName,
                                 org.xml.sax.ContentHandler pContentHandler)
                          throws org.xml.sax.SAXException

Returns a qualified element name for the given namespace URI and local name. If there is no mapping for the namespace URI, a default mapping is established.

Throws:
org.xml.sax.SAXException
See Also:
getAttrQName(java.lang.String, java.lang.String, org.xml.sax.ContentHandler)

getAttrQName

public java.lang.String getAttrQName(java.lang.String pNamespaceURI,
                                     java.lang.String pLocalName,
                                     org.xml.sax.ContentHandler pContentHandler)
                              throws org.xml.sax.SAXException

Returns a qualified attribute name for the given namespace URI and local name. Mostly the same than getQName(), except that a possible default mapping does not apply.

Throws:
org.xml.sax.SAXException
See Also:
getQName(java.lang.String, java.lang.String, org.xml.sax.ContentHandler)

getDefaultPrefix

public java.lang.String getDefaultPrefix()

Returns the String being used to construct a default mapping. A unique number will be appended to the String.


setDefaultPrefix

public void setDefaultPrefix(java.lang.String pDefaultPrefix)

Sets the String being used to construct a default mapping. A unique number will be appended to the String.


createPrefix

protected java.lang.String createPrefix()

Creates a new default mapping for the given namespace URI.


getMarshaller

public MarshallerImpl getMarshaller()

Returns the Marshaller that created this instance.


setMarshaller

public void setMarshaller(MarshallerImpl pMarshaller)

Sets the Marshaller that created this instance.