public class ParserUtil extends java.lang.Object
Constructor and Description |
---|
ParserUtil() |
Modifier and Type | Method and Description |
---|---|
static java.awt.geom.Rectangle2D |
getElementPosition(org.xml.sax.Attributes atts)
Parses an element position.
|
static boolean |
parseBoolean(java.lang.String text,
boolean defaultVal)
Parses a boolean.
|
static java.awt.Color |
parseColor(java.lang.String color)
Parses a color entry.
|
static java.awt.Color |
parseColor(java.lang.String color,
java.awt.Color defaultValue)
Parses a color entry.
|
static float |
parseFloat(java.lang.String text,
float defaultVal)
Parses the string
text into an float. |
static float |
parseFloat(java.lang.String text,
java.lang.String message)
Parses the string
text into an float. |
static int |
parseInt(java.lang.String text,
int defaultVal)
Parses an integer.
|
static int |
parseInt(java.lang.String text,
java.lang.String message)
Parses the string
text into an int. |
static float |
parseRelativeFloat(java.lang.String value,
java.lang.String exceptionMessage)
Parses a position of an element.
|
static java.lang.String |
parseString(java.lang.String text,
java.lang.String defaultVal)
Parses a string.
|
static java.awt.Stroke |
parseStroke(java.lang.String weight)
Creates a basic stroke given the width contained as float in the given string.
|
public ParserUtil()
public static int parseInt(java.lang.String text, java.lang.String message) throws org.xml.sax.SAXException
text
into an int. If text is null or does not
contain a parsable value, the message given in message
is used to
throw a SAXException.text
- the text to parse.message
- the error message if parsing fails.org.xml.sax.SAXException
- if there is a problem with the parsing.public static int parseInt(java.lang.String text, int defaultVal)
text
- the text to parse.defaultVal
- the default value.public static float parseFloat(java.lang.String text, java.lang.String message) throws org.xml.sax.SAXException
text
into an float. If text is null or does not
contain a parsable value, the message given in message
is used to
throw a SAXException.text
- the text to parse.message
- the error message if parsing fails.org.xml.sax.SAXException
- if there is a problem with the parsing.public static float parseFloat(java.lang.String text, float defaultVal)
text
into an float. If text is null or does not
contain a parsable value, the message given in message
is used to
throw a SAXException.text
- the text to parse.defaultVal
- the defaultValue returned if parsing fails.public static boolean parseBoolean(java.lang.String text, boolean defaultVal)
text
contains the value of "true", the
true value is returned, else false is returned.text
- the text to parse.defaultVal
- the default value.public static java.lang.String parseString(java.lang.String text, java.lang.String defaultVal)
text
is null, defaultval is returned.text
- the text to parse.defaultVal
- the default value.public static java.awt.Stroke parseStroke(java.lang.String weight)
weight
- a string containing a number (the stroke weight).public static java.awt.Color parseColor(java.lang.String color)
As fallback the color black is returned if no color can be parsed.
color
- the color (as a string).public static java.awt.Color parseColor(java.lang.String color, java.awt.Color defaultValue)
As fallback the supplied default value is returned if no color can be parsed.
color
- the color (as a string).defaultValue
- the default value (returned if no color can be parsed).public static float parseRelativeFloat(java.lang.String value, java.lang.String exceptionMessage) throws org.xml.sax.SAXException
value
- the value.exceptionMessage
- the exception message.org.xml.sax.SAXException
- if there is a problem parsing the string.public static java.awt.geom.Rectangle2D getElementPosition(org.xml.sax.Attributes atts) throws org.xml.sax.SAXException
atts
- the attributes.org.xml.sax.SAXException
- if there is a problem getting the element position.