org.apache.jackrabbit.util
Class XMLUtil

java.lang.Object
  extended by org.apache.jackrabbit.util.XMLUtil

public class XMLUtil
extends java.lang.Object

XMLUtil...


Constructor Summary
XMLUtil()
           
 
Method Summary
static java.lang.String getAttribute(org.w3c.dom.Element parent, java.lang.String localName, java.lang.String namespaceURI)
          Returns the value of the named attribute of the current element.
static org.w3c.dom.Element getChildElement(org.w3c.dom.Node parent, java.lang.String childLocalName, java.lang.String childNamespaceURI)
          Returns the first child element that matches the given local name and namespace.
static java.lang.String getChildText(org.w3c.dom.Element parent, java.lang.String childLocalName, java.lang.String childNamespaceURI)
          Calls getText(Element) on the first child element that matches the given local name and namespace.
static java.lang.String getText(org.w3c.dom.Element element)
          Concatenates the values of all child nodes of type 'Text' or 'CDATA'/
static java.lang.String getText(org.w3c.dom.Element element, java.lang.String defaultValue)
          Same as getText(Element) except that 'defaultValue' is returned instead of null, if the element does not contain any text.
static boolean isText(org.w3c.dom.Node node)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLUtil

public XMLUtil()
Method Detail

isText

public static boolean isText(org.w3c.dom.Node node)
Parameters:
node -
Returns:
true if the given node is of type text or CDATA.

getText

public static java.lang.String getText(org.w3c.dom.Element element)
Concatenates the values of all child nodes of type 'Text' or 'CDATA'/

Parameters:
element -
Returns:
String representing the value of all Text and CDATA child nodes or null if the length of the resulting String is 0.
See Also:
isText(org.w3c.dom.Node)

getText

public static java.lang.String getText(org.w3c.dom.Element element,
                                       java.lang.String defaultValue)
Same as getText(Element) except that 'defaultValue' is returned instead of null, if the element does not contain any text.

Parameters:
element -
defaultValue -
Returns:
the text contained in the specified element or defaultValue if the element does not contain any text.

getChildText

public static java.lang.String getChildText(org.w3c.dom.Element parent,
                                            java.lang.String childLocalName,
                                            java.lang.String childNamespaceURI)
Calls getText(Element) on the first child element that matches the given local name and namespace.

Parameters:
parent -
childLocalName -
childNamespaceURI -
Returns:
text contained in the first child that matches the given local name and namespace or null.
See Also:
getText(Element)

getChildElement

public static org.w3c.dom.Element getChildElement(org.w3c.dom.Node parent,
                                                  java.lang.String childLocalName,
                                                  java.lang.String childNamespaceURI)
Returns the first child element that matches the given local name and namespace. If no child element is present or no child element matches, null is returned.

Parameters:
parent -
childLocalName -
childNamespaceURI -
Returns:
first child element matching the specified names or null.

getAttribute

public static java.lang.String getAttribute(org.w3c.dom.Element parent,
                                            java.lang.String localName,
                                            java.lang.String namespaceURI)
Returns the value of the named attribute of the current element.

Parameters:
parent -
localName - attribute local name or 'nodeName' if no namespace is specified.
namespaceURI - or null
Returns:
attribute value, or null if not found


Copyright © 2004-2011 The Apache Software Foundation. All Rights Reserved.