java.lang.Objectcom.realtime.crossfire.jxclient.util.NumberParser
public class NumberParser
Utility class for parsing strings into numbers.
| Constructor Summary | |
|---|---|
private |
NumberParser()
Private constructor to prevent instantiation. |
| Method Summary | ||
|---|---|---|
static boolean |
parseBoolean(java.lang.String str)
Parses a boolean constant. |
|
static
|
parseEnum(java.lang.Class<T> class_,
java.lang.String name,
java.lang.String ident)
Parses an enum constant. |
|
static float |
parseFloat(java.lang.String str)
Parses a float constant. |
|
static int |
parseInt(java.lang.String string,
int defaultValue)
Converts a string into an int value. |
|
static int |
parseInt(java.lang.String string,
int defaultValue,
int minValue,
int maxValue)
Converts a string into an int value in the given bounds. |
|
static long |
parseLong(java.lang.String string,
long defaultValue)
Converts a string into a long value. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
private NumberParser()
| Method Detail |
|---|
public static boolean parseBoolean(@NotNull
java.lang.String str)
throws java.io.IOException
str - the boolean constant string to parse
java.io.IOException - if a parsing error occurs
@NotNull
public static <T extends java.lang.Enum<T>> T parseEnum(@NotNull
java.lang.Class<T> class_,
@NotNull
java.lang.String name,
@NotNull
java.lang.String ident)
throws java.io.IOException
class_ - the enum class the enum constant belongs toname - the enum constant to parseident - the description of the enum class for building error
messages
java.io.IOException - if the enum constant does not exist
public static float parseFloat(@NotNull
java.lang.String str)
throws java.io.IOException
str - the floating constant string to parse
java.io.IOException - if a parsing error occurs
public static int parseInt(@NotNull
java.lang.String string,
int defaultValue)
string - the string to convertdefaultValue - the value to return if the number is not a string
public static int parseInt(@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 value
public static long parseLong(@NotNull
java.lang.String string,
long defaultValue)
string - the string to convertdefaultValue - the value to return if the number is not a string