com.ibm.dse.tools.workbench.tbg
Class TbgValidator

java.lang.Object
  |
  +--com.ibm.dse.tools.workbench.tbg.TbgValidator

public class TbgValidator
extends java.lang.Object

Class that allows to parse and format between String objects and different types of objects.


Field Summary
protected static java.text.SimpleDateFormat dateFormat
          This field stores the format used to format dates using the mask provided in datePattern field.
protected static java.lang.String datePattern
          This field stores the date mask to format the dates
protected static Types externalValidator
          This field stores an external formatter/parser.
protected static java.text.NumberFormat numberFormat
          This field stores the format used to format decimals using the mask provided in decimalPattern field.
protected static java.lang.String numberPattern
          This field stores the decimal mask to format the decimals
 
Constructor Summary
TbgValidator()
          This constructor creates a TypeValidator object.
 
Method Summary
static java.lang.String format(java.lang.Object anObject)
          Formats anObject to a String format.
static java.lang.String formatBoolean(java.lang.Boolean aBoolean)
          Formats a Boolean object to a String format.
static java.lang.String formatChar(char aChar)
          Formats a Character object to a String format.
static java.lang.String formatChar(java.lang.Character aChar)
          Formats a Character object to a String format.
static java.lang.String formatColor(java.awt.Color aColor)
          Formats a java.awt.Color object to a String format.
static java.lang.String formatDate(java.util.Date aDate)
          Formats a java.util.Date object to a String format.
static java.lang.String formatDouble(java.lang.Double aDouble)
          Formats a Double object to a String format.
static java.lang.String formatFile(java.io.File aFile)
          Formats a File object to a String format.
static java.lang.String formatFloat(java.lang.Float aFloat)
          Formats a Float object to a String format.
static java.lang.String formatFont(java.awt.Font aFont)
          Formats a Font object to a String format.
static java.lang.String formatInteger(java.lang.Integer anInteger)
          Formats a Integer object to a String format.
static java.lang.String formatJavaInitializationString(com.ibm.dse.tools.workbench.util.JavaInitializationString aJavaInitString)
          Formats a JavaInitializationString object to a String format.
static java.lang.String formatLong(java.lang.Long aLong)
          Formats a Long object to a String format.
static java.lang.String formatRectangle(java.awt.Rectangle aRectangle)
          Formats a java.awt.Rectangle object to a String format.
static java.lang.String formatShort(java.lang.Short aShort)
          Formats a Short object to a String format.
static java.lang.String formatString(java.lang.String aString)
          Formats a String object to a String format.
static java.lang.String formatURL(java.net.URL aURL)
          Formats a java.net.URL object to a String format.
static boolean isBoolean(java.lang.String aBoolean)
          Returns true if is possible to formataBoolean String to a Boolean object.
static boolean isCharacter(java.lang.String aCharacter)
          Returns true if is possible to formataCharacter String to a Character object.
static boolean isColor(java.lang.String aColor)
          Returns true if is possible to formataColor String to a Color object.
static boolean isDate(java.lang.String aDate)
          Returns true if is possible to formataDate String to a Date value.
static boolean isDouble(java.lang.String aDouble)
          Returns true if is possible to formataDouble String to a Double object.
static boolean isFile(java.lang.String aFile)
          Returns true if is possible to formataFile String to a File object.
static boolean isFloat(java.lang.String aFloat)
          Returns true if is possible to formataFloat String to a Float object.
static boolean isFont(java.lang.String aFont)
          Returns true if is possible to formataFont String to a Font object.
static boolean isInteger(java.lang.String aInteger)
          Returns true if is possible to formataInteger String to a Integer object.
static boolean isJavaInitializationString(java.lang.String aString)
          Returns true if is possible to formataString String to a JavaInitializationString object.
static boolean isLong(java.lang.String aLong)
          Returns true if is possible to formataLong String to a Long object.
static boolean isRectangle(java.lang.String aRectangle)
          Returns true if is possible to formataRectangle String to a Rectangle object.
static boolean isShort(java.lang.String aShort)
          Returns true if is possible to formataShort String to a Short object.
static boolean isString(java.lang.String aString)
          Returns true if is possible to formataString String to a String object.
