QJCC homepage

biz.chitec.quarterback.util
Class DOMHelp

java.lang.Object
  extended bybiz.chitec.quarterback.util.DOMHelp

public final class DOMHelp
extends java.lang.Object

Some helper stuff for handling DOM trees.

Version:
$Id: 5a1e8fa3e5dca8a65dd1eebf91b45ad83f948fed $
Author:
cantamen/Dirk Hillbrecht 2005. Distributed under the LGPL.

Nested Class Summary
private static class DOMHelp.NodeListIterator
          Internal helper class for accessing node lists through an Iterator.
 
Constructor Summary
private DOMHelp()
          The class is uninstantiable and contains only static methods.
 
Method Summary
static EDate createEDate(java.lang.String nodevalue)
          Create an EDate out of a String representation.
static org.w3c.dom.Element createSingleTextElement(org.w3c.dom.Document doc, java.lang.String name, java.lang.String value)
          Convenience method for creation of an Element which only contains one textual value node.
static org.w3c.dom.Node findLeaf(org.w3c.dom.Node n, java.lang.String name)
          Find the (first) child of the given node which has the given name.
static org.w3c.dom.Node findLeaf(org.w3c.dom.Node n, java.lang.String[] names)
          Strange method which seems to be superfluous
static java.util.Iterator getNodeListIterator(org.w3c.dom.NodeList nl)
          Return an Iterator for a given NodeList.
static boolean isNode(java.lang.String nodename, org.w3c.dom.Node node)
          Returns whether a node has a certain name.
static org.w3c.dom.Element propertiesToXML(org.w3c.dom.Document doc, java.lang.String elementname, java.util.Properties p)
          Create an XML representation of a Properties instance.
static java.util.Properties xmlToProperties(org.w3c.dom.Element father)
           
static java.util.Properties xmlToProperties(org.w3c.dom.Element father, java.util.Properties p)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DOMHelp

private DOMHelp()
The class is uninstantiable and contains only static methods.

Method Detail

getNodeListIterator

public static java.util.Iterator getNodeListIterator(org.w3c.dom.NodeList nl)
Return an Iterator for a given NodeList. The Iterator will return the first element of the list and go onward from there.

Parameters:
nl - The NodeList.
Returns:
An Iterator for the given NodeList.

findLeaf

public static org.w3c.dom.Node findLeaf(org.w3c.dom.Node n,
                                        java.lang.String name)
Find the (first) child of the given node which has the given name.

Parameters:
n - A node in the DOM tree.
name - Wanted child name.
Returns:
First child of the given node with the given name, or null if such a child does not exist.

findLeaf

public static org.w3c.dom.Node findLeaf(org.w3c.dom.Node n,
                                        java.lang.String[] names)
Strange method which seems to be superfluous


isNode

public static boolean isNode(java.lang.String nodename,
                             org.w3c.dom.Node node)
Returns whether a node has a certain name.

Parameters:
nodename - Name to check
node - Node

createSingleTextElement

public static org.w3c.dom.Element createSingleTextElement(org.w3c.dom.Document doc,
                                                          java.lang.String name,
                                                          java.lang.String value)
Convenience method for creation of an Element which only contains one textual value node. The textual value node is only inserted if the given value is not null.

Parameters:
doc - Document to insert the Element to finally.
name - Name of the element.
value - Value of the element or null if it should not contain a value.
Returns:
Properly created Element.

createEDate

public static EDate createEDate(java.lang.String nodevalue)
Create an EDate out of a String representation. The date description must contain year, month, day, hour, minute and second. The elements must be seperated by one of the characters "-", "T", ":", ".".

Parameters:
nodevalue - Date-describing node value.
Returns:
EDate instance representing the given date.

propertiesToXML

public static org.w3c.dom.Element propertiesToXML(org.w3c.dom.Document doc,
                                                  java.lang.String elementname,
                                                  java.util.Properties p)
Create an XML representation of a Properties instance. Each key-value pair is represented by a "Value"-tag which has a "Key" attribute. The tags are sorted by key order.

Parameters:
doc - Document to insert the element into.
elementname - Name of the XML element containing the Property's content.
p - Properties to convert.
Returns:
Element representing the Properties instance.

xmlToProperties

public static java.util.Properties xmlToProperties(org.w3c.dom.Element father,
                                                   java.util.Properties p)

xmlToProperties

public static java.util.Properties xmlToProperties(org.w3c.dom.Element father)

QJCC homepage