|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.jackrabbit.webdav.xml.DomUtil
public class DomUtil
DomUtil provides some common utility methods related to w3c-DOM.
| Field Summary | |
|---|---|
static javax.xml.parsers.DocumentBuilderFactory |
BUILDER_FACTORY
Constant for DocumentBuilderFactory which is used
widely to create new Documents |
| Constructor Summary | |
|---|---|
DomUtil()
|
|
| Method Summary | |
|---|---|
static org.w3c.dom.Element |
addChildElement(org.w3c.dom.Element parent,
java.lang.String localName,
Namespace namespace)
Add a new child element with the given local name and namespace to the specified parent. |
static org.w3c.dom.Element |
addChildElement(org.w3c.dom.Element parent,
java.lang.String localName,
Namespace namespace,
java.lang.String text)
Add a new child element with the given local name and namespace to the specified parent. |
static org.w3c.dom.Element |
addChildElement(org.w3c.dom.Node parent,
java.lang.String localName,
Namespace namespace)
Add a new child element with the given local name and namespace to the specified parent. |
static org.w3c.dom.Element |
createElement(org.w3c.dom.Document factory,
java.lang.String localName,
Namespace namespace)
Create a new DOM element with the specified local name and namespace. |
static org.w3c.dom.Element |
createElement(org.w3c.dom.Document factory,
java.lang.String localName,
Namespace namespace,
java.lang.String text)
Create a new DOM element with the specified local name and namespace and add the specified text as Text node to it. |
static org.w3c.dom.Element |
depthToXml(boolean isDeep,
org.w3c.dom.Document factory)
Returns the Xml representation of a boolean isDeep, where false presents a depth value of '0', true a depth value of 'infinity'. |
static org.w3c.dom.Element |
depthToXml(java.lang.String depth,
org.w3c.dom.Document factory)
Returns the Xml representation of a depth String. |
static java.lang.String |
getAttribute(org.w3c.dom.Element parent,
java.lang.String localName,
Namespace namespace)
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,
Namespace childNamespace)
Returns the first child element that matches the given local name and namespace. |
static ElementIterator |
getChildren(org.w3c.dom.Element parent)
Return an ElementIterator over all child elements. |
static ElementIterator |
getChildren(org.w3c.dom.Element parent,
java.lang.String childLocalName,
Namespace childNamespace)
Returns a ElementIterator containing all child elements of
the given parent node that match the given local name and namespace. |
static java.lang.String |
getChildText(org.w3c.dom.Element parent,
java.lang.String childLocalName,
Namespace childNamespace)
Calls getText(Element) on the first child element that matches
the given local name and namespace. |
static java.lang.String |
getChildTextTrim(org.w3c.dom.Element parent,
java.lang.String childLocalName,
Namespace childNamespace)
Calls getTextTrim(Element) on the first child element that matches
the given local name and namespace. |
static java.util.List |
getContent(org.w3c.dom.Node parent)
Return a list of all child nodes that are either Element, Text or CDATA. |
static org.w3c.dom.Element |
getFirstChildElement(org.w3c.dom.Node parent)
Return the first child element |
static Namespace |
getNamespace(org.w3c.dom.Element element)
Build a Namespace from the prefix and uri retrieved from the given element. |
static org.w3c.dom.Attr[] |
getNamespaceAttributes(org.w3c.dom.Element element)
Returns the namespace attributes of the given element. |
static java.lang.String |
getPrefixedName(java.lang.String localName,
Namespace namespace)
Return the prefixed name of a DOM node consisting of namespace prefix + ":" + local name. |
static java.lang.String |
getQualifiedName(java.lang.String localName,
Namespace namespace)
Return a qualified name of a DOM node consisting of "{" + namespace uri + "}" + localName. |
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 java.lang.String |
getTextTrim(org.w3c.dom.Element element)
Removes leading and trailing whitespace after calling getText(Element). |
static boolean |
hasChildElement(org.w3c.dom.Node parent,
java.lang.String childLocalName,
Namespace childNamespace)
Returns true if the given parent node has a child element that matches the specified local name and namespace. |
static boolean |
hasContent(org.w3c.dom.Node parent)
Return true if the given parent contains any child that is
either an Element, Text or CDATA. |
static org.w3c.dom.Element |
hrefToXml(java.lang.String href,
org.w3c.dom.Document factory)
Builds a 'DAV:href' Xml element from the given href. |
static boolean |
matches(org.w3c.dom.Node node,
java.lang.String requiredLocalName,
Namespace requiredNamespace)
Returns true if the specified node matches the required names. |
static void |
setAttribute(org.w3c.dom.Element element,
java.lang.String attrLocalName,
Namespace attrNamespace,
java.lang.String attrValue)
Add an attribute node to the given element. |
static void |
setNamespaceAttribute(org.w3c.dom.Element element,
java.lang.String prefix,
java.lang.String uri)
Adds a namespace attribute on the given element. |
static void |
setText(org.w3c.dom.Element element,
java.lang.String text)
Create a new text node and add it as child to the given element. |
static org.w3c.dom.Element |
timeoutToXml(long timeout,
org.w3c.dom.Document factory)
Converts the given timeout (long value defining the number of milli- second until timeout is reached) to its Xml representation as defined by RTF 2518. Note, that DavConstants.INFINITE_TIMEOUT is not represented by the String
'Infinite' defined by RFC 2518, due to a known
issue with Microsoft Office that opens the document "read only" and
never unlocks the resource if the timeout is missing or 'Infinite'. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static javax.xml.parsers.DocumentBuilderFactory BUILDER_FACTORY
DocumentBuilderFactory which is used
widely to create new Documents
| Constructor Detail |
|---|
public DomUtil()
| Method Detail |
|---|
public static java.lang.String getAttribute(org.w3c.dom.Element parent,
java.lang.String localName,
Namespace namespace)
parent - localName - attribute local name or 'nodeName' if no namespace is
specified.namespace - or null
null if not foundpublic static org.w3c.dom.Attr[] getNamespaceAttributes(org.w3c.dom.Element element)
element -
public static java.lang.String getText(org.w3c.dom.Element element)
element -
null if the length of the resulting String is 0.isText(Node)
public static java.lang.String getText(org.w3c.dom.Element element,
java.lang.String defaultValue)
getText(Element) except that 'defaultValue' is returned
instead of null, if the element does not contain any text.
element - defaultValue -
defaultValue if the element does not contain any text.public static java.lang.String getTextTrim(org.w3c.dom.Element element)
getText(Element).
element -
null
public static java.lang.String getChildText(org.w3c.dom.Element parent,
java.lang.String childLocalName,
Namespace childNamespace)
getText(Element) on the first child element that matches
the given local name and namespace.
parent - childLocalName - childNamespace -
null.getText(Element)
public static java.lang.String getChildTextTrim(org.w3c.dom.Element parent,
java.lang.String childLocalName,
Namespace childNamespace)
getTextTrim(Element) on the first child element that matches
the given local name and namespace.
parent - childLocalName - childNamespace -
null. Note, that leading and trailing whitespace
is removed from the text.getTextTrim(Element)
public static boolean hasChildElement(org.w3c.dom.Node parent,
java.lang.String childLocalName,
Namespace childNamespace)
parent - childLocalName - childNamespace -
public static org.w3c.dom.Element getChildElement(org.w3c.dom.Node parent,
java.lang.String childLocalName,
Namespace childNamespace)
null is returned.
parent - childLocalName - childNamespace -
null.
public static ElementIterator getChildren(org.w3c.dom.Element parent,
java.lang.String childLocalName,
Namespace childNamespace)
ElementIterator containing all child elements of
the given parent node that match the given local name and namespace.
If the namespace is null only the localName is compared.
parent - the node the children elements should be retrieved fromchildLocalName - childNamespace -
ElementIterator giving access to all child elements
that match the specified localName and namespace.public static ElementIterator getChildren(org.w3c.dom.Element parent)
ElementIterator over all child elements.
parent -
for a method that only
retrieves child elements that match a specific local name and namespace.public static org.w3c.dom.Element getFirstChildElement(org.w3c.dom.Node parent)
null if the given node has no
child elements.public static boolean hasContent(org.w3c.dom.Node parent)
true if the given parent contains any child that is
either an Element, Text or CDATA.
parent -
true if the given parent contains any child that is
either an Element, Text or CDATA.public static java.util.List getContent(org.w3c.dom.Node parent)
parent -
public static Namespace getNamespace(org.w3c.dom.Element element)
Namespace of the given element.
public static boolean matches(org.w3c.dom.Node node,
java.lang.String requiredLocalName,
Namespace requiredNamespace)
null.
node - requiredLocalName - requiredNamespace -
public static org.w3c.dom.Element createElement(org.w3c.dom.Document factory,
java.lang.String localName,
Namespace namespace)
factory - localName - namespace -
Document.createElement(String),
Document.createElementNS(String, String)
public static org.w3c.dom.Element createElement(org.w3c.dom.Document factory,
java.lang.String localName,
Namespace namespace,
java.lang.String text)
factory - localName - namespace - text -
Document.createElement(String),
Document.createElementNS(String, String),
Document.createTextNode(String),
Node.appendChild(org.w3c.dom.Node)
public static org.w3c.dom.Element addChildElement(org.w3c.dom.Element parent,
java.lang.String localName,
Namespace namespace)
parent - localName - namespace -
public static org.w3c.dom.Element addChildElement(org.w3c.dom.Node parent,
java.lang.String localName,
Namespace namespace)
parent - localName - namespace -
public static org.w3c.dom.Element addChildElement(org.w3c.dom.Element parent,
java.lang.String localName,
Namespace namespace,
java.lang.String text)
parent - localName - namespace - text -
Document.createElement(String),
Document.createElementNS(String, String),
Document.createTextNode(String),
Node.appendChild(org.w3c.dom.Node)
public static void setText(org.w3c.dom.Element element,
java.lang.String text)
element - text -
public static void setAttribute(org.w3c.dom.Element element,
java.lang.String attrLocalName,
Namespace attrNamespace,
java.lang.String attrValue)
element - attrLocalName - attrNamespace - attrValue -
public static void setNamespaceAttribute(org.w3c.dom.Element element,
java.lang.String prefix,
java.lang.String uri)
element - prefix - uri -
public static org.w3c.dom.Element timeoutToXml(long timeout,
org.w3c.dom.Document factory)
DavConstants.INFINITE_TIMEOUT is not represented by the String
'Infinite' defined by RFC 2518, due to a known
issue with Microsoft Office that opens the document "read only" and
never unlocks the resource if the timeout is missing or 'Infinite'.
timeout - number of milli-seconds until timeout is reached.
public static org.w3c.dom.Element depthToXml(boolean isDeep,
org.w3c.dom.Document factory)
isDeep -
public static org.w3c.dom.Element depthToXml(java.lang.String depth,
org.w3c.dom.Document factory)
depth -
public static org.w3c.dom.Element hrefToXml(java.lang.String href,
org.w3c.dom.Document factory)
escaped in order to prevent problems with
WebDAV clients.
href - String representing the text of the 'href' Xml elementfactory - the Document used as factory
public static java.lang.String getQualifiedName(java.lang.String localName,
Namespace namespace)
null or represents
the empty namespace, the local name is returned.
localName - namespace -
null or represents
the empty namespace, the local name is returned.
public static java.lang.String getPrefixedName(java.lang.String localName,
Namespace namespace)
null
or contains an empty prefix, the local name is returned.
localName - namespace -
Document.createAttributeNS(String, String),
Document.createElementNS(String, String)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||