ru.novosoft.dc.core.util
Class NamespaceHandler

java.lang.Object
  |
  +--ru.novosoft.dc.core.util.NamespaceHandler

public class NamespaceHandler
extends java.lang.Object

The handler of XML namespaces.


Constructor Summary
NamespaceHandler()
           
 
Method Summary
 java.lang.String get(java.lang.String prefix)
          Return uri for the given namespace prefix.
 org.w3c.dom.Element getDefaultElement()
          Return the default element or null if no defaults specified.
 void set(java.lang.String prefix, java.lang.String uri)
          Register a namespace uri for the given namespace prefix.
 void setDefaultElement(org.w3c.dom.Element element)
          Set DOM element to be handled by default.
 void use(java.lang.String prefix)
          Use a namespace with the given prefix at the default DOM element.
 void use(java.lang.String prefix, org.w3c.dom.Element element)
          Use a namespace with the given prefix at the given DOM element.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NamespaceHandler

public NamespaceHandler()
Method Detail

set

public final void set(java.lang.String prefix,
                      java.lang.String uri)
Register a namespace uri for the given namespace prefix.

get

public final java.lang.String get(java.lang.String prefix)
Return uri for the given namespace prefix.
Throws:
java.lang.IllegalArgumentException - if a namespace with the given prefix does not registered in this handler

setDefaultElement

public final void setDefaultElement(org.w3c.dom.Element element)
Set DOM element to be handled by default.

getDefaultElement

public final org.w3c.dom.Element getDefaultElement()
Return the default element or null if no defaults specified.

use

public final void use(java.lang.String prefix)
Use a namespace with the given prefix at the default DOM element.
Throws:
NullPointerException - if no default DOM elemeent specified
java.lang.IllegalArgumentException - if a namespace with the given prefix does not registered in this handler
IllegalStateException - if the default DOM element already has this namespace but with another uri value

use

public void use(java.lang.String prefix,
                org.w3c.dom.Element element)
Use a namespace with the given prefix at the given DOM element. The method provides the given DOM element with the "xmlns:prefix" attribute extracting attribute value from the handler's registry.
Throws:
java.lang.IllegalArgumentException - if a namespace with the given prefix does not registered in this handler
IllegalStateException - if the given DOM element already has this namespace but with another uri value