Package com.helger.commons.string
Class StringParser
- java.lang.Object
-
- com.helger.commons.string.StringParser
-
@Immutable public final class StringParser extends Object
This class contains the methods to parse String objects to numeric values. Before v3.7.0 this was contained in classStringHelper.- Author:
- Philip Helger
-
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_RADIXThe default radix used to convert string values to numeric values
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanisDouble(String sStr)Checks if the given string is a double string that can be converted to a double value.static booleanisFloat(String sStr)Checks if the given string is a float string that can be converted to a double value.static booleanisInt(String sStr)Checks if the given string is a numeric string that can be converted to a long value with radix 10.static booleanisLong(String sStr)Checks 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 booleanparseBool(Object aObject)Try to interpret the passed object as boolean.static booleanparseBool(Object aObject, boolean bDefault)Try to interpret the passed object as boolean.static booleanparseBool(String sStr)Parse the givenStringas boolean value.static booleanparseBool(String sStr, boolean bDefault)Parse 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 byteparseByte(Object aObject, byte nDefault)static byteparseByte(Object aObject, int nRadix, byte nDefault)Parse the givenObjectas byte with the specified radix.static byteparseByte(String sStr, byte nDefault)static byteparseByte(String sStr, int nRadix, byte nDefault)Parse 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 intparseInt(Object aObject, int nDefault)Parse the givenObjectas int with radixDEFAULT_RADIX.static intparseInt(Object aObject, int nRadix, int nDefault)Parse the givenObjectas int with the specified radix.static intparseInt(String sStr, int nDefault)static intparseInt(String sStr, int nRadix, int nDefault)Parse 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 longparseLong(Object aObject, int nRadix, long nDefault)Parse the givenObjectas long with the specified radix.static longparseLong(Object aObject, long nDefault)static longparseLong(String sStr, int nRadix, long nDefault)Parse the givenStringas long with the specified radix.static longparseLong(String sStr, long nDefault)static 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 Detail
-
DEFAULT_RADIX
public static final int DEFAULT_RADIX
The default radix used to convert string values to numeric values- See Also:
- Constant Field Values
-
-
Method Detail
-
parseBool
public static boolean parseBool(@Nullable Object aObject)
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
public static boolean parseBool(@Nullable Object aObject, boolean bDefault)
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
public static boolean parseBool(@Nullable String sStr)
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:
Boolean.parseBoolean(String)
-
parseBool
public static boolean parseBool(@Nullable String sStr, boolean bDefault)
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
@Nullable public static Boolean parseBoolObj(@Nullable Object aObject)
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
@Nullable public static Boolean parseBoolObj(@Nullable Object aObject, @Nullable Boolean aDefault)
- 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
@Nonnull public static Boolean parseBoolObj(@Nullable String sStr)
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
@Nullable public static Boolean parseBoolObjExact(@Nullable String sStr)
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
public static byte parseByte(@Nullable Object aObject, byte nDefault)
- 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
public static byte parseByte(@Nullable Object aObject, @Nonnegative int nRadix, byte nDefault)
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
public static byte parseByte(@Nullable String sStr, byte nDefault)
- 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
public static byte parseByte(@Nullable String sStr, @Nonnegative int nRadix, byte nDefault)
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
@Nullable public static Byte parseByteObj(@Nullable Object aObject)
- Parameters:
aObject- The object to parse. May benull.- Returns:
nullif the object does not represent a valid value.
-
parseByteObj
@Nullable public static Byte parseByteObj(@Nullable Object aObject, @Nullable Byte aDefault)
- 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
@Nullable public static Byte parseByteObj(@Nullable String sStr)
- Parameters:
sStr- The String to parse. May benull.- Returns:
nullif the string does not represent a valid value.
-
parseByteObj
@Nullable public static Byte parseByteObj(@Nullable String sStr, @Nullable Byte 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.
-
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
public static double parseDouble(@Nullable Object aObject, double dDefault)
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
public static double parseDouble(@Nullable String sStr, double dDefault)
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
@Nullable public static Double parseDoubleObj(@Nullable Object aObject)
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
@Nullable public static Double parseDoubleObj(@Nullable Object aObject, @Nullable Double aDefault)
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
@Nullable public static Double parseDoubleObj(@Nullable String sStr)
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
@Nullable public static Double parseDoubleObj(@Nullable String sStr, @Nullable Double aDefault)
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
public static float parseFloat(@Nullable Object aObject, float fDefault)
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
public static float parseFloat(@Nullable String sStr, float fDefault)
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
@Nullable public static Float parseFloatObj(@Nullable Object aObject)
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
@Nullable public static Float parseFloatObj(@Nullable Object aObject, @Nullable Float aDefault)
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
@Nullable public static Float parseFloatObj(@Nullable String sStr)
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
@Nullable public static Float parseFloatObj(@Nullable String sStr, @Nullable Float aDefault)
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
public static int parseInt(@Nullable Object aObject, int nDefault)
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
public static int parseInt(@Nullable Object aObject, @Nonnegative int nRadix, int nDefault)
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
public static int parseInt(@Nullable String sStr, int nDefault)
- 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
public static int parseInt(@Nullable String sStr, @Nonnegative int nRadix, int nDefault)
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
@Nullable public static Integer parseIntObj(@Nullable Object aObject)
- Parameters:
aObject- The object to parse. May benull.- Returns:
nullif the object does not represent a valid value.
-
parseIntObj
@Nullable public static Integer parseIntObj(@Nullable Object aObject, @Nullable Integer aDefault)
- 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
@Nullable public static Integer parseIntObj(@Nullable String sStr)
- Parameters:
sStr- The string to parse. May benull.- Returns:
nullif the string does not represent a valid value.
-
parseIntObj
@Nullable public static Integer parseIntObj(@Nullable String sStr, @Nullable Integer 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.
-
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
@Nullable public static Long parseUnsignedIntObj(@Nullable String sStr)
- Parameters:
sStr- The string to parse. May benull.- Returns:
nullif the string does not represent a valid value.- Since:
- 9.0.0
-
parseUnsignedIntObj
@Nullable public static Long parseUnsignedIntObj(@Nullable String sStr, @Nullable Long 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.- 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
public static long parseLong(@Nullable Object aObject, long nDefault)
- 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
public static long parseLong(@Nullable Object aObject, @Nonnegative int nRadix, long nDefault)
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
public static long parseLong(@Nullable String sStr, long nDefault)
- 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
public static long parseLong(@Nullable String sStr, @Nonnegative int nRadix, long nDefault)
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
@Nullable public static Long parseLongObj(@Nullable Object aObject)
- Parameters:
aObject- The object to parse. May benull.- Returns:
nullif the object does not represent a valid value.
-
parseLongObj
@Nullable public static Long parseLongObj(@Nullable Object aObject, @Nullable Long aDefault)
- 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
@Nullable public static Long parseLongObj(@Nullable String sStr)
- Parameters:
sStr- The string to parse. May benull.- Returns:
nullif the string does not represent a valid value.
-
parseLongObj
@Nullable public static Long parseLongObj(@Nullable String sStr, @Nullable Long 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.
-
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
public static short parseShort(@Nullable Object aObject, short nDefault)
- 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
public static short parseShort(@Nullable Object aObject, @Nonnegative int nRadix, short nDefault)
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
public static short parseShort(@Nullable String sStr, short nDefault)
- 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
public static short parseShort(@Nullable String sStr, @Nonnegative int nRadix, short nDefault)
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
@Nullable public static Short parseShortObj(@Nullable Object aObject)
- Parameters:
aObject- The object to parse. May benull.- Returns:
nullif the object does not represent a valid value.
-
parseShortObj
@Nullable public static Short parseShortObj(@Nullable Object aObject, @Nullable Short aDefault)
- 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
@Nullable public static Short parseShortObj(@Nullable String sStr)
- Parameters:
sStr- The string to parse. May benull.- Returns:
nullif the string does not represent a valid value.
-
parseShortObj
@Nullable public static Short parseShortObj(@Nullable String sStr, @Nullable Short 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.
-
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
@Nullable public static BigInteger parseBigInteger(@Nullable String sStr)
- Parameters:
sStr- The String to parse. May benull.- Returns:
nullif the string does not represent a valid value.
-
parseBigInteger
@Nullable public static BigInteger parseBigInteger(@Nullable String sStr, @Nonnegative int nRadix)
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
@Nullable public static BigDecimal parseBigDecimal(@Nullable String sStr)
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
public static boolean isInt(@Nullable String sStr)
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
public static boolean isLong(@Nullable String sStr)
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
public static boolean isUnsignedInt(@Nullable String sStr)
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
public static boolean isUnsignedLong(@Nullable String sStr)
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
public static boolean isDouble(@Nullable String sStr)
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
-
-