static boolean isURL(java.lang.String aURL)
          Returns true if is possible to formataURL String to a URL object.
static java.lang.Object parse(java.lang.String aString, java.lang.String aType)
          Parses aString String to a aType object.
static boolean parseToBoolean(java.lang.String aBoolean)
          Parses aBoolean String to a boolean object.
static java.lang.Character parseToCharacter(java.lang.String aString)
          Parses aString String to a Character object.
static java.awt.Color parseToColor(java.lang.String aString)
          Parses aString String to a java.awt.Color object.
static java.util.Date parseToDate(java.lang.String aString)
          Parses aString String to a java.util.Dater object.
static java.lang.Double parseToDouble(java.lang.String aString)
          Parses aString String to a Double object.
static java.io.File parseToFile(java.lang.String fileName)
          Parses fileName String to a java.io.File object.
static java.lang.Float parseToFloat(java.lang.String aString)
          Parses aString String to a Float object.
static java.awt.Font parseToFont(java.lang.String fontValues)
          Parses fontValues String to a java.awt.Font object.
static java.lang.Integer parseToInteger(java.lang.String aString)
          Parses aString String to a Integer object.
static com.ibm.dse.tools.workbench.util.JavaInitializationString parseToJavaInitializationString(java.lang.String aString)
          Parses aString String to a JavaInitializationString object.
static java.lang.Long parseToLong(java.lang.String aString)
          Parses aString String to a Long object.
static java.awt.Rectangle parseToRectangle(java.lang.String aString)
          Parses aString String to a java.awt.Rectangle object.
static java.lang.Short parseToShort(java.lang.String aString)
          Parses aString String to a Short object.
static java.net.URL parseToURL(java.lang.String aString)
          Parses aString String to a java.net.URL object.
static void setDatePattern(java.lang.String aPattern)
          Sets the Date Pattern.
static void setNumberPattern(java.lang.String aPattern)
          Sets the Decimal Pattern.
static void setValidator(Types aType)
          Sets an external type validator to use replacing the default provided one
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

datePattern

protected static java.lang.String datePattern
This field stores the date mask to format the dates

dateFormat

protected static java.text.SimpleDateFormat dateFormat
This field stores the format used to format dates using the mask provided in datePattern field.

numberPattern

protected static java.lang.String numberPattern
This field stores the decimal mask to format the decimals

numberFormat

protected static java.text.NumberFormat numberFormat
This field stores the format used to format decimals using the mask provided in decimalPattern field.

externalValidator

protected static Types externalValidator
This field stores an external formatter/parser.
Constructor Detail

TbgValidator

public TbgValidator()
This constructor creates a TypeValidator object.
Method Detail

format

public static java.lang.String format(java.lang.Object anObject)
                               throws FormatException
Formats anObject to a String format.
Parameters:
Object - anObject The object to be formated.
Returns:
java.lang.String - The string format of anObject.
Throws:
FormatException - The object can not be formated.

formatBoolean

public static java.lang.String formatBoolean(java.lang.Boolean aBoolean)
Formats a Boolean object to a String format.
Parameters:
aBoolean - java.lang.Boolean The object to be formated
Returns:
java.lang.String - The string format of Boolean.

formatChar

public static java.lang.String formatChar(char aChar)
                                   throws FormatException
Formats a Character object to a String format.
Parameters:
aChar - char The object to be formated.
Returns:
java.lang.String - The string format of Character.
Throws:
FormatException - The object can not be formated.

formatChar

public static java.lang.String formatChar(java.lang.Character aChar)
                                   throws FormatException
Formats a Character object to a String format.
Parameters:
aChar - java.lang.Character The object to be formated
Returns:
java.lang.String - The string format of Character.
Throws:
FormatException - The object can not be formated.

formatColor

public static java.lang.String formatColor(java.awt.Color aColor)
                                    throws FormatException
Formats a java.awt.Color object to a String format.
Parameters:
aColor - java.awt.Color The object to be formated
Returns:
java.lang.String - The string format of java.awt.Color.
Throws:
FormatException - The object can not be formated.

formatDate

public static java.lang.String formatDate(java.util.Date aDate)
                                   throws FormatException
