org.apache.ws.jaxme.util
Class NamespaceSupport

java.lang.Object
  extended by org.apache.ws.jaxme.util.NamespaceSupport
All Implemented Interfaces:
NamespaceContext

public class NamespaceSupport
extends java.lang.Object
implements NamespaceContext

Similar to org.xml.sax.NamespaceSupport, but for marshalling and not for parsing XML.

Version:
$Id: NamespaceSupport.java 231705 2004-01-07 02:07:20Z jochen $
Author:
Jochen Wiedmann

Constructor Summary
NamespaceSupport()
          Creates a new instance of NamespaceSupport.
 
Method Summary
 void declarePrefix(java.lang.String pPrefix, java.lang.String pURI)
          Declares a new prefix.
 java.lang.String getAttributePrefix(java.lang.String pURI)
          Returns a non-empty prefix currently mapped to the given URL or null, if there is no such mapping.
 int getContext()
           
 java.lang.String getNamespaceURI(java.lang.String pPrefix)
          Given a prefix, returns the URI to which the prefix is currently mapped or null, if there is no such mapping.
 java.lang.String getPrefix(java.lang.String pURI)
          Returns a prefix currently mapped to the given URI or null, if there is no such mapping.
 java.util.Iterator getPrefixes(java.lang.String pURI)
          Returns a collection to all prefixes bound to the given namespace URI.
 boolean isPrefixDeclared(java.lang.String pPrefix)
          Returns whether a given prefix is currently declared.
 void reset()
          Resets the NamespaceSupport's state for reuse.
 java.lang.String setContext(int i)
           
 void undeclarePrefix(java.lang.String pPrefix)
          Removes a prefix declaration.
 
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

reset

public void reset()

Resets the NamespaceSupport's state for reuse.


declarePrefix

public void declarePrefix(java.lang.String pPrefix,
                          java.lang.String pURI)

Declares a new prefix.


undeclarePrefix

public void undeclarePrefix(java.lang.String pPrefix)

Removes a prefix declaration. Assumes that the prefix is the current prefix. If not, throws a IllegalStateException.


getNamespaceURI

public java.lang.String getNamespaceURI(java.lang.String pPrefix)

Given a prefix, returns the URI to which the prefix is currently mapped or null, if there is no such mapping.

Note: This methods behaviour is precisely defined by NamespaceContext.getNamespaceURI(java.lang.String).

Specified by:
getNamespaceURI in interface NamespaceContext
Parameters:
pPrefix - The prefix in question
Returns:
The Namespace URI to which the input prefix is currently mapped or null, if there is no such mapping.

getPrefix

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

Returns a prefix currently mapped to the given URI or null, if there is no such mapping. This method may be used to find a possible prefix for an elements namespace URI. For attributes you should use getAttributePrefix(String).

Note: This methods behaviour is precisely defined by NamespaceContext.getPrefix(java.lang.String).

Specified by:
getPrefix in interface NamespaceContext
Parameters:
pURI - The namespace URI in question
Returns:
A prefix currently mapped to the given namespace URI or null, if there is no such mapping
Throws:
java.lang.IllegalArgumentException - The namespace URI is null.

getAttributePrefix

public java.lang.String getAttributePrefix(java.lang.String pURI)

Returns a non-empty prefix currently mapped to the given URL or null, if there is no such mapping. This method may be used to find a possible prefix for an attributes namespace URI. For elements you should use getPrefix(String).

Parameters:
pURI - Thhe namespace URI in question
Throws:
java.lang.IllegalArgumentException - The namespace URI is null.

getPrefixes

public java.util.Iterator getPrefixes(java.lang.String pURI)

Returns a collection to all prefixes bound to the given namespace URI.

Note: This methods behaviour is precisely defined by NamespaceContext.getPrefixes(java.lang.String).

Specified by:
getPrefixes in interface NamespaceContext
Parameters:
pURI - The namespace prefix in question
Returns:
An unmodifiable Iterator: Using it's Iterator.remove() method throws an UnsupportedOperationException.

isPrefixDeclared

public boolean isPrefixDeclared(java.lang.String pPrefix)

Returns whether a given prefix is currently declared.


getContext

public int getContext()

setContext

public java.lang.String setContext(int i)