Class ParserUtil
java.lang.Object
org.pentaho.reporting.libraries.xmlns.common.ParserUtil
Basic helper functions to ease up the process of parsing.
- Author:
- Thomas Morgner
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
parseBoolean
(String text, boolean defaultVal) Parses a boolean.static Boolean
parseBoolean
(String value, Locator locator) Translates an boolean string ("true" or "false") into the corresponding Boolean object.static float
parseFloat
(String text, float defaultVal) Parses the stringtext
into an float.static float
parseFloat
(String text, String message) Parses the stringtext
into an float.static float
parseFloat
(String text, String message, Locator locator) Parses the stringtext
into an float.static int
Parses an integer.static int
Parses the stringtext
into an int.static int
Parses the stringtext
into an int.static String
parseString
(String text, String defaultVal) Parses a string.
-
Method Details
-
parseInt
Parses the stringtext
into an int. If text is null or does not contain a parsable value, the message given inmessage
is used to throw a SAXException.- Parameters:
text
- the text to parse.message
- the error message if parsing fails.locator
- the SAX locator to print meaningfull error messages.- Returns:
- the int value.
- Throws:
SAXException
- if there is a problem with the parsing.
-
parseInt
Parses the stringtext
into an int. If text is null or does not contain a parsable value, the message given inmessage
is used to throw a SAXException.- Parameters:
text
- the text to parse.message
- the error message if parsing fails.- Returns:
- the int value.
- Throws:
SAXException
- if there is a problem with the parsing.
-
parseInt
Parses an integer.- Parameters:
text
- the text to parse.defaultVal
- the default value.- Returns:
- the integer.
-
parseFloat
Parses the stringtext
into an float. If text is null or does not contain a parsable value, the message given inmessage
is used to throw a SAXException.- Parameters:
text
- the text to parse.message
- the error message if parsing fails.locator
- the SAX locator to print meaningfull error messages.- Returns:
- the float value.
- Throws:
ParseException
- if the text is no valid float number.
-
parseFloat
Parses the stringtext
into an float. If text is null or does not contain a parsable value, the message given inmessage
is used to throw a SAXException.- Parameters:
text
- the text to parse.message
- the error message if parsing fails.- Returns:
- the float value.
- Throws:
SAXException
- if there is a problem with the parsing.
-
parseFloat
Parses the stringtext
into an float. If text is null or does not contain a parsable value, the message given inmessage
is used to throw a SAXException.- Parameters:
text
- the text to parse.defaultVal
- the defaultValue returned if parsing fails.- Returns:
- the float value.
-
parseBoolean
Parses a boolean. If the stringtext
contains the value of "true", the true value is returned, else false is returned.- Parameters:
text
- the text to parse.defaultVal
- the default value.- Returns:
- a boolean.
-
parseBoolean
Translates an boolean string ("true" or "false") into the corresponding Boolean object.- Parameters:
value
- the string that represents the boolean.locator
- the SAX locator to print meaningfull error messages.- Returns:
- Boolean.TRUE or Boolean.FALSE
- Throws:
ParseException
- if an parse error occured or the string is not 'true' or 'false'.
-
parseString
Parses a string. If thetext
is null, defaultval is returned.- Parameters:
text
- the text to parse.defaultVal
- the default value.- Returns:
- a string.
-