com.bankframe.validation
Class DataTypeConvertor

java.lang.Object
  |
  +--com.bankframe.validation.DataTypeConvertor

public class DataTypeConvertor
extends java.lang.Object

This class provides utility methods for converting data-types.

See Also:
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 java.lang.Boolean getBoolean(java.lang.String value)
          This method converts a String value to a Boolean value
static java.lang.Double getDouble(java.lang.String value)
          This method converts a String value to a Double value
static java.lang.Float getFloat(java.lang.String value)
          This method converts a String value to a Float value
static java.lang.Integer getInteger(java.lang.String value)
          This method converts a String value to an Integer value
static java.lang.String getString(java.lang.Object value)
          This method converts an Object value to a String value
static java.lang.String padString(java.lang.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 java.lang.Integer parseInteger(java.lang.String value)
          This method converts a String value to an Integer value.
static java.lang.Double round(java.lang.Double value, int decimalPlaces)
          This method rounds up the specified value to the specified number of decimal places
static java.lang.Double round(java.lang.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

ROUND_CEILING

public static final int ROUND_CEILING
See Also:
Constant Field Values

ROUND_DOWN

public static final int ROUND_DOWN
See Also:
Constant Field Values

ROUND_FLOOR

public static final int ROUND_FLOOR
See Also:
Constant Field Values

ROUND_HALF_DOWN

public static final int ROUND_HALF_DOWN
See Also:
Constant Field Values

ROUND_HALF_EVEN

public static final int ROUND_HALF_EVEN
See Also:
Constant Field Values

ROUND_HALF_UP

public static final int ROUND_HALF_UP
See Also:
Constant Field Values

ROUND_UNNECESSARY

public static final int ROUND_UNNECESSARY
See Also:
Constant Field Values

ROUND_UP

public static final int ROUND_UP
See Also:
Constant Field Values
Constructor Detail

DataTypeConvertor

public DataTypeConvertor()
Method Detail

getBoolean

public static java.lang.Boolean getBoolean(java.lang.String value)
                                    throws ValidationException
This method converts a String value to a Boolean value

Parameters:
value - String value to be converted
Returns:
Boolean

true if String equals yes, y, true, t or 1

false if String equals no, n, false, f or 0

Throws:
ValidationException - if the string cannot be converted to a Boolean value

getInteger

public static java.lang.Integer getInteger(java.lang.String value)
                                    throws ValidationException
This method converts a String value to an Integer value

Returns:
Integer instance if successful
Throws:
ValidationException - if the String cannot be converted to an Integer value

parseInteger

public static java.lang.Integer parseInteger(java.lang.String value)
                                      throws ValidationException
This method converts a String value to an Integer value. This method unlike the getInteger() method assumes the value is base 10 and will not interpret radix specifiers. This method should be used where leading zeros are present in a base 10 string. A String with a leading zero specifies to the getInteger() method that the value to be converted is radix 8.

Parameters:
value -
Returns:
@throws ValidationException
ValidationException

getFloat

public static java.lang.Float getFloat(java.lang.String value)
                                throws ValidationException
This method converts a String value to a Float value

Returns:
Float instance if successful
Throws:
ValidationException - if the String cannot be converted to a Float value

getDouble

public static java.lang.Double getDouble(java.lang.String value)
                                  throws ValidationException
This method converts a String value to a Double value

Returns:
Double instance if successful
Throws:
ValidationException - if the String cannot be converted to a Double value

getString

public static java.lang.String getString(java.lang.Object value)
                                  throws ValidationException
This method converts an Object value to a String value

Returns:
String instance if successful
Throws:
ValidationException - if the Object cannot be converted to a String value

round

public static java.lang.Double round(java.lang.Double value,
                                     int decimalPlaces)
This method rounds up the specified value to the specified number of decimal places

Parameters:
value - The value to round up
decimalPlaces - The number of decimal places to round to
Returns:
Double rounded to the specified number of decimal places

round

public static java.lang.Double round(java.lang.Double value,
                                     int decimalPlaces,
                                     int roundMethod)
This method rounds the specified value to the specified number of decimal places using the specified rounding method

Parameters:
value - The value to round
decimalPlaces - The number of decimal places to round to
roundMethod - The rounding method to use
Returns:
The rounded value

padString

public static java.lang.String padString(java.lang.String value,
                                         char padChar,
                                         int length,
                                         boolean padRight)
                                  throws ValidationException
This method returns a String padded with the specified amount of padding characters, to the left or to the right

Parameters:
value - String to pad
padChar - The character to use for padding
length - The length of the padded String
padRight - If true the padding will be added to the right, otherwise the padding will be added to the left
Returns:
Padded String
Throws:
ValidationException - if the value is null or too long to be padded


Copyright © 2005 Siebel Systems, Inc. All rights reserved.