com.waveset.util
Class XmlElement

java.lang.Object
  extended bycom.waveset.util.XmlElement

public class XmlElement
extends java.lang.Object

A wrapper around the standard DOM Element that provides a more convenient set of methods.


Field Summary
static java.lang.String code_id
           
 
Constructor Summary
XmlElement(org.w3c.dom.Element e)
           
 
Method Summary
 java.lang.String getAttribute(java.lang.String name)
          Return the value of an attribute.
 boolean getBooleanAttribute(java.lang.String name)
          Return a boolean attribute value.
 XmlElement getChildElement()
          Return the first child element.
 XmlElement getChildElement(java.lang.String localName)
          Return the first child element with the given local name.
 java.util.List getChildElements(java.lang.String localName)
           
 org.w3c.dom.Node getChildren()
           
 java.lang.String getContent()
          Return the content of the given element.
 org.w3c.dom.Element getElement()
           
 java.lang.String getLocalName()
          Return the element tag name without the namespace qualifier.
 java.lang.String getNamespaceURI()
          Given an element with a namespace prefix and a namespace declaration for that prefix, return the namespace URI.
 XmlElement getNextElement()
          Get the next right sibling that is an element.
 XmlElement getNextElement(java.lang.String localName)
          Return the next right sibling with the given local name.
 java.lang.String getPrefix()
          Return the namespace prefix.
 java.lang.String getTagName()
           
 XmlElement next()
          Assimilate the next right sibling within this element wrapper.
 void setAttribute(java.lang.String name, java.lang.String value)
           
static java.lang.String stripPrefix(java.lang.String value)
          Remove an identifier prefix from an attribute value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

code_id

public static final java.lang.String code_id
See Also:
Constant Field Values
Constructor Detail

XmlElement

public XmlElement(org.w3c.dom.Element e)
Method Detail

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.String value)

getElement

public org.w3c.dom.Element getElement()

getChildren

public org.w3c.dom.Node getChildren()

getTagName

public java.lang.String getTagName()

getLocalName

public java.lang.String getLocalName()
Return the element tag name without the namespace qualifier. // See file comments for the reason why we don't just call // Element.getLocalName.


getPrefix

public java.lang.String getPrefix()
Return the namespace prefix. // See file comments for the reason why we don't just call // Element.getPrefix.


getNamespaceURI

public java.lang.String getNamespaceURI()
Given an element with a namespace prefix and a namespace declaration for that prefix, return the namespace URI. Note that this is not as general as the DOM method, the only scope examined is the local element. // See file comments for the reason we don't just call // Element.getNamespaceURI.


stripPrefix

public static java.lang.String stripPrefix(java.lang.String value)
Remove an identifier prefix from an attribute value.


getAttribute

public java.lang.String getAttribute(java.lang.String name)
Return the value of an attribute.

The DOM getAttribute method returns an empty string if the attribute doesn't exist. Here, we detect this and return null.


getBooleanAttribute

public boolean getBooleanAttribute(java.lang.String name)
Return a boolean attribute value.

The value must be equal to the string "true" or "1" to be considered true.


getChildElement

public XmlElement getChildElement()
Return the first child element.


getChildElement

public XmlElement getChildElement(java.lang.String localName)
Return the first child element with the given local name. Used during SPML parsing to skip over the optional SOAP header and get to the Body.


getChildElements

public java.util.List getChildElements(java.lang.String localName)

getNextElement

public XmlElement getNextElement()
Get the next right sibling that is an element.


getNextElement

public XmlElement getNextElement(java.lang.String localName)
Return the next right sibling with the given local name.


next

public XmlElement next()
Assimilate the next right sibling within this element wrapper. This makes the element behave more like an iterator which is usually what you want and cuts down on garbage.


getContent

public java.lang.String getContent()
Return the content of the given element.

We will descend to an arbitrary depth looking for the first non-empty text node.

Note that the parser may break what was originally a single string of pcdata into multiple adjacent text nodes. Xerces appears to do this when it encounters a '$' in the text, not sure if there is specified behavior, or if its parser specific.

Here, we will congeal adjacent text nodes.

We will NOT ignore text nodes that have only whitespace.