Package com.helger.commons.string
Class StringParser
java.lang.Object
com.helger.commons.string.StringParser
This class contains the methods to parse String objects to numeric values.
Before v3.7.0 this was contained in class
StringHelper.- Author:
- Philip Helger
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe default radix used to convert string values to numeric values -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanChecks if the given string is a double string that can be converted to a double value.static booleanChecks if the given string is a float string that can be converted to a double value.static booleanChecks if the given string is a numeric string that can be converted to a long value with radix 10.static booleanChecks if the given string is a numeric string that can be converted to a long value with radix 10.static booleanisUnsignedInt(String sStr) Checks if the given string is a numeric string that can be converted to an unsigned long value with radix 10.static booleanisUnsignedLong(String sStr) Checks if the given string is a numeric string that can be converted to an unsigned long value with radix 10.static BigDecimalparseBigDecimal(String sStr) Parse the givenStringasBigDecimal.static BigDecimalparseBigDecimal(String sStr, int nScale, RoundingMode eRoundingMode) Parse the givenStringasBigDecimal.static BigDecimalparseBigDecimal(String sStr, int nScale, RoundingMode eRoundingMode, BigDecimal aDefault) Parse the givenStringasBigDecimal.static BigDecimalparseBigDecimal(String sStr, BigDecimal aDefault) Parse the givenStringasBigDecimal.static BigIntegerparseBigInteger(String sStr) static BigIntegerparseBigInteger(String sStr, int nRadix) Parse the givenStringasBigIntegerwith the specified radix.static BigIntegerparseBigInteger(String sStr, int nRadix, BigInteger aDefault) Parse the givenStringasBigIntegerwith the specified radix.static BigIntegerparseBigInteger(String sStr, BigInteger aDefault) static booleanTry to interpret the passed object as boolean.static booleanTry to interpret the passed object as boolean.static booleanParse the givenStringas boolean value.static booleanParse the givenStringas boolean value.static BooleanparseBoolObj(Object aObject) Try to interpret the passed object as boolean.static BooleanparseBoolObj(Object aObject, Boolean aDefault) static BooleanparseBoolObj(String sStr) Returns aBooleanwith a value represented by the specified string.static BooleanparseBoolObjExact(String sStr) Returns aBooleanwith a value represented by the specified string.static BooleanparseBoolObjExact(String sStr, Boolean aDefault) Returns aBooleanwith a value represented by the specified string.static bytestatic byteParse the givenObjectas byte with the specified radix.static bytestatic byteParse the givenStringas byte with the specified radix.static ByteparseByteObj(Object aObject) static ByteparseByteObj(Object aObject, int nRadix, Byte aDefault) static ByteparseByteObj(Object aObject, Byte aDefault) static ByteparseByteObj(String sStr) static ByteparseByteObj(String sStr, int nRadix, Byte aDefault) static ByteparseByteObj(String sStr, Byte aDefault) static doubleparseDouble(Object aObject, double dDefault) Parse the givenObjectas double.static doubleparseDouble(String sStr, double dDefault) Parse the givenStringas double.static DoubleparseDoubleObj(Object aObject) static DoubleparseDoubleObj(Object aObject, Double aDefault) static DoubleparseDoubleObj(String sStr) static DoubleparseDoubleObj(String sStr, Double aDefault) static floatparseFloat(Object aObject, float fDefault) Parse the givenObjectas float.static floatparseFloat(String sStr, float fDefault) Parse the givenStringas float.static FloatparseFloatObj(Object aObject) static FloatparseFloatObj(Object aObject, Float aDefault) static FloatparseFloatObj(String sStr) static FloatparseFloatObj(String sStr, Float aDefault) static intParse the givenObjectas int with radixDEFAULT_RADIX.static intParse the givenObjectas int with the specified radix.static intstatic intParse the givenStringas int with the specified radix.static IntegerparseIntObj(Object aObject) static IntegerparseIntObj(Object aObject, int nRadix, Integer aDefault) static IntegerparseIntObj(Object aObject, Integer aDefault) static IntegerparseIntObj(String sStr) static IntegerparseIntObj(String sStr, int nRadix, Integer aDefault) static IntegerparseIntObj(String sStr, Integer aDefault) static longParse the givenObjectas long with the specified radix.static longstatic longParse the givenStringas long with the specified radix.static longstatic LongparseLongObj(Object aObject) static LongparseLongObj(Object aObject, int nRadix, Long aDefault) static LongparseLongObj(Object aObject, Long aDefault) static LongparseLongObj(String sStr) static LongparseLongObj(String sStr, int nRadix, Long aDefault) static LongparseLongObj(String sStr, Long aDefault) static shortparseShort(Object aObject, int nRadix, short nDefault) Parse the givenObjectas short with the specified radix.static shortparseShort(Object aObject, short nDefault) static shortparseShort(String sStr, int nRadix, short nDefault) Parse the givenStringas short with the specified radix.static shortparseShort(String sStr, short nDefault) static ShortparseShortObj(Object aObject) static ShortparseShortObj(Object aObject, int nRadix, Short aDefault) static ShortparseShortObj(Object aObject, Short aDefault) static ShortparseShortObj(String sStr) static ShortparseShortObj(String sStr, int nRadix, Short aDefault) static ShortparseShortObj(String sStr, Short aDefault) static LongparseUnsignedIntObj(String sStr) static LongparseUnsignedIntObj(String sStr, int nRadix, Long aDefault) static LongparseUnsignedIntObj(String sStr, Long aDefault)
-
Field Details
-
DEFAULT_RADIX
public static final int DEFAULT_RADIXThe default radix used to convert string values to numeric values- See Also:
-
-
Method Details
-
parseBool
Try to interpret the passed object as boolean. This works only if the passed object is either aStringor aBoolean.- Parameters:
aObject- The object to be interpreted. May benull.- Returns:
falseif the passed object cannot be interpreted as a boolean.
-
parseBool
Try to interpret the passed object as boolean. This works only if the passed object is either aStringor aBoolean.- Parameters:
aObject- The object to be interpreted. May benull.bDefault- The default value to be returned, if the object cannot be interpreted.- Returns:
- The boolean representation or the default value if the passed object cannot be interpreted as a boolean.
-
parseBool
Parse the givenStringas boolean value. All values that are equal to "true" (ignoring case) will result intruereturn values. All other values result infalsereturn values. This method is equal toBoolean.parseBoolean(String)- Parameters:
sStr- The string to be interpreted. May benull.- Returns:
trueif the passed string matches "true" (ignoring case),falseotherwise.- See Also:
-
parseBool
Parse the givenStringas boolean value. All values that are equal to "true" (ignoring case) will result intruereturn values. All values that are equal to "false" (ignoring case) will result infalsereturn values. All other values will return the default.- Parameters:
sStr- The string to be interpreted. May benull.bDefault- The default value to be returned if the passed string is neither "true" nor "false".- Returns:
trueorfalse:)
-
parseBoolObj
Try to interpret the passed object as boolean. This works only if the passed object is either aStringor aBoolean.- Parameters:
aObject- The object to be interpreted. May benull.- Returns:
nullif the passed object cannot be interpreted as a boolean, any otherBooleanotherwise.
-
parseBoolObj
- Parameters:
aObject- The object to be interpreted. May benull.aDefault- The default value to be returned, if the passed object isnull.- Returns:
- The passed default value if the passed object is
null, the matchingBooleanotherwise.
-
parseBoolObj
Returns aBooleanwith a value represented by the specified string. TheBooleanreturned represents atruevalue if the string argument is notnulland is equal, ignoring case, to the string"true". This method is equal toBoolean.valueOf(String)- Parameters:
sStr- The string to be parsed. May benull.- Returns:
- the
Booleanvalue represented by the string. Nevernull.
-
parseBoolObjExact
Returns aBooleanwith a value represented by the specified string. TheBooleanreturned represents atruevalue if the string argument is notnulland is equal, ignoring case, to the string"true", and it will returnfalseif the string argument is notnulland is equal, ignoring case, to the string"false". In all other casesnullis returned.- Parameters:
sStr- The string to be parsed. May benull.- Returns:
- the
Booleanvalue represented by the string. Nevernull.
-
parseBoolObjExact
@Nullable public static Boolean parseBoolObjExact(@Nullable String sStr, @Nullable Boolean aDefault) Returns aBooleanwith a value represented by the specified string. TheBooleanreturned represents atruevalue if the string argument is notnulland is equal, ignoring case, to the string"true", and it will returnfalseif the string argument is notnulland is equal, ignoring case, to the string"false". In all other casesaDefaultis returned.- Parameters:
sStr- The string to be parsed. May benull.aDefault- The default value to be returned if the value is neither "true" nor "false". May benull.- Returns:
- the
Booleanvalue represented by the string. Nevernull.
-
parseByte
- Parameters:
aObject- The Object to parse. May benull.nDefault- The default value to be returned if the passed object could not be converted to a valid value.- Returns:
- The default value if the string does not represent a valid value.
-
parseByte
Parse the givenObjectas byte with the specified radix.- Parameters:
aObject- The Object to parse. May benull.nRadix- The radix to use. Must be ≥Character.MIN_RADIXand ≤Character.MAX_RADIX.nDefault- The default value to be returned if the passed object could not be converted to a valid value.- Returns:
- The default value if the string does not represent a valid value.
-
parseByte
- Parameters:
sStr- The String to parse. May benull.nDefault- The value to be returned if the string cannot be converted to a valid value.- Returns:
- The passed default parameter if the string does not represent a valid value.
-
parseByte
Parse the givenStringas byte with the specified radix.- Parameters:
sStr- The String to parse. May benull.nRadix- The radix to use. Must be ≥Character.MIN_RADIXand ≤Character.MAX_RADIX.nDefault- The value to be returned if the string cannot be converted to a valid value.- Returns:
- The passed default parameter if the string does not represent a valid value.
-
parseByteObj
- Parameters:
aObject- The object to parse. May benull.- Returns:
nullif the object does not represent a valid value.
-
parseByteObj
- Parameters:
aObject- The object to parse. May benull.aDefault- The default value to be returned, if the passed object cannot be converted. May benull.- Returns:
- the passed default value if the object does not represent a valid value.
-
parseByteObj
@Nullable public static Byte parseByteObj(@Nullable Object aObject, @Nonnegative int nRadix, @Nullable Byte aDefault) - Parameters:
aObject- The object to parse. May benull.nRadix- The radix to use. Must be ≥Character.MIN_RADIXand ≤Character.MAX_RADIX.aDefault- The default value to be returned, if the passed object cannot be converted. May benull.- Returns:
- the passed default value if the object does not represent a valid value.
-
parseByteObj
- Parameters:
sStr- The String to parse. May benull.- Returns:
nullif the string does not represent a valid value.
-
parseByteObj
- Parameters:
sStr- The String to parse. May benull.aDefault- The default value to be returned if the passed string could not be converted to a valid value. May benull.- Returns:
aDefaultif the string does not represent a valid value.
-
parseByteObj
@Nullable public static Byte parseByteObj(@Nullable String sStr, @Nonnegative int nRadix, @Nullable Byte aDefault) - Parameters:
sStr- The String to parse. May benull.nRadix- The radix to use. Must be ≥Character.MIN_RADIXand ≤Character.MAX_RADIX.aDefault- The default value to be returned if the passed string could not be converted to a valid value. May benull.- Returns:
aDefaultif the string does not represent a valid value.
-
parseDouble
Parse the givenObjectas double. Note: both the locale independent form of a double can be parsed here (e.g. 4.523) as well as a localized form using the comma as the decimal separator (e.g. the German 4,523).- Parameters:
aObject- The object to parse. May benull.dDefault- The default value to be returned if the passed object could not be converted to a valid value.- Returns:
- The default value if the object does not represent a valid value.
-
parseDouble
Parse the givenStringas double.- Parameters:
sStr- The string to parse. May benull.dDefault- The default value to be returned if the passed object could not be converted to a valid value.- Returns:
- The default value if the string does not represent a valid value.
-
parseDoubleObj
Parse the givenObjectasDouble. Note: both the locale independent form of a double can be parsed here (e.g. 4.523) as well as a localized form using the comma as the decimal separator (e.g. the German 4,523).- Parameters:
aObject- The object to parse. May benull.- Returns:
nullif the object does not represent a valid value.
-
parseDoubleObj
Parse the givenObjectasDouble. Note: both the locale independent form of a double can be parsed here (e.g. 4.523) as well as a localized form using the comma as the decimal separator (e.g. the German 4,523).- Parameters:
aObject- The object to parse. May benull.aDefault- The default value to be returned if the parsed object cannot be converted to a double. May benull.- Returns:
aDefaultif the object does not represent a valid value.
-
parseDoubleObj
Parse the givenStringasDouble. Note: both the locale independent form of a double can be parsed here (e.g. 4.523) as well as a localized form using the comma as the decimal separator (e.g. the German 4,523).- Parameters:
sStr- The string to parse. May benull.- Returns:
nullif the object does not represent a valid value.
-
parseDoubleObj
Parse the givenStringasDouble. Note: both the locale independent form of a double can be parsed here (e.g. 4.523) as well as a localized form using the comma as the decimal separator (e.g. the German 4,523).- Parameters:
sStr- The string to parse. May benull.aDefault- The default value to be returned if the parsed string cannot be converted to a double. May benull.- Returns:
aDefaultif the object does not represent a valid value.
-
parseFloat
Parse the givenObjectas float. Note: both the locale independent form of a float can be parsed here (e.g. 4.523) as well as a localized form using the comma as the decimal separator (e.g. the German 4,523).- Parameters:
aObject- The object to parse. May benull.fDefault- The default value to be returned if the passed object could not be converted to a valid value.- Returns:
- The default value if the object does not represent a valid value.
-
parseFloat
Parse the givenStringas float.- Parameters:
sStr- The string to parse. May benull.fDefault- The default value to be returned if the passed object could not be converted to a valid value.- Returns:
- The default value if the string does not represent a valid value.
-
parseFloatObj
Parse the givenObjectasFloat. Note: both the locale independent form of a double can be parsed here (e.g. 4.523) as well as a localized form using the comma as the decimal separator (e.g. the German 4,523).- Parameters:
aObject- The object to parse. May benull.- Returns:
nullif the object does not represent a valid value.
-
parseFloatObj
Parse the givenObjectasFloat. Note: both the locale independent form of a double can be parsed here (e.g. 4.523) as well as a localized form using the comma as the decimal separator (e.g. the German 4,523).- Parameters:
aObject- The object to parse. May benull.aDefault- The default value to be returned if the parsed object cannot be converted to a float. May benull.- Returns:
aDefaultif the object does not represent a valid value.
-
parseFloatObj
Parse the givenStringasFloat. Note: both the locale independent form of a double can be parsed here (e.g. 4.523) as well as a localized form using the comma as the decimal separator (e.g. the German 4,523).- Parameters:
sStr- The string to parse. May benull.- Returns:
nullif the object does not represent a valid value.
-
parseFloatObj
Parse the givenStringasFloat. Note: both the locale independent form of a double can be parsed here (e.g. 4.523) as well as a localized form using the comma as the decimal separator (e.g. the German 4,523).- Parameters:
sStr- The string to parse. May benull.aDefault- The default value to be returned if the parsed string cannot be converted to a float. May benull.- Returns:
aDefaultif the object does not represent a valid value.
-
parseInt
Parse the givenObjectas int with radixDEFAULT_RADIX.- Parameters:
aObject- The Object to parse. May benull.nDefault- The default value to be returned if the passed object could not be converted to a valid value.- Returns:
- The default value if the string does not represent a valid value.
-
parseInt
Parse the givenObjectas int with the specified radix.- Parameters:
aObject- The object to parse. May benull.nRadix- The radix to use. Must be ≥Character.MIN_RADIXand ≤Character.MAX_RADIX.nDefault- The default value to be returned if the passed object could not be converted to a valid value.- Returns:
- The default value if the string does not represent a valid value.
-
parseInt
- Parameters:
sStr- The String to parse. May benull.nDefault- The value to be returned if the string cannot be converted to a valid value.- Returns:
- The passed default parameter if the string does not represent a valid value.
-
parseInt
Parse the givenStringas int with the specified radix.- Parameters:
sStr- The String to parse. May benull.nRadix- The radix to use. Must be ≥Character.MIN_RADIXand ≤Character.MAX_RADIX.nDefault- The value to be returned if the string cannot be converted to a valid value.- Returns:
- The passed default parameter if the string does not represent a valid value.
-
parseIntObj
- Parameters:
aObject- The object to parse. May benull.- Returns:
nullif the object does not represent a valid value.
-
parseIntObj
- Parameters:
aObject- The object to parse. May benull.aDefault- The default value to be returned if the passed object cannot be converted to an Integer. May benull.- Returns:
aDefaultif the object does not represent a valid value.
-
parseIntObj
@Nullable public static Integer parseIntObj(@Nullable Object aObject, @Nonnegative int nRadix, @Nullable Integer aDefault) - Parameters:
aObject- The object to parse. May benull.nRadix- The radix to use. Must be ≥Character.MIN_RADIXand ≤Character.MAX_RADIX.aDefault- The default value to be returned if the passed object cannot be converted to an Integer. May benull.- Returns:
aDefaultif the object does not represent a valid value.
-
parseIntObj
- Parameters:
sStr- The string to parse. May benull.- Returns:
nullif the string does not represent a valid value.
-
parseIntObj
- Parameters:
sStr- The string to parse. May benull.aDefault- The default value to be returned if the passed string could not be converted to a valid value. May benull.- Returns:
aDefaultif the string does not represent a valid value.
-
parseIntObj
@Nullable public static Integer parseIntObj(@Nullable String sStr, @Nonnegative int nRadix, @Nullable Integer aDefault) - Parameters:
sStr- The string to parse. May benull.nRadix- The radix to use. Must be ≥Character.MIN_RADIXand ≤Character.MAX_RADIX.aDefault- The default value to be returned if the passed string could not be converted to a valid value. May benull.- Returns:
aDefaultif the string does not represent a valid value.
-
parseUnsignedIntObj
- Parameters:
sStr- The string to parse. May benull.- Returns:
nullif the string does not represent a valid value.- Since:
- 9.0.0
-
parseUnsignedIntObj
- Parameters:
sStr- The string to parse. May benull.aDefault- The default value to be returned if the passed string could not be converted to a valid value. May benull.- Returns:
aDefaultif the string does not represent a valid value.- Since:
- 9.0.0
-
parseUnsignedIntObj
@Nullable public static Long parseUnsignedIntObj(@Nullable String sStr, @Nonnegative int nRadix, @Nullable Long aDefault) - Parameters:
sStr- The string to parse. May benull.nRadix- The radix to use. Must be ≥Character.MIN_RADIXand ≤Character.MAX_RADIX.aDefault- The default value to be returned if the passed string could not be converted to a valid value. May benull.- Returns:
aDefaultif the string does not represent a valid value.- Since:
- 9.0.0
-
parseLong
- Parameters:
aObject- The object to parse. May benull.nDefault- The default value to be returned if the passed object could not be converted to a valid value.- Returns:
- The default value if the object does not represent a valid value.
-
parseLong
Parse the givenObjectas long with the specified radix.- Parameters:
aObject- The object to parse. May benull.nRadix- The radix to use. Must be ≥Character.MIN_RADIXand ≤Character.MAX_RADIX.nDefault- The default value to be returned if the passed object could not be converted to a valid value.- Returns:
- The default value if the object does not represent a valid value.
-
parseLong
- Parameters:
sStr- The string to parse. May benull.nDefault- The default value to be returned if the passed object could not be converted to a valid value.- Returns:
- The default if the string does not represent a valid value.
-
parseLong
Parse the givenStringas long with the specified radix.- Parameters:
sStr- The string to parse. May benull.nRadix- The radix to use. Must be ≥Character.MIN_RADIXand ≤Character.MAX_RADIX.nDefault- The default value to be returned if the passed object could not be converted to a valid value.- Returns:
- The default if the string does not represent a valid value.
-
parseLongObj
- Parameters:
aObject- The object to parse. May benull.- Returns:
nullif the object does not represent a valid value.
-
parseLongObj
- Parameters:
aObject- The object to parse. May benull.aDefault- The default value to be returned if the passed object cannot be converted to a Long. May benull.- Returns:
aDefaultif the object does not represent a valid value.
-
parseLongObj
@Nullable public static Long parseLongObj(@Nullable Object aObject, @Nonnegative int nRadix, @Nullable Long aDefault) - Parameters:
aObject- The object to parse. May benull.nRadix- The radix to use. Must be ≥Character.MIN_RADIXand ≤Character.MAX_RADIX.aDefault- The default value to be returned if the passed object cannot be converted to a Long. May benull.- Returns:
aDefaultif the object does not represent a valid value.
-
parseLongObj
- Parameters:
sStr- The string to parse. May benull.- Returns:
nullif the string does not represent a valid value.
-
parseLongObj
- Parameters:
sStr- The string to parse. May benull.aDefault- The default value to be returned if the passed string could not be converted to a valid value. May benull.- Returns:
aDefaultif the string does not represent a valid value.
-
parseLongObj
@Nullable public static Long parseLongObj(@Nullable String sStr, @Nonnegative int nRadix, @Nullable Long aDefault) - Parameters:
sStr- The string to parse. May benull.nRadix- The radix to use. Must be ≥Character.MIN_RADIXand ≤Character.MAX_RADIX.aDefault- The default value to be returned if the passed string could not be converted to a valid value. May benull.- Returns:
aDefaultif the string does not represent a valid value.
-
parseShort
- Parameters:
aObject- The object to parse. May benull.nDefault- The default value to be returned if the passed object could not be converted to a valid value.- Returns:
- The default value if the object does not represent a valid value.
-
parseShort
Parse the givenObjectas short with the specified radix.- Parameters:
aObject- The object to parse. May benull.nRadix- The radix to use. Must be ≥Character.MIN_RADIXand ≤Character.MAX_RADIX.nDefault- The default value to be returned if the passed object could not be converted to a valid value.- Returns:
- The default value if the object does not represent a valid value.
-
parseShort
- Parameters:
sStr- The string to parse. May benull.nDefault- The default value to be returned if the passed object could not be converted to a valid value.- Returns:
- The default if the string does not represent a valid value.
-
parseShort
Parse the givenStringas short with the specified radix.- Parameters:
sStr- The string to parse. May benull.nRadix- The radix to use. Must be ≥Character.MIN_RADIXand ≤Character.MAX_RADIX.nDefault- The default value to be returned if the passed object could not be converted to a valid value.- Returns:
- The default if the string does not represent a valid value.
-
parseShortObj
- Parameters:
aObject- The object to parse. May benull.- Returns:
nullif the object does not represent a valid value.
-
parseShortObj
- Parameters:
aObject- The object to parse. May benull.aDefault- The default value to be returned if the passed object cannot be converted to a Short. May benull.- Returns:
aDefaultif the object does not represent a valid value.
-
parseShortObj
@Nullable public static Short parseShortObj(@Nullable Object aObject, @Nonnegative int nRadix, @Nullable Short aDefault) - Parameters:
aObject- The object to parse. May benull.nRadix- The radix to use. Must be ≥Character.MIN_RADIXand ≤Character.MAX_RADIX.aDefault- The default value to be returned if the passed object cannot be converted to a Short. May benull.- Returns:
aDefaultif the object does not represent a valid value.
-
parseShortObj
- Parameters:
sStr- The string to parse. May benull.- Returns:
nullif the string does not represent a valid value.
-
parseShortObj
- Parameters:
sStr- The string to parse. May benull.aDefault- The default value to be returned if the passed string could not be converted to a valid value. May benull.- Returns:
aDefaultif the string does not represent a valid value.
-
parseShortObj
@Nullable public static Short parseShortObj(@Nullable String sStr, @Nonnegative int nRadix, @Nullable Short aDefault) - Parameters:
sStr- The string to parse. May benull.nRadix- The radix to use. Must be ≥Character.MIN_RADIXand ≤Character.MAX_RADIX.aDefault- The default value to be returned if the passed string could not be converted to a valid value. May benull.- Returns:
aDefaultif the string does not represent a valid value.
-
parseBigInteger
- Parameters:
sStr- The String to parse. May benull.- Returns:
nullif the string does not represent a valid value.
-
parseBigInteger
Parse the givenStringasBigIntegerwith the specified radix.- Parameters:
sStr- The String to parse. May benull.nRadix- The radix to use. Must be ≥Character.MIN_RADIXand ≤Character.MAX_RADIX.- Returns:
nullif the string does not represent a valid value.
-
parseBigInteger
@Nullable public static BigInteger parseBigInteger(@Nullable String sStr, @Nullable BigInteger aDefault) - Parameters:
sStr- The String to parse. May benull.aDefault- The default value to be returned if the passed string could not be converted to a valid value. May benull.- Returns:
aDefaultif the string does not represent a valid value.
-
parseBigInteger
@Nullable public static BigInteger parseBigInteger(@Nullable String sStr, @Nonnegative int nRadix, @Nullable BigInteger aDefault) Parse the givenStringasBigIntegerwith the specified radix.- Parameters:
sStr- The String to parse. May benull.nRadix- The radix to use. Must be ≥Character.MIN_RADIXand ≤Character.MAX_RADIX.aDefault- The default value to be returned if the passed string could not be converted to a valid value. May benull.- Returns:
aDefaultif the string does not represent a valid value.
-
parseBigDecimal
Parse the givenStringasBigDecimal.- Parameters:
sStr- The String to parse. May benull.- Returns:
nullif the string does not represent a valid value.
-
parseBigDecimal
@Nullable public static BigDecimal parseBigDecimal(@Nullable String sStr, @Nullable BigDecimal aDefault) Parse the givenStringasBigDecimal.- Parameters:
sStr- The String to parse. May benull.aDefault- The default value to be returned if the passed string could not be converted to a valid value. May benull.- Returns:
aDefaultif the string does not represent a valid value.
-
parseBigDecimal
@Nullable public static BigDecimal parseBigDecimal(@Nullable String sStr, @Nonnegative int nScale, @Nonnull RoundingMode eRoundingMode) Parse the givenStringasBigDecimal.- Parameters:
sStr- The String to parse. May benull.nScale- The scaling (decimal places) to be used for the result. Must be ≥ 0!eRoundingMode- The rounding mode to be used to achieve the scale. May not benull.- Returns:
nullif the string does not represent a valid value.
-
parseBigDecimal
@Nullable public static BigDecimal parseBigDecimal(@Nullable String sStr, @Nonnegative int nScale, @Nonnull RoundingMode eRoundingMode, @Nullable BigDecimal aDefault) Parse the givenStringasBigDecimal.- Parameters:
sStr- The String to parse. May benull.nScale- The scaling (decimal places) to be used for the result. Must be ≥ 0!eRoundingMode- The rounding mode to be used to achieve the scale. May not benull.aDefault- The default value to be returned if the passed string could not be converted to a valid value. May benull.- Returns:
aDefaultif the string does not represent a valid value.
-
isInt
Checks if the given string is a numeric string that can be converted to a long value with radix 10.- Parameters:
sStr- The string to check. May benull.- Returns:
trueif the value can be converted to a valid value
-
isLong
Checks if the given string is a numeric string that can be converted to a long value with radix 10.- Parameters:
sStr- The string to check. May benull.- Returns:
trueif the value can be converted to a valid value
-
isUnsignedInt
Checks if the given string is a numeric string that can be converted to an unsigned long value with radix 10.- Parameters:
sStr- The string to check. May benull.- Returns:
trueif the value can be converted to a valid value
-
isUnsignedLong
Checks if the given string is a numeric string that can be converted to an unsigned long value with radix 10.- Parameters:
sStr- The string to check. May benull.- Returns:
trueif the value can be converted to a valid value
-
isDouble
Checks if the given string is a double string that can be converted to a double value.- Parameters:
sStr- The string to check. May benull.- Returns:
trueif the value can be converted to a valid value
-
isFloat
Checks if the given string is a float string that can be converted to a double value.- Parameters:
sStr- The string to check. May benull.- Returns:
trueif the value can be converted to a valid value
-