public class ParseUtil extends Object
Constructor and Description |
---|
ParseUtil() |
Modifier and Type | Method and Description |
---|---|
static <T> T |
convert(Object object,
Class<T> type)
Tries to convert a given Object to the type specified
|
static <T> T |
convert(Object object,
Class<T> type,
T def)
Tries to convert a given Object to the type specified
|
static <T> T |
convert(Object object,
T def)
Tries to convert a given Object to the type specified
The default value can not be null! |
static String |
filterNumeric(String text)
Attempts to filter all non-numeric values from the text specified
- Commas are changed to dots - Text after a space is excluded - Non-digit information is erased - Prefixed text is ignored - A single dot maximum is enforced - Null input returns an empty String instead |
static boolean |
isBool(String text)
Checks if a given value is a full valid boolean
|
static boolean |
isNumeric(String text)
Checks if the given value is a full valid number
|
static <T> T |
parseArray(T[] values,
String text,
T def)
Tries to parse the text to one of the values in the array specified
|
static boolean |
parseBool(String text)
Parses the text specified to a boolean
|
static Boolean |
parseBool(String text,
Boolean def)
Parses the text specified to a boolean
|
static float |
parseByte(String text,
byte def)
Tries to parse the text specified to a byte
|
static Byte |
parseByte(String text,
Byte def)
Tries to parse the text specified to a byte
|
static double |
parseDouble(String text,
double def)
Tries to parse the text specified to a double
|
static Double |
parseDouble(String text,
Double def)
Tries to parse the text specified to a double
|
static <T> T |
parseEnum(Class<T> enumClass,
String text,
T def)
Tries to parse the text to one of the values in the Enum specified
|
static <T> T |
parseEnum(String text,
T def)
Tries to parse the text to one of the values in the Enum specified
The default value is used to obtain the class to look in, it can not be null! |
static float |
parseFloat(String text,
float def)
Tries to parse the text specified to a float
|
static Float |
parseFloat(String text,
Float def)
Tries to parse the text specified to a float
|
static int |
parseInt(String text,
int def)
Tries to parse the text specified to an int
|
static Integer |
parseInt(String text,
Integer def)
Tries to parse the text specified to an int
|
static long |
parseLong(String text,
long def)
Tries to parse the text specified to a long
|
static Long |
parseLong(String text,
Long def)
Tries to parse the text specified to a long
|
static org.bukkit.Material |
parseMaterial(String text,
org.bukkit.Material def)
Tries to parse the text to one of the values in the Material class
|
static org.bukkit.Material |
parseMaterial(String text,
org.bukkit.Material def,
boolean legacy)
Deprecated.
|
static Byte |
parseMaterialData(String text,
org.bukkit.Material material,
Byte def)
Deprecated.
|
static int |
parseMaterialData(String text,
org.bukkit.Material material,
int def)
Deprecated.
|
static float |
parseShort(String text,
short def)
Tries to parse the text specified to a short
|
static Short |
parseShort(String text,
Short def)
Tries to parse the text specified to a short
|
static long |
parseTime(String timestring)
Parses a time value from a String.
|
static org.bukkit.TreeSpecies |
parseTreeSpecies(String text,
org.bukkit.TreeSpecies def)
Tries to parse the text to one of the values in the TreeSpecies class
|
public static String filterNumeric(String text)
text
- to filterpublic static boolean isNumeric(String text)
text
- to checkpublic static boolean isBool(String text)
text
- to checkpublic static boolean parseBool(String text)
text
- to parsepublic static Boolean parseBool(String text, Boolean def)
text
- to parsedef
- value to return if the text is not a boolean expressionpublic static float parseFloat(String text, float def)
text
- to parsedef
- to return on failurepublic static Float parseFloat(String text, Float def)
text
- to parsedef
- to return on failurepublic static double parseDouble(String text, double def)
text
- to parsedef
- to return on failurepublic static Double parseDouble(String text, Double def)
text
- to parsedef
- to return on failurepublic static long parseLong(String text, long def)
text
- to parsedef
- to return on failurepublic static Long parseLong(String text, Long def)
text
- to parsedef
- to return on failurepublic static int parseInt(String text, int def)
text
- to parsedef
- to return on failurepublic static Integer parseInt(String text, Integer def)
text
- to parsedef
- to return on failurepublic static float parseShort(String text, short def)
text
- to parsedef
- to return on failurepublic static Short parseShort(String text, Short def)
text
- to parsedef
- to return on failurepublic static float parseByte(String text, byte def)
text
- to parsedef
- to return on failurepublic static Byte parseByte(String text, Byte def)
text
- to parsedef
- to return on failurepublic static long parseTime(String timestring)
timestring
- to parsepublic static <T> T parseArray(T[] values, String text, T def)
values
- array to look for a valuetext
- to parsedef
- to return on failurepublic static <T> T parseEnum(String text, T def)
text
- to parsedef
- to return on failurepublic static <T> T parseEnum(Class<T> enumClass, String text, T def)
enumClass
- to look for a valuetext
- to parsedef
- to return on failurepublic static org.bukkit.TreeSpecies parseTreeSpecies(String text, org.bukkit.TreeSpecies def)
text
- to parsedef
- to return on failurepublic static org.bukkit.Material parseMaterial(String text, org.bukkit.Material def)
text
- to parsedef
- to return on failure@Deprecated public static org.bukkit.Material parseMaterial(String text, org.bukkit.Material def, boolean legacy)
text
- def
- legacy
- @Deprecated public static Byte parseMaterialData(String text, org.bukkit.Material material, Byte def)
@Deprecated public static int parseMaterialData(String text, org.bukkit.Material material, int def)
text
- to parsematerial
- to parse the text againstdef
- to return on failure (hint: use -1)public static <T> T convert(Object object, Class<T> type)
object
- to converttype
- to convert topublic static <T> T convert(Object object, T def)
object
- to convertdef
- to return on failureCopyright © 2019. All rights reserved.