|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.bankframe.validation.DataTypeConvertor
public class DataTypeConvertor
This class provides utility methods for converting data-types.
for more information on rounding of numbers.
Field Summary | |
---|---|
static int |
ROUND_CEILING
|
static int |
ROUND_DOWN
|
static int |
ROUND_FLOOR
|
static int |
ROUND_HALF_DOWN
|
static int |
ROUND_HALF_EVEN
|
static int |
ROUND_HALF_UP
|
static int |
ROUND_UNNECESSARY
|
static int |
ROUND_UP
|
Constructor Summary | |
---|---|
DataTypeConvertor()
|
Method Summary | |
---|---|
static Boolean |
getBoolean(String value)
This method converts a String value to a Boolean value |
static Double |
getDouble(String value)
This method converts a String value to a Double value |
static Float |
getFloat(String value)
This method converts a String value to a Float value |
static Integer |
getInteger(String value)
This method converts a String value to an Integer value |
static String |
getString(Object value)
This method converts an Object value to a String value |
static String |
padString(String value,
char padChar,
int length,
boolean padRight)
This method returns a String padded with the specified amount of padding characters, to the left or to the right |
static Integer |
parseInteger(String value)
This method converts a String value to an Integer value. |
static Double |
round(Double value,
int decimalPlaces)
This method rounds up the specified value to the specified number of decimal places |
static Double |
round(Double value,
int decimalPlaces,
int roundMethod)
This method rounds the specified value to the specified number of decimal places using the specified rounding method |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int ROUND_CEILING
public static final int ROUND_DOWN
public static final int ROUND_FLOOR
public static final int ROUND_HALF_DOWN
public static final int ROUND_HALF_EVEN
public static final int ROUND_HALF_UP
public static final int ROUND_UNNECESSARY
public static final int ROUND_UP
Constructor Detail |
---|
public DataTypeConvertor()
Method Detail |
---|
public static Boolean getBoolean(String value) throws ValidationException
value
- String value to be converted
true if String equals yes, y, true, t or 1
false if String equals no, n, false, f or 0
ValidationException
- if the string cannot be converted to a Boolean valuepublic static Integer getInteger(String value) throws ValidationException
ValidationException
- if the String cannot be converted to an Integer valuepublic static Integer parseInteger(String value) throws ValidationException
value
-
ValidationException
public static Float getFloat(String value) throws ValidationException
ValidationException
- if the String cannot be converted to a Float valuepublic static Double getDouble(String value) throws ValidationException
ValidationException
- if the String cannot be converted to a Double valuepublic static String getString(Object value) throws ValidationException
ValidationException
- if the Object cannot be converted to a String valuepublic static Double round(Double value, int decimalPlaces)
value
- The value to round updecimalPlaces
- The number of decimal places to round to
public static Double round(Double value, int decimalPlaces, int roundMethod)
value
- The value to rounddecimalPlaces
- The number of decimal places to round toroundMethod
- The rounding method to use
public static String padString(String value, char padChar, int length, boolean padRight) throws ValidationException
value
- String to padpadChar
- The character to use for paddinglength
- The length of the padded StringpadRight
- If true the padding will be added to the right, otherwise
the padding will be added to the left
ValidationException
- if the value is null or too long to be padded
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |