org.apache.webdav.lib.util

Class DOMUtils


public class DOMUtils
extends java.lang.Object

This class provides some basic utility methods for working with XML Document objects. Many of these utilities provide JAXP 1.0 "brute force" implementations of functions that are available in JAXP 1.1.
Version:
$Revision: 1.2.2.1 $

Nested Class Summary

(package private) static class
DOMUtils.NodeListImpl
This class provides an implementation of NodeList, which is used by the getElementsByTagNameNS() method.

Field Summary

protected static Class[]
getElementsByNSParameterTypes

Method Summary

static String
findDavPrefix(Document document)
Deprecated.
protected static void
getChildElementsByTagNameNS(Vector vector, Node node, String tagName, String namespace)
static String
getElementLocalName(Element element)
static String
getElementNamespaceURI(Element element)
static NodeList
getElementsByTagNameNS(Node node, String tagName, String namespace)
static Element
getFirstElement(Node node, String namespace, String name)
Get the first element matched with the given namespace and name.
static String
getTextValue(Node node)
Recursively scans all child elements, appending any text nodes.
static int
parseStatus(String statusString)
Get the status code out of the normal status response.

Field Details

getElementsByNSParameterTypes

protected static Class[] getElementsByNSParameterTypes

Method Details

findDavPrefix

public static String findDavPrefix(Document document)

Deprecated.

Determine the namespace prefix being used for DAV. Generally, DAV responses say something like:
  <D:multistatus xmlns:D="DAV:">
  

In this case, the "D:" is the prefix for DAV.


getChildElementsByTagNameNS

protected static void getChildElementsByTagNameNS(Vector vector,
                                                  Node node,
                                                  String tagName,
                                                  String namespace)

getElementLocalName

public static String getElementLocalName(Element element)

getElementNamespaceURI

public static String getElementNamespaceURI(Element element)

getElementsByTagNameNS

public static NodeList getElementsByTagNameNS(Node node,
                                              String tagName,
                                              String namespace)

getFirstElement

public static Element getFirstElement(Node node,
                                      String namespace,
                                      String name)
Get the first element matched with the given namespace and name.
Parameters:
node - The node.
name - The name.
Returns:
The wanted first element.

getTextValue

public static String getTextValue(Node node)
Recursively scans all child elements, appending any text nodes.
  <customer>Joe Schmoe</customer>
  

In this case, calling this method on the customer element returns "Joe Schmoe".


parseStatus

public static int parseStatus(String statusString)
Get the status code out of the normal status response.

Each DAV:propstat node contains a status line, such as:

  <DAV:status>HTTP/1.1 200 OK</DAV:status>
  

In this case, calling this method on the text string returns 200.