com.kitfox.svg.xml
Class XMLParseUtil

java.lang.Object
  extended by com.kitfox.svg.xml.XMLParseUtil

public class XMLParseUtil
extends java.lang.Object

Author:
Mark McKay, Mark McKay

Method Summary
static double findDouble(java.lang.String val)
          Searches the given string for the first floating point number it contains, parses and returns it.
static float findFloat(java.lang.String val)
          Searches the given string for the first floating point number it contains, parses and returns it.
static int findInt(java.lang.String val)
          Searches the given string for the first integer point number it contains, parses and returns it.
static boolean getAttribBoolean(org.w3c.dom.Element ele, java.lang.String name)
          Parses the given attribute of this tag and returns it as a boolean.
static double getAttribDouble(org.w3c.dom.Element ele, java.lang.String name)
          Parses the given attribute of this tag and returns it as a double.
static float getAttribFloat(org.w3c.dom.Element ele, java.lang.String name)
          Parses the given attribute of this tag and returns it as a float
static int getAttribInt(org.w3c.dom.Element ele, java.lang.String name)
          Parses the given attribute of this tag and returns it as an int.
static int getAttribIntHex(org.w3c.dom.Element ele, java.lang.String name)
          Parses the given attribute of this tag as a hexadecimal encoded string and returns it as an int
static java.lang.String getAttribString(org.w3c.dom.Element ele, java.lang.String name)
          Parses the given attribute of this tag and returns it as a String.
static java.net.URL getAttribURL(org.w3c.dom.Element ele, java.lang.String name, java.net.URL docRoot)
           
static ReadableXMLElement getElement(java.lang.Class classType, org.w3c.dom.Element root, java.lang.String name, java.net.URL docRoot)
          Returns the first ReadableXMLElement with the given name
static java.lang.Object[] getElementArray(java.lang.Class classType, org.w3c.dom.Element root, java.lang.String name, java.net.URL docRoot)
           
static int[] getElementArrayInt(org.w3c.dom.Element root, java.lang.String name, java.lang.String attrib)
          Takes a number of tags of name 'name' that are children of 'root', and looks for attributes of 'attrib' on them.
static java.lang.String[] getElementArrayString(org.w3c.dom.Element root, java.lang.String name, java.lang.String attrib)
          Takes a number of tags of name 'name' that are children of 'root', and looks for attributes of 'attrib' on them.
static java.util.HashMap getElementHashMap(java.lang.Class classType, org.w3c.dom.Element root, java.lang.String name, java.lang.String key, java.net.URL docRoot)
          Returns a HashMap of nodes that are children of root.
static java.util.HashSet getElementHashSet(java.lang.Class classType, org.w3c.dom.Element root, java.lang.String name, java.net.URL docRoot)
           
static java.util.LinkedList getElementLinkedList(java.lang.Class classType, org.w3c.dom.Element root, java.lang.String name, java.net.URL docRoot)
           
static org.w3c.dom.Element getFirstChild(org.w3c.dom.Element root, java.lang.String name)
          Returns the first node that is a direct child of root with the coresponding name.
static java.lang.String getTagText(org.w3c.dom.Element ele)
          Scans the tag's children and returns the first text element found
static boolean isDouble(java.lang.String val)
           
static double parseDouble(java.lang.String val)
           
static double[] parseDoubleList(java.lang.String list)
          Scans an input string for double values.
static float parseFloat(java.lang.String val)
           
static float[] parseFloatList(java.lang.String list)
           
static int parseInt(java.lang.String val)
           
static int[] parseIntList(java.lang.String list)
           
static NumberWithUnits parseNumberWithUnits(java.lang.String val)
           
static double parseRatio(java.lang.String val)
          The input string represents a ratio.
static java.lang.String[] parseStringList(java.lang.String list)
           
static java.util.HashMap parseStyle(java.lang.String styleString)
          Takes a CSS style string and retursn a hash of them.
static java.util.HashMap parseStyle(java.lang.String styleString, java.util.HashMap map)
          Takes a CSS style string and retursn a hash of them.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getTagText

public static java.lang.String getTagText(org.w3c.dom.Element ele)
Scans the tag's children and returns the first text element found


getFirstChild

public static org.w3c.dom.Element getFirstChild(org.w3c.dom.Element root,
                                                java.lang.String name)
Returns the first node that is a direct child of root with the coresponding name. Does not search children of children.


parseStringList

public static java.lang.String[] parseStringList(java.lang.String list)

isDouble

public static boolean isDouble(java.lang.String val)

parseDouble

public static double parseDouble(java.lang.String val)

findDouble

public static double findDouble(java.lang.String val)
Searches the given string for the first floating point number it contains, parses and returns it.


parseDoubleList

