public class NumberParser
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static boolean |
parseBoolean(@NotNull java.lang.String str)
Parses a boolean constant.
|
static <T extends java.lang.Enum<T>> |
parseEnum(@NotNull java.lang.Class<T> class_,
@NotNull java.lang.String name,
@NotNull java.lang.String ident)
Parses an enum constant.
|
static float |
parseFloat(@NotNull java.lang.String str)
Parses a float constant.
|
static int |
parseInt(@NotNull java.lang.String string,
int defaultValue)
Converts a string into an int value.
|
static int |
parseInt(@NotNull java.lang.String string,
int defaultValue,
int minValue,
int maxValue)
Converts a string into an int value in the given bounds.
|
static long |
parseLong(@NotNull java.lang.String string,
long defaultValue)
Converts a string into a long value.
|
public static int parseInt(@NotNull @NotNull java.lang.String string, int defaultValue)
string
- the string to convertdefaultValue
- the value to return if the number is not a stringpublic static int parseInt(@NotNull @NotNull java.lang.String string, int defaultValue, int minValue, int maxValue)
string
- the string to convertdefaultValue
- the value to return if the number is not a string or
not within boundsminValue
- the bound's minimum valuemaxValue
- the bound's maximum valuepublic static long parseLong(@NotNull @NotNull java.lang.String string, long defaultValue)
string
- the string to convertdefaultValue
- the value to return if the number is not a stringpublic static float parseFloat(@NotNull @NotNull java.lang.String str) throws java.io.IOException
str
- the floating constant string to parsejava.io.IOException
- if a parsing error occurspublic static boolean parseBoolean(@NotNull @NotNull java.lang.String str) throws java.io.IOException
str
- the boolean constant string to parsejava.io.IOException
- if a parsing error occurs@NotNull public static <T extends java.lang.Enum<T>> T parseEnum(@NotNull @NotNull java.lang.Class<T> class_, @NotNull @NotNull java.lang.String name, @NotNull @NotNull java.lang.String ident) throws java.io.IOException
T
- the enum classclass_
- the enum class the enum constant belongs toname
- the enum constant to parseident
- the description of the enum class for building error
messagesjava.io.IOException
- if the enum constant does not exist