Package org.apache.jackrabbit.util
Class XMLUtil
- java.lang.Object
-
- org.apache.jackrabbit.util.XMLUtil
-
public class XMLUtil extends Object
XMLUtil...
-
-
Constructor Summary
Constructors Constructor Description XMLUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringgetAttribute(Element parent, String localName, String namespaceURI)Returns the value of the named attribute of the current element.static ElementgetChildElement(Node parent, String childLocalName, String childNamespaceURI)Returns the first child element that matches the given local name and namespace.static StringgetChildText(Element parent, String childLocalName, String childNamespaceURI)CallsgetText(Element)on the first child element that matches the given local name and namespace.static StringgetText(Element element)Concatenates the values of all child nodes of type 'Text' or 'CDATA'/static StringgetText(Element element, String defaultValue)Same asgetText(Element)except that 'defaultValue' is returned instead ofnull, if the element does not contain any text.static booleanisText(Node node)
-
-
-
Method Detail
-
isText
public static boolean isText(Node node)
- Parameters:
node-- Returns:
- true if the given node is of type text or CDATA.
-
getText
public static String getText(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
nullif the length of the resulting String is 0. - See Also:
isText(org.w3c.dom.Node)
-
getText
public static String getText(Element element, String defaultValue)
Same asgetText(Element)except that 'defaultValue' is returned instead ofnull, if the element does not contain any text.- Parameters:
element-defaultValue-- Returns:
- the text contained in the specified element or
defaultValueif the element does not contain any text.
-
getChildText
public static String getChildText(Element parent, String childLocalName, String childNamespaceURI)
CallsgetText(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 Element getChildElement(Node parent, String childLocalName, 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,nullis returned.- Parameters:
parent-childLocalName-childNamespaceURI-- Returns:
- first child element matching the specified names or
null.
-
getAttribute
public static String getAttribute(Element parent, String localName, 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- ornull- Returns:
- attribute value, or
nullif not found
-
-