Formats a java.util.Date object to a String format.
Parameters:
aDate - java.util.Date The object to be formated
Returns:
java.lang.String - The string format of java.util.Date.
Throws:
FormatException - The object can not be formated.

formatDouble

public static java.lang.String formatDouble(java.lang.Double aDouble)
                                     throws FormatException
Formats a Double object to a String format.
Parameters:
aDouble - java.lang.Double The object to be formated
Returns:
java.lang.String - The string format of Double.
Throws:
FormatException - The object can not be formated.

formatFile

public static java.lang.String formatFile(java.io.File aFile)
                                   throws FormatException
Formats a File object to a String format.
Parameters:
aFile - java.io.File The object to be formated
Returns:
java.lang.String - The string format of File .
Throws:
FormatException - The object can not be formated.

formatFloat

public static java.lang.String formatFloat(java.lang.Float aFloat)
                                    throws FormatException
Formats a Float object to a String format.
Parameters:
aFloat - java.lang.Float The object to be formated
Returns:
java.lang.String - The string format of Float .
Throws:
FormatException - The object can not be formated.

formatFont

public static java.lang.String formatFont(java.awt.Font aFont)
                                   throws FormatException
Formats a Font object to a String format.
Parameters:
aFont - java.awt.Font The object to be formated
Returns:
java.lang.String - The string format of Font.
Throws:
FormatException - The object can not be formated.

formatInteger

public static java.lang.String formatInteger(java.lang.Integer anInteger)
                                      throws FormatException
Formats a Integer object to a String format.
Parameters:
anInteger - java.lang.Integer The object to be formated
Returns:
java.lang.String - The string format of Integer .
Throws:
com.ibm.dse.tools.workbench.base.com.ibm.dse.tools.workbench.base.FormatException - The object can not be formated.

formatJavaInitializationString

public static java.lang.String formatJavaInitializationString(com.ibm.dse.tools.workbench.util.JavaInitializationString aJavaInitString)
Formats a JavaInitializationString object to a String format.
Parameters:
aJavaInitString - com.ibm.dse.tools.workbench.util.JavaInitializationString The object to be formated
Returns:
java.lang.String - The string format of boolean.

formatLong

public static java.lang.String formatLong(java.lang.Long aLong)
                                   throws FormatException
Formats a Long object to a String format.
Parameters:
aLong - java.lang.Long The object to be formated
Returns:
java.lang.String - The string format of Long .
Throws:
FormatException - The object can not be formated.

formatRectangle

public static java.lang.String formatRectangle(java.awt.Rectangle aRectangle)
                                        throws FormatException
Formats a java.awt.Rectangle object to a String format.
Parameters:
aRectangle - java.awt.Rectangle The object to be formated
Returns:
java.lang.String - The string format of java.awt.Rectangle .
Throws:
FormatException - The object can not be formated.

formatShort

public static java.lang.String formatShort(java.lang.Short aShort)
                                    throws FormatException
Formats a Short object to a String format.
Parameters:
aShort - java.lang.Short The object to be formated
Returns:
java.lang.String - The string format of Short .
Throws:
FormatException - The object can not be formated.

formatString

public static java.lang.String formatString(java.lang.String aString)
Formats a String object to a String format.
Parameters:
aString - java.lang.String The object to be formated
Returns:
java.lang.String - The string format of String .

formatURL

public static java.lang.String formatURL(java.net.URL aURL)
                                  throws FormatException
Formats a java.net.URL object to a String format.
Parameters:
aURL - java.net.URL The object to be formated
Returns:
java.lang.String - The string format of java.net.URL .
Throws:
FormatException - The object can not be formated.

isBoolean

public static boolean isBoolean(java.lang.String aBoolean)
Returns true if is possible to formataBoolean String to a Boolean object.
Parameters:
aBoolean - java.lang.String The object to ckeck.
Returns:
boolean - The boolean value.

isCharacter

public static boolean isCharacter(java.lang.String aCharacter)
Returns true if is possible to formataCharacter String to a Character object.
Parameters:
aCharacter - java.lang.String The object to ckeck.
Returns:
boolean - The boolean value.

isColor

public static boolean isColor(java.lang.String aColor)
Returns true if is possible to formataColor String to a Color object.
Parameters:
aColor - java.lang.String The object to ckeck.
Returns:
boolean - The boolean value.

