com.inxar.syntacs.util
Class DOM

java.lang.Object
  |
  +--com.inxar.syntacs.util.DOM

public class DOM
extends Object

Collection of utilities useful for working with XML DOM trees.


Method Summary
static void escape(StringBuffer b)
          Modifies the StringBuffer argument such that any '<', '>', '&' characters are escaped by their entity reference counterparts.
static org.w3c.dom.Element get(int index, org.w3c.dom.NodeList nodes)
           
static boolean getBoolean(String name, org.w3c.dom.Element e)
           
static byte getByte(String name, org.w3c.dom.Element e)
           
static char getChar(String name, org.w3c.dom.Element e)
           
static org.w3c.dom.Document getDocument(String uri, boolean validate)
          Attempts to instantiate an XML document from the given URI using three different parsers.
static double getDouble(String name, org.w3c.dom.Element e)
           
static Iterator getElements(String name, org.w3c.dom.Element e)
           
static org.w3c.dom.Element getFirstChildElement(org.w3c.dom.Element e)
          Fetches the first child that is an Element.
static float getFloat(String name, org.w3c.dom.Element e)
           
static int getInt(String name, org.w3c.dom.Element e)
           
static long getLong(String name, org.w3c.dom.Element e)
           
static org.w3c.dom.Element getRoot(String uri, boolean validate)
           
static short getShort(String name, org.w3c.dom.Element e)
           
static String getString(String name, org.w3c.dom.Element e)
           
static StringTokenizer getStrings(String name, org.w3c.dom.Element e)
          Returns a tokeinzer over a set of comma-delimited strings.
static String getText(org.w3c.dom.Element e)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getRoot

public static org.w3c.dom.Element getRoot(String uri,
                                          boolean validate)
                                   throws Exception

getDocument

public static org.w3c.dom.Document getDocument(String uri,
                                               boolean validate)
                                        throws ClassNotFoundException
Attempts to instantiate an XML document from the given URI using three different parsers. The first attempt is for Sun's JAXP-1.0.1's javax.xml.parsers.DocumentBuilderFactory, the second attempt is for Xerces-1.2.3's org.apache.xerces.parsers.DOMParser, and the third attempt is for Sun's xml-tr2's com.sun.xml.tree.XmlDocument. If all attempts fail, a ClassNotFoundException will be thrown.

getFirstChildElement

public static org.w3c.dom.Element getFirstChildElement(org.w3c.dom.Element e)
Fetches the first child that is an Element.

getText

public static String getText(org.w3c.dom.Element e)

getString

public static String getString(String name,
                               org.w3c.dom.Element e)

getBoolean

public static boolean getBoolean(String name,
                                 org.w3c.dom.Element e)

getChar

public static char getChar(String name,
                           org.w3c.dom.Element e)

getByte

public static byte getByte(String name,
                           org.w3c.dom.Element e)
                    throws NumberFormatException

getShort

public static short getShort(String name,
                             org.w3c.dom.Element e)
                      throws NumberFormatException

getInt

public static int getInt(String name,
                         org.w3c.dom.Element e)
                  throws NumberFormatException

getLong

public static long getLong(String name,
                           org.w3c.dom.Element e)
                    throws NumberFormatException

getFloat

public static float getFloat(String name,
                             org.w3c.dom.Element e)
                      throws NumberFormatException

getDouble

public static double getDouble(String name,
                               org.w3c.dom.Element e)
                        throws NumberFormatException

getStrings

public static StringTokenizer getStrings(String name,
                                         org.w3c.dom.Element e)
Returns a tokeinzer over a set of comma-delimited strings.

escape

public static void escape(StringBuffer b)
Modifies the StringBuffer argument such that any '<', '>', '&' characters are escaped by their entity reference counterparts.

get

public static org.w3c.dom.Element get(int index,
                                      org.w3c.dom.NodeList nodes)

getElements

public static Iterator getElements(String name,
                                   org.w3c.dom.Element e)