de.ispsoft.jaxme.generator.util
Class DOM

java.lang.Object
  extended byde.ispsoft.jaxme.generator.util.DOM

public class DOM
extends java.lang.Object

A set of utility methods for working with DOM documents.

Author:
Jochen Wiedmann

Field Summary
static java.lang.String DOM_XMLNS_URI
          The DOM namespace for xmlns attributes.
 
Constructor Summary
DOM()
           
 
Method Summary
static void assignBeanProperties(java.lang.Object pBean, org.w3c.dom.Node pNode)
          Treats the attributes and child elements of the given DOM element pElement as bean properties of the bean pBean.
static void assignBeanProperties(java.lang.Object pBean, org.w3c.dom.Node pNode, ReflectResolver pResolver)
           
static org.w3c.dom.Element getAnnotationNode(org.w3c.dom.Element pNode)
          Returns an elements or attributes xs:annotation node, or null, if no such node exists.
static org.w3c.dom.Element getAppInfoNode(org.w3c.dom.Element pNode)
          Returns an elements or attributes xs:appinfo node, or null, if no such node exists.
static org.w3c.dom.Element getChildElement(org.w3c.dom.Node pNode, java.lang.String pNamespaceURI, java.lang.String pLocalName)
          Returns the child element with namespace URI pNamespaceURI and local name pLocalName of pNode, if any.
static org.w3c.dom.Element getDocumentationNode(org.w3c.dom.Element pNode)
          Returns an elements or attributes xs:documentation node, or null, if no such node exists.
static java.lang.String getElementValue(org.w3c.dom.Node node)
          Returns an element nodes text contents by appending any text nodes or cdata section nodes value.
static java.lang.String getPrefixOf(org.w3c.dom.Node pNode, java.lang.String pURI)
          Given an attribute or element node, tries to return a valid prefix declaration for a given namespace.
static boolean isAtomic(org.w3c.dom.Node pNode)
          Returns whether the given node is an atomic element.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DOM_XMLNS_URI

public static final java.lang.String DOM_XMLNS_URI

The DOM namespace for xmlns attributes.

See Also:
Constant Field Values
Constructor Detail

DOM

public DOM()
Method Detail

getElementValue

public static java.lang.String getElementValue(org.w3c.dom.Node node)

Returns an element nodes text contents by appending any text nodes or cdata section nodes value.


assignBeanProperties

public static void assignBeanProperties(java.lang.Object pBean,
                                        org.w3c.dom.Node pNode)
                                 throws SchemaException

Treats the attributes and child elements of the given DOM element pElement as bean properties of the bean pBean. More precise:

  1. For any attribute someAttribute with default namespace a method setSomeAttribute is searched. The method is called with the attribute value, if it exists.
  2. For any child element someElement with the same namespace that the element pElement has, a method setSomeElement or addSomeElement is searched. The method is called with the attribute value, if it exists.

Throws:
SchemaException

assignBeanProperties

public static void assignBeanProperties(java.lang.Object pBean,
                                        org.w3c.dom.Node pNode,
                                        ReflectResolver pResolver)
                                 throws SchemaException
Throws:
SchemaException

isAtomic

public static boolean isAtomic(org.w3c.dom.Node pNode)

Returns whether the given node is an atomic element.


getAnnotationNode

public static org.w3c.dom.Element getAnnotationNode(org.w3c.dom.Element pNode)

Returns an elements or attributes xs:annotation node, or null, if no such node exists.


getAppInfoNode

public static org.w3c.dom.Element getAppInfoNode(org.w3c.dom.Element pNode)

Returns an elements or attributes xs:appinfo node, or null, if no such node exists.


getDocumentationNode

public static org.w3c.dom.Element getDocumentationNode(org.w3c.dom.Element pNode)

Returns an elements or attributes xs:documentation node, or null, if no such node exists.


getPrefixOf

public static java.lang.String getPrefixOf(org.w3c.dom.Node pNode,
                                           java.lang.String pURI)

Given an attribute or element node, tries to return a valid prefix declaration for a given namespace.

Parameters:
pNode - The node to query
pURI - The namespace URI
Returns:
A namespace prefix, possibly the empty string for the default namespace, or null, if no such namespace was found.

getChildElement

public static org.w3c.dom.Element getChildElement(org.w3c.dom.Node pNode,
                                                  java.lang.String pNamespaceURI,
                                                  java.lang.String pLocalName)

Returns the child element with namespace URI pNamespaceURI and local name pLocalName of pNode, if any. If pNode is null or no such child element exists, returns null.