public static double[] parseDoubleList(java.lang.String list)
Scans an input string for double values. For each value found, places in a list. This method regards any characters not part of a floating point value to be seperators. Thus this will parse whitespace seperated, comma seperated, and many other separation schemes correctly.


parseFloat

public static float parseFloat(java.lang.String val)

findFloat

public static float findFloat(java.lang.String val)
Searches the given string for the first floating point number it contains, parses and returns it.


parseFloatList

public static float[] parseFloatList(java.lang.String list)

parseInt

public static int parseInt(java.lang.String val)

findInt

public static int findInt(java.lang.String val)
Searches the given string for the first integer point number it contains, parses and returns it.


parseIntList

public static int[] parseIntList(java.lang.String list)

parseRatio

public static double parseRatio(java.lang.String val)
The input string represents a ratio. Can either be specified as a double number on the range of [0.0 1.0] or as a percentage [0% 100%]


parseNumberWithUnits

public static NumberWithUnits parseNumberWithUnits(java.lang.String val)

getAttribString

public static java.lang.String getAttribString(org.w3c.dom.Element ele,
                                               java.lang.String name)
Parses the given attribute of this tag and returns it as a String.


getAttribInt

public static int getAttribInt(org.w3c.dom.Element ele,
                               java.lang.String name)
Parses the given attribute of this tag and returns it as an int.


getAttribIntHex

public static int getAttribIntHex(org.w3c.dom.Element ele,
                                  java.lang.String name)
Parses the given attribute of this tag as a hexadecimal encoded string and returns it as an int


getAttribFloat

public static float getAttribFloat(org.w3c.dom.Element ele,
                                   java.lang.String name)
Parses the given attribute of this tag and returns it as a float


getAttribDouble

public static double getAttribDouble(org.w3c.dom.Element ele,
                                     java.lang.String name)
Parses the given attribute of this tag and returns it as a double.


getAttribBoolean

public static boolean getAttribBoolean(org.w3c.dom.Element ele,
                                       java.lang.String name)
Parses the given attribute of this tag and returns it as a boolean. Essentially compares the lower case textual value to the string "true"


getAttribURL

public static java.net.URL getAttribURL(org.w3c.dom.Element ele,
                                        java.lang.String name,
                                        java.net.URL docRoot)

getElement

public static ReadableXMLElement getElement(java.lang.Class classType,
                                            org.w3c.dom.Element root,
                                            java.lang.String name,
                                            java.net.URL docRoot)
Returns the first ReadableXMLElement with the given name


getElementHashMap

public static java.util.HashMap getElementHashMap(java.lang.Class classType,
                                                  org.w3c.dom.Element root,
                                                  java.lang.String name,
                                                  java.lang.String key,
                                                  java.net.URL docRoot)
Returns a HashMap of nodes that are children of root. All nodes will be of class classType and have a tag name of 'name'. 'key' is an attribute of tag 'name' who's string value will be used as the key in the HashMap


getElementHashSet

public static java.util.HashSet getElementHashSet(java.lang.Class classType,
                                                  org.w3c.dom.Element root,
                                                  java.lang.String name,
                                                  java.net.URL docRoot)

getElementLinkedList

public static java.util.LinkedList getElementLinkedList(java.lang.Class classType,
                                                        org.w3c.dom.Element root,
                                                        java.lang.String name,
                                                        java.net.URL docRoot)

getElementArray

public static java.lang.Object[] getElementArray(java.lang.Class classType,
                                                 org.w3c.dom.Element root,
                                                 java.lang.String name,
                                                 java.net.URL docRoot)

getElementArrayInt

public static int[] getElementArrayInt(org.w3c.dom.Element root,
                                       java.lang.String name,
                                       java.lang.String attrib)
Takes a number of tags of name 'name' that are children of 'root', and looks for attributes of 'attrib' on them. Converts attributes to an int and returns in an array.


getElementArrayString

public static java.lang.String[] getElementArrayString(org.w3c.dom.Element root,
                                                       java.lang.String name,
                                                       java.lang.String attrib)
Takes a number of tags of name 'name' that are children of 'root', and looks for attributes of 'attrib' on them. Converts attributes to an int and returns in an array.


parseStyle

public static java.util.HashMap parseStyle(java.lang.String styleString)
Takes a CSS style string and retursn a hash of them.

Parameters:
styleString - - A CSS formatted string of styles. Eg, "font-size:12;fill:#d32c27;fill-rule:evenodd;stroke-width:1pt;"

parseStyle

public static java.util.HashMap parseStyle(java.lang.String styleString,
                                           java.util.HashMap map)
Takes a CSS style string and retursn a hash of them.

Parameters:
styleString - - A CSS formatted string of styles. Eg, "font-size:12;fill:#d32c27;fill-rule:evenodd;stroke-width:1pt;"
map - - A map to which these styles will be added