to.etc.xml
Class NSDomTools

java.lang.Object
  extended by to.etc.xml.NSDomTools

public class NSDomTools
extends java.lang.Object

DomTools version that is namespace-aware. Created on Oct 12, 2005

Author:
jal

Constructor Summary
NSDomTools()
           
 
Method Summary
static boolean boolAttr(org.w3c.dom.Node n, java.lang.String ns, java.lang.String aname)
           
static boolean boolAttr(org.w3c.dom.Node n, java.lang.String ns, java.lang.String aname, boolean defval)
           
static boolean boolNode(org.w3c.dom.Node rootnode, java.lang.String ns, java.lang.String name)
          Finds the child node with the name specified, and returns it as a boolean value.
static java.util.Date dateNode(org.w3c.dom.Node rn, java.lang.String ns, java.lang.String name)
           
static java.util.Date dateNode(org.w3c.dom.Node rn, java.lang.String ns, java.lang.String name, java.util.Date dflt)
           
static double doubleNode(org.w3c.dom.Node rootnode, java.lang.String ns, java.lang.String name, double val)
           
static int getNodeAttribute(org.w3c.dom.Node n, java.lang.String ns, java.lang.String aname, int defval)
          Get the named attribute from a node.
static java.lang.String getNodeAttribute(org.w3c.dom.Node n, java.lang.String ns, java.lang.String aname, java.lang.String defval)
          Get the named attribute from a node.
static org.w3c.dom.Node getRootElement(org.w3c.dom.Document doc)
           
static java.lang.String[] getStringList(org.w3c.dom.Node inn, java.lang.String itemname)
           
static java.util.List<java.lang.String> getStringList(org.w3c.dom.Node inn, java.lang.String listname, java.lang.String itemname)
           
static int intAttr(org.w3c.dom.Node n, java.lang.String ns, java.lang.String aname)
           
static int intAttr(org.w3c.dom.Node n, java.lang.String ns, java.lang.String aname, int defval)
           
static int intNode(org.w3c.dom.Node rootnode, java.lang.String ns, java.lang.String name)
           
static int intNode(org.w3c.dom.Node rootnode, java.lang.String ns, java.lang.String name, int val)
           
static long longNode(org.w3c.dom.Node rootnode, java.lang.String ns, java.lang.String name)
           
static long longNode(org.w3c.dom.Node rootnode, java.lang.String ns, java.lang.String name, long val)
           
static org.w3c.dom.Node nodeFind(org.w3c.dom.Node rn, java.lang.String ns, java.lang.String name)
          Finds a single element with the name spec'd in the node.
static java.lang.String strAttr(org.w3c.dom.Node n, java.lang.String ns, java.lang.String aname, java.lang.String def)
           
static java.lang.String stringNode_untrimmed(org.w3c.dom.Node rootnode, java.lang.String ns, java.lang.String name)
          Finds the child node with the name specified, and returns it's text value.
static java.lang.String stringNode_untrimmed(org.w3c.dom.Node rootnode, java.lang.String ns, java.lang.String name, java.lang.String deflt)
          Finds the child node with the name specified, and returns it's text value.
static java.lang.String stringNode(org.w3c.dom.Node rootnode, java.lang.String ns, java.lang.String name)
          Finds the child node with the name specified, and returns it's text value.
static java.lang.String stringNode(org.w3c.dom.Node rootnode, java.lang.String ns, java.lang.String name, int trunclen)
          Finds the child node with the name specified, and returns it's text value.
static java.lang.String stringNode(org.w3c.dom.Node rootnode, java.lang.String ns, java.lang.String name, java.lang.String deflt)
          Finds the child node with the name specified, and returns it's text value.
static java.lang.String textFrom_untrimmed(org.w3c.dom.Node n)
          Gets the text part contained in a node...
static java.lang.String textFrom(org.w3c.dom.Node n)
          Gets the text part contained in a node...
static int timeNode(org.w3c.dom.Node rn, java.lang.String ns, java.lang.String name, int dflt)
          Scans a node as a hh:mm:ss time (or hh:mm).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NSDomTools

public NSDomTools()
Method Detail

nodeFind

public static org.w3c.dom.Node nodeFind(org.w3c.dom.Node rn,
                                        java.lang.String ns,
                                        java.lang.String name)
                                 throws java.lang.Exception
Finds a single element with the name spec'd in the node. If more than one node with the same name exists this throws an exception.

Throws:
java.lang.Exception

textFrom_untrimmed

public static java.lang.String textFrom_untrimmed(org.w3c.dom.Node n)
Gets the text part contained in a node... All text parts are obtained and concatenated with a single space.


textFrom

public static java.lang.String textFrom(org.w3c.dom.Node n)
Gets the text part contained in a node... All text parts are obtained and concatenated with a single space.


stringNode

public static java.lang.String stringNode(org.w3c.dom.Node rootnode,
                                          java.lang.String ns,
                                          java.lang.String name)
                                   throws java.lang.Exception
Finds the child node with the name specified, and returns it's text value. If the node is not found it returns null.

Throws:
java.lang.Exception

stringNode

public static java.lang.String stringNode(org.w3c.dom.Node rootnode,
                                          java.lang.String ns,
                                          java.lang.String name,
                                          int trunclen)
                                   throws java.lang.Exception
Finds the child node with the name specified, and returns it's text value. If the node is not found it returns null.

Throws:
java.lang.Exception

stringNode

public static java.lang.String stringNode(org.w3c.dom.Node rootnode,
                                          java.lang.String ns,
                                          java.lang.String name,
                                          java.lang.String deflt)
                                   throws java.lang.Exception
Finds the child node with the name specified, and returns it's text value. If the node is not found it returns the default string.