isDate

public static boolean isDate(java.lang.String aDate)
Returns true if is possible to formataDate String to a Date value.
Parameters:
aDate - java.lang.String The object to ckeck.
Returns:
boolean - The boolean value.

isDouble

public static boolean isDouble(java.lang.String aDouble)
Returns true if is possible to formataDouble String to a Double object.
Parameters:
aDouble - java.lang.String The object to ckeck.
Returns:
boolean - The boolean value.

isFile

public static boolean isFile(java.lang.String aFile)
Returns true if is possible to formataFile String to a File object.
Parameters:
aFile - java.lang.String The object to ckeck.
Returns:
boolean - The boolean value.

isFloat

public static boolean isFloat(java.lang.String aFloat)
Returns true if is possible to formataFloat String to a Float object.
Parameters:
aFloat - java.lang.String The object to ckeck.
Returns:
boolean - The boolean value.

isFont

public static boolean isFont(java.lang.String aFont)
Returns true if is possible to formataFont String to a Font object.
Parameters:
aFont - java.lang.String The object to ckeck.
Returns:
boolean - The boolean value.

isInteger

public static boolean isInteger(java.lang.String aInteger)
Returns true if is possible to formataInteger String to a Integer object.
Parameters:
aInteger - java.lang.String The object to ckeck.
Returns:
boolean - The boolean value.

isJavaInitializationString

public static boolean isJavaInitializationString(java.lang.String aString)
Returns true if is possible to formataString String to a JavaInitializationString object.
Parameters:
aString - java.lang.String The object to ckeck.
Returns:
boolean - The boolean value.

isLong

public static boolean isLong(java.lang.String aLong)
Returns true if is possible to formataLong String to a Long object.
Parameters:
aLong - java.lang.String The object to ckeck.
Returns:
boolean - The boolean value.

isRectangle

public static boolean isRectangle(java.lang.String aRectangle)
Returns true if is possible to formataRectangle String to a Rectangle object.
Parameters:
aRectangle - java.lang.String The object to ckeck.
Returns:
boolean - The boolean value.

isShort

public static boolean isShort(java.lang.String aShort)
Returns true if is possible to formataShort String to a Short object.
Parameters:
aShort - java.lang.String The object to ckeck.
Returns:
boolean - The boolean value.

isString

public static boolean isString(java.lang.String aString)
Returns true if is possible to formataString String to a String object.
Parameters:
aString - java.lang.String The object to ckeck.
Returns:
boolean - The boolean value.

isURL

public static boolean isURL(java.lang.String aURL)
Returns true if is possible to formataURL String to a URL object.
Parameters:
aURL - java.lang.String The object to ckeck.
Returns:
boolean - The boolean value.

parse

public static java.lang.Object parse(java.lang.String aString,
                                     java.lang.String aType)
                              throws ParseException
Parses aString String to a aType object.
Parameters:
aString - java.lang.String The String object to be parsed.
aType - java.lang.String The type of the target object.
Returns:
java.lang.Object - The aType format of aString.
Throws:
ParseException - The object can not be parsed.

parseToBoolean

public static boolean parseToBoolean(java.lang.String aBoolean)
                              throws ParseException
Parses aBoolean String to a boolean object.
Parameters:
java.lang.String - aBoolean The String object to be parsed.
Returns:
boolean - The aBoolean parsed.
Throws:
ParseException - The object can not be parsed.

parseToCharacter

public static java.lang.Character parseToCharacter(java.lang.String aString)
                                            throws ParseException
Parses aString String to a Character object.
Parameters:
aString - java.lang.String The String object to be parsed.
Returns:
java.lang.Character - The aString parsed.
Throws:
ParseException - The object can not be parsed.

parseToColor

public static java.awt.Color parseToColor(java.lang.String aString)
                                   throws ParseException
Parses aString String to a java.awt.Color object.
Parameters:
java.lang.String - aString The String object to be parsed.
Returns:
java.awt.Color - The aString parsed.
Throws:
ParseException - The object can not be parsed.

parseToDate

public static java.util.Date parseToDate(java.lang.String aString)
                                  throws ParseException
Parses aString String to a java.util.Dater object.
Parameters:
aString - java.lang.String The String object to be parsed.
Returns:
java.util.Date - The aString parsed.
Throws:
ParseException - The object can not be parsed.

parseToDouble

public static java.lang.Double parseToDouble(java.lang.String aString)
                                      throws ParseException
Parses aString String to a Double object.
Parameters:
aString - java.lang.String The String object to be parsed.
Returns:
java.lang.Double - The aString parsed.
Throws:
ParseException - The object can not be parsed.

parseToFile

public static java.io.File parseToFile(java.lang.String fileName)
                                throws ParseException
Parses fileName String to a java.io.File object.
Parameters:
aString - String The String object to be parsed.
Returns:
java.io.File - The fileName parsed.
Throws:
ParseException - The object can not be parsed.

parseToFloat

public static java.lang.Float parseToFloat(java.lang.String aString)
                                    throws ParseException
Parses aString String to a Float object.
Parameters:
aString - java.lang.String The String object to be parsed.
Returns:
java.lang.Float - The aString parsed.
Throws:
ParseException - The object can not be parsed.

parseToFont

public static java.awt.Font parseToFont(java.lang.String fontValues)
                                 throws ParseException
Parses fontValues String to a java.awt.Font object.
Parameters:
aString - java.lang.String The String object to be parsed.
Returns:
java.awt.Font - The fontValues parsed.
Throws:
ParseException - The object can not be parsed.

parseToInteger

public static java.lang.Integer parseToInteger(java.lang.String aString)
                                        throws ParseException
Parses aString String to a Integer object.
Parameters:
aString - java.lang.String The String object to be parsed.
Returns:
java.lang.Integer - The aString parsed.
Throws:
ParseException - The object can not be parsed.

parseToJavaInitializationString

public static com.ibm.dse.tools.workbench.util.JavaInitializationString parseToJavaInitializationString(java.lang.String aString)
                                                                                                 throws ParseException
Parses aString String to a JavaInitializationString object.
Parameters:
aString - java.lang.String The String object to be parsed.
Returns:
com.ibm.dse.tools.workbench.util.JavaInitializationString - The aString parsed.
Throws:
com.ibm.dse.tools.workbench.util.ParseException - The object can not be parsed.

parseToLong

public static java.lang.Long parseToLong(java.lang.String aString)
                                  throws ParseException
Parses aString String to a Long object.
Parameters:
aString - java.lang.String The String object to be parsed.
Returns:
java.lang.Long - The aString parsed.
Throws:
com.ibm.dse.tools.workbench.util.ParseException - The object can not be parsed.

parseToRectangle

public static java.awt.Rectangle parseToRectangle(java.lang.String aString)
                                           throws ParseException
Parses aString String to a java.awt.Rectangle object.
Parameters:
aString - java.lang.String The String object to be parsed.
Returns:
java.awt.Rectangle - The aString parsed.
Throws:
com.ibm.dse.tools.workbench.util.ParseException - The object can not be parsed.

parseToShort

public static java.lang.Short parseToShort(java.lang.String aString)
                                    throws ParseException
Parses aString String to a Short object.
Parameters:
aString - java.lang.String The String object to be parsed.
Returns:
java.lang.Short - The aString parsed.
Throws:
com.ibm.dse.tools.workbench.util.ParseException - The object can not be parsed.

parseToURL

public static java.net.URL parseToURL(java.lang.String aString)
                               throws ParseException
Parses aString String to a java.net.URL object.
Parameters:
aString - java.lang.String The String object to be parsed.
Returns:
java.net.URL - The aString parsed.
Throws:
com.ibm.dse.tools.workbench.util.ParseException - The object can not be parsed.

setDatePattern

public static void setDatePattern(java.lang.String aPattern)
Sets the Date Pattern.
Parameters:
aPattern - java.lang.String The aPattern to set the pattern.

setNumberPattern

public static void setNumberPattern(java.lang.String aPattern)
Sets the Decimal Pattern.
Parameters:
aPattern - java.lang.String The aPattern to set the pattern.

setValidator

public static void setValidator(Types aType)
Sets an external type validator to use replacing the default provided one
Parameters:
aType - com.ibm.dse.tools.workbench.base.Types.