Class ParserUtil
- java.lang.Object
-
- org.pentaho.reporting.libraries.xmlns.common.ParserUtil
-
public class ParserUtil extends java.lang.ObjectBasic helper functions to ease up the process of parsing.- Author:
- Thomas Morgner
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanparseBoolean(java.lang.String text, boolean defaultVal)Parses a boolean.static java.lang.BooleanparseBoolean(java.lang.String value, org.xml.sax.Locator locator)Translates an boolean string ("true" or "false") into the corresponding Boolean object.static floatparseFloat(java.lang.String text, float defaultVal)Parses the stringtextinto an float.static floatparseFloat(java.lang.String text, java.lang.String message)Parses the stringtextinto an float.static floatparseFloat(java.lang.String text, java.lang.String message, org.xml.sax.Locator locator)Parses the stringtextinto an float.static intparseInt(java.lang.String text, int defaultVal)Parses an integer.static intparseInt(java.lang.String text, java.lang.String message)Parses the stringtextinto an int.static intparseInt(java.lang.String text, java.lang.String message, org.xml.sax.Locator locator)Parses the stringtextinto an int.static java.lang.StringparseString(java.lang.String text, java.lang.String defaultVal)Parses a string.
-
-
-
Method Detail
-
parseInt
public static int parseInt(java.lang.String text, java.lang.String message, org.xml.sax.Locator locator) throws org.xml.sax.SAXExceptionParses the stringtextinto an int. If text is null or does not contain a parsable value, the message given inmessageis 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:
org.xml.sax.SAXException- if there is a problem with the parsing.
-
parseInt
public static int parseInt(java.lang.String text, java.lang.String message) throws org.xml.sax.SAXExceptionParses the stringtextinto an int. If text is null or does not contain a parsable value, the message given inmessageis used to throw a SAXException.- Parameters:
text- the text to parse.message- the error message if parsing fails.- Returns:
- the int value.
- Throws:
org.xml.sax.SAXException- if there is a problem with the parsing.
-
parseInt
public static int parseInt(java.lang.String text, int defaultVal)Parses an integer.- Parameters:
text- the text to parse.defaultVal- the default value.- Returns:
- the integer.
-
parseFloat
public static float parseFloat(java.lang.String text, java.lang.String message, org.xml.sax.Locator locator) throws ParseExceptionParses the stringtextinto an float. If text is null or does not contain a parsable value, the message given inmessageis 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
public static float parseFloat(java.lang.String text, java.lang.String message) throws org.xml.sax.SAXExceptionParses the stringtextinto an float. If text is null or does not contain a parsable value, the message given inmessageis used to throw a SAXException.- Parameters:
text- the text to parse.message- the error message if parsing fails.- Returns:
- the float value.
- Throws:
org.xml.sax.SAXException- if there is a problem with the parsing.
-
parseFloat
public static float parseFloat(java.lang.String text, float defaultVal)Parses the stringtextinto an float. If text is null or does not contain a parsable value, the message given inmessageis used to throw a SAXException.- Parameters:
text- the text to parse.defaultVal- the defaultValue returned if parsing fails.- Returns:
- the float value.
-
parseBoolean
public static boolean parseBoolean(java.lang.String text, boolean defaultVal)Parses a boolean. If the stringtextcontains 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
public static java.lang.Boolean parseBoolean(java.lang.String value, org.xml.sax.Locator locator) throws ParseExceptionTranslates 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
public static java.lang.String parseString(java.lang.String text, java.lang.String defaultVal)Parses a string. If thetextis null, defaultval is returned.- Parameters:
text- the text to parse.defaultVal- the default value.- Returns:
- a string.
-
-