kitfox-svg-core
1.0.0-build001 / 2012-04-07T15:40:49.711-0500

com.kitfox.svg.xml
Class XMLParseUtil

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

public class XMLParseUtil
extends Object

Author:
Mark McKay, Mark McKay

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


getFirstChild

public static Element getFirstChild(Element root,
                                    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 String[] parseStringList(String list)

isDouble

public static boolean isDouble(String val)

parseDouble

public static double parseDouble(String val)

findDouble

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


parseDoubleList

public static double[] parseDoubleList(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(String val)

findFloat

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


parseFloatList

public static float[] parseFloatList(String list)

parseInt

public static int parseInt(String val)

findInt

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


parseIntList

public static int[] parseIntList(String list)

parseRatio

public static double parseRatio(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(String val)

getAttribString

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


getAttribInt

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


getAttribIntHex

public static int getAttribIntHex(Element ele,
                                  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(Element ele,
                                   String name)
Parses the given attribute of this tag and returns it as a float


getAttribDouble

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


getAttribBoolean

public static boolean getAttribBoolean(Element ele,
                                       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 URL getAttribURL(Element ele,
                               String name,
                               URL docRoot)

getElement

public static ReadableXMLElement getElement(Class classType,
                                            Element root,
                                            String name,
                                            URL docRoot)
Returns the first ReadableXMLElement with the given name


getElementHashMap

public static HashMap getElementHashMap(Class classType,
                                        Element root,
                                        String name,
                                        String key,
                                        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 HashSet getElementHashSet(Class classType,
                                        Element root,
                                        String name,
                                        URL docRoot)

getElementLinkedList

public static LinkedList getElementLinkedList(Class classType,
                                              Element root,
                                              String name,
                                              URL docRoot)

getElementArray

public static Object[] getElementArray(Class classType,
                                       Element root,
                                       String name,
                                       URL docRoot)

getElementArrayInt

public static int[] getElementArrayInt(Element root,
                                       String name,
                                       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 String[] getElementArrayString(Element root,
                                             String name,
                                             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 HashMap parseStyle(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 HashMap parseStyle(String styleString,
                                 HashMap map)
Takes a CSS style string and returns 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

kitfox-svg-core
1.0.0-build001 / 2012-04-07T15:40:49.711-0500

Copyright © 2011-2012 Barchart, Inc.. All Rights Reserved.