Throws:
java.lang.Exception

stringNode_untrimmed

public static java.lang.String stringNode_untrimmed(org.w3c.dom.Node rootnode,
                                                    java.lang.String ns,
                                                    java.lang.String name)
                                             throws java.lang.Exception
Finds the child node with the name specified, and returns it's text value. If the node is not found it returns null.

Throws:
java.lang.Exception

stringNode_untrimmed

public static java.lang.String stringNode_untrimmed(org.w3c.dom.Node rootnode,
                                                    java.lang.String ns,
                                                    java.lang.String name,
                                                    java.lang.String deflt)
                                             throws java.lang.Exception
Finds the child node with the name specified, and returns it's text value. If the node is not found it returns the default string.

Throws:
java.lang.Exception

dateNode

public static java.util.Date dateNode(org.w3c.dom.Node rn,
                                      java.lang.String ns,
                                      java.lang.String name)
                               throws java.lang.Exception
Throws:
java.lang.Exception

dateNode

public static java.util.Date dateNode(org.w3c.dom.Node rn,
                                      java.lang.String ns,
                                      java.lang.String name,
                                      java.util.Date dflt)
                               throws java.lang.Exception
Throws:
java.lang.Exception

timeNode

public static int timeNode(org.w3c.dom.Node rn,
                           java.lang.String ns,
                           java.lang.String name,
                           int dflt)
                    throws java.lang.Exception
Scans a node as a hh:mm:ss time (or hh:mm). The time is returned as a #seconds in the day.

Parameters:
rn -
name -
dflt -
Returns:
Throws:
java.lang.Exception

intNode

public static int intNode(org.w3c.dom.Node rootnode,
                          java.lang.String ns,
                          java.lang.String name)
                   throws java.lang.Exception
Throws:
java.lang.Exception

intNode

public static int intNode(org.w3c.dom.Node rootnode,
                          java.lang.String ns,
                          java.lang.String name,
                          int val)
                   throws java.lang.Exception
Throws:
java.lang.Exception

longNode

public static long longNode(org.w3c.dom.Node rootnode,
                            java.lang.String ns,
                            java.lang.String name)
                     throws java.lang.Exception
Throws:
java.lang.Exception

longNode

public static long longNode(org.w3c.dom.Node rootnode,
                            java.lang.String ns,
                            java.lang.String name,
                            long val)
                     throws java.lang.Exception
Throws:
java.lang.Exception

doubleNode

public static double doubleNode(org.w3c.dom.Node rootnode,
                                java.lang.String ns,
                                java.lang.String name,
                                double val)
                         throws java.lang.Exception
Throws:
java.lang.Exception

boolNode

public static boolean boolNode(org.w3c.dom.Node rootnode,
                               java.lang.String ns,
                               java.lang.String name)
                        throws java.lang.Exception
Finds the child node with the name specified, and returns it as a boolean value. If the node has NO text associated then this returns TRUE, if the node is not present then this returns false; if the node is present and has text the text field is interpreted: if numeric we return T if the number is not null; if text the value must start with T for true and F for false. All other values throw an exception.

Throws:
java.lang.Exception

getNodeAttribute

public static java.lang.String getNodeAttribute(org.w3c.dom.Node n,
                                                java.lang.String ns,
                                                java.lang.String aname,
                                                java.lang.String defval)
Get the named attribute from a node. If the attribute is not present return the default value in defval

Parameters:
n - the node to containing the attribute.
aname - the name of the attribute.
defval - the value to return if the attribute is not present,
Returns:
a string containing the attribute's value or the default.

strAttr

public static java.lang.String strAttr(org.w3c.dom.Node n,
                                       java.lang.String ns,
                                       java.lang.String aname,
                                       java.lang.String def)

intAttr

public static int intAttr(org.w3c.dom.Node n,
                          java.lang.String ns,
                          java.lang.String aname,
                          int defval)
                   throws java.lang.Exception
Throws:
java.lang.Exception

intAttr

public static int intAttr(org.w3c.dom.Node n,
                          java.lang.String ns,
                          java.lang.String aname)
                   throws java.lang.Exception
Throws:
java.lang.Exception

boolAttr

public static boolean boolAttr(org.w3c.dom.Node n,
                               java.lang.String ns,
                               java.lang.String aname)
                        throws java.lang.Exception
Throws:
java.lang.Exception

boolAttr

public static boolean boolAttr(org.w3c.dom.Node n,
                               java.lang.String ns,
                               java.lang.String aname,
                               boolean defval)
                        throws java.lang.Exception
Throws:
java.lang.Exception

getNodeAttribute

public static int getNodeAttribute(org.w3c.dom.Node n,
                                   java.lang.String ns,
                                   java.lang.String aname,
                                   int defval)
                            throws java.lang.Exception
Get the named attribute from a node. If the attribute is not present return the default value in defval

Parameters:
n - the node to containing the attribute.
aname - the name of the attribute.
defval - the value to return if the attribute is not present,
Returns:
a string containing the attribute's value or the default.
Throws:
java.lang.Exception

getStringList

public static final java.lang.String[] getStringList(org.w3c.dom.Node inn,
                                                     java.lang.String itemname)
                                              throws java.lang.Exception
Throws:
java.lang.Exception

getStringList

public static final java.util.List<java.lang.String> getStringList(org.w3c.dom.Node inn,
                                                                   java.lang.String listname,
                                                                   java.lang.String itemname)
                                                            throws java.lang.Exception
Throws:
java.lang.Exception

getRootElement

public static org.w3c.dom.Node getRootElement(org.w3c.dom.Document doc)
                                       throws java.lang.Exception
Throws:
java.lang.Exception