|
3.1.1: 2012-03-29 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.sf.basedb.core.IntegerUtil
public class IntegerUtil
Utility methods that will make it easier to implement data validation for integer attributes.
| Constructor Summary | |
|---|---|
IntegerUtil()
|
|
| Method Summary | |
|---|---|
static int |
checkMax(int value,
String name,
int maxValue)
Check that an integer is equal or lower than a maximum value. |
static int |
checkMin(int value,
String name,
int minValue)
Check that an integer is equal or greater than a minimum value. |
static int |
checkMinMax(int value,
String name,
int minValue,
int maxValue)
Check that an integer is equal or between a minimum and a maximum value. |
static int |
getInt(Integer value)
Get the value of an Integer. |
static int |
getInt(Integer value,
int defaultValue)
Get the value of an Integer. |
static int |
getInt(String value)
Get the int value of an String. |
static int |
getInt(String value,
int defaultValue)
Get the int value of an String. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public IntegerUtil()
| Method Detail |
|---|
public static int getInt(String value)
String. If the String
couldn't be parsed 0 is returned.
value - The Integer
Integer or 0 if it is not parseable
public static int getInt(String value,
int defaultValue)
String. If the String
couldn't be parsed default value is returned.
value - The IntegerdefaultValue - Default value to return if the parsing fails.
Integer or defaultValue if it is not parseablepublic static int getInt(Integer value)
Integer.
value - The Integer
Integer or 0 if it is null
public static int getInt(Integer value,
int defaultValue)
Integer.
value - The IntegerdefaultValue - The default value to return if the value is null
Integer or defaultValue if it is null
public static int checkMin(int value,
String name,
int minValue)
throws NumberOutOfRangeException
value - The value to checkname - The name of the attribute to use if an exception is thrownminValue - The minimum allowed value
NumberOutOfRangeException - If the value lower than the minimum
public static int checkMax(int value,
String name,
int maxValue)
throws NumberOutOfRangeException
value - The value to checkname - The name of the attribute to use if an exception is thrownmaxValue - The maximum allowed value
NumberOutOfRangeException - If the value greater than the maximum
public static int checkMinMax(int value,
String name,
int minValue,
int maxValue)
throws NumberOutOfRangeException
value - The value to checkname - The name of the attribute to use if an exception is thrownminValue - The minimum allowed valuemaxValue - The maximum allowed value
NumberOutOfRangeException - If the value is outside the range
|
3.1.1: 2012-03-29 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||