2011-05-15 19:33:03 +02:00
|
|
|
package com.Acrobot.ChestShop.Utils;
|
2011-05-15 18:16:25 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks if string is a numerical value
|
2011-05-29 13:25:25 +02:00
|
|
|
*
|
2011-05-15 18:16:25 +02:00
|
|
|
* @author Acrobot
|
|
|
|
*/
|
2011-07-05 19:08:55 +02:00
|
|
|
public class uNumber {
|
2011-05-29 13:25:25 +02:00
|
|
|
public static boolean isInteger(String string) {
|
|
|
|
try {
|
2011-05-15 18:16:25 +02:00
|
|
|
Integer.parseInt(string);
|
|
|
|
return true;
|
2012-02-16 19:09:37 +01:00
|
|
|
} catch (NumberFormatException e) {
|
2011-05-15 18:16:25 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-29 13:25:25 +02:00
|
|
|
public static boolean isFloat(String string) {
|
|
|
|
try {
|
2011-05-15 18:16:25 +02:00
|
|
|
Float.parseFloat(string);
|
|
|
|
return true;
|
2012-02-16 19:09:37 +01:00
|
|
|
} catch (NumberFormatException e) {
|
2011-05-15 18:16:25 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-29 13:25:25 +02:00
|
|
|
public static boolean isDouble(String string) {
|
|
|
|
try {
|
2011-05-15 18:16:25 +02:00
|
|
|
Double.parseDouble(string);
|
|
|
|
return true;
|
2012-02-16 19:09:37 +01:00
|
|
|
} catch (NumberFormatException e) {
|
2011-05-15 18:16:25 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|