public class ParserUtil extends Object
Modifier and Type | Method and Description |
---|---|
static 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 string
text into an float. |
static float |
parseFloat(String text,
String message)
Parses the string
text into an float. |
static float |
parseFloat(String text,
String message,
Locator locator)
Parses the string
text into an float. |
static int |
parseInt(String text,
int defaultVal)
Parses an integer.
|
static int |
parseInt(String text,
String message)
Parses the string
text into an int. |
static int |
parseInt(String text,
String message,
Locator locator)
Parses the string
text into an int. |
static String |
parseString(String text,
String defaultVal)
Parses a string.
|
public static int parseInt(String text, String message, Locator locator) throws 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.locator
- the SAX locator to print meaningfull error messages.SAXException
- if there is a problem with the parsing.public static int parseInt(String text, String message) throws 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.SAXException
- if there is a problem with the parsing.public static int parseInt(String text, int defaultVal)
text
- the text to parse.defaultVal
- the default value.public static float parseFloat(String text, String message, Locator locator) throws ParseException
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.locator
- the SAX locator to print meaningfull error messages.ParseException
- if the text is no valid float number.public static float parseFloat(String text, String message) throws 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.SAXException
- if there is a problem with the parsing.public static float parseFloat(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(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 Boolean parseBoolean(String value, Locator locator) throws ParseException
value
- the string that represents the boolean.locator
- the SAX locator to print meaningfull error messages.ParseException
- if an parse error occured or the string is not 'true' or 'false'.Copyright © 2002–2017 Pentaho Corporation. All rights reserved.