Class JDPUtils

java.lang.Object
   |
   +----JDPUtils

public class JDPUtils
extends Object
Class JDPUtils represents a set of standard utilities.


Variable Index

 o controlColor
 o numColors
 o textHighlight
 o textHighlightText

Constructor Index

 o JDPUtils(JDPUser)
Creates utilities class.

Method Index

 o _cvtbcolor(Color)
Convert a color to a string.
 o _cvtcolor(String)
Convert a string to a color.
 o aton(String)
Convert a fraction to a numeric with decimals.
 o brighter(Color)
Returns a brighter version of this color.
 o createObject(Class, String)
Create an object of the requested type using the supplied value.
 o cursor(Object)
Position the Cusror on a particular Component.
 o darker(Color)
Returns a darker version of this color.
 o dateFormat(String, String, String, String)
Format the output date.
 o execSql(JDPJagg, JDPStatusMessage, String, Vector)
Run an SQL and get the results.
 o execSql(JDPStatusMessage, String, Vector)
Run an SQL and get the results.
 o fmtcomma(int)
Format an int into a string with commas.
 o getClass(String)
Get a Class object of the requested type.
 o getControlColor()
Get the System background color.
 o getDataSourceType(JDPJagg)
Get the type of the data source being used.
 o getFieldQuote(int, String)
Get the field quote type for this datatype and datasource
 o getFileNames(String)
Get the file name from the specified directory path.
 o getInstanceHandle(String, boolean)
Attempt to retrieve the handle to a class of this type that has registered itself on the global handle.
 o getMenuPanel()
Retrieve the handle to the menu panel of JDP so the menu can be manipulated programatically.
 o getNumColors()
Get the number of colors we are presently running in.
 o getODBCValue(int)
Retrieve the ODBC value of this datatype.
 o getODBCValue(String)
Retrieve the ODBC value of this datatype.
 o getRelatedAppPath(String, String)
Retrieve the path of the application that handles the requested extension.
 o getTabPanel(Component)
Get the handle to the tab select panel above this Component.
 o getTextHighlight()
Get the background color for highlighted text.
 o getTextHighlightText()
Get the Text color for highlighted text.
 o insertTabs(TextArea)
Auto insert tabs into a text area for source editing purposes
 o ischaracter(Component, JDPStatusMessage)
Validate that a TextComponent has an entry in it.
 o ischaracter(Component, JDPStatusMessage, String)
Validate that a TextComponent has an entry in it.
 o isfloat(Component, JDPStatusMessage)
Validate that a TextComponent has an float entry in it.
 o isfloat(Component, JDPStatusMessage, String)
Validate that a TextComponent has an float entry in it.
 o isnumeric(Component, JDPStatusMessage)
Validate that a TextComponent has an numeric entry in it.
 o isnumeric(Component, JDPStatusMessage, String)
Validate that a TextComponent has an numeric entry in it.
 o isOdbcBinary(int)
Check if this field type is an ODBC binary.
 o isOdbcChar(int)
Check if this field type is an ODBC character field.
 o isOdbcDate(int)
Check if this field type is an ODBC date.
 o isOdbcEqual(int, int)
Check if the two field types are equivalent for SQL purposes.
 o isOdbcFloat(int)
Check if this field type is an ODBC float.
 o isOdbcInt(int)
Check if this field type is an ODBC integer.
 o isOdbcMemo(int)
Check if this field type is an ODBC memo or text field.
 o isOdbcNum(int)
Check if this field type is an ODBC number.
 o isvalidDate(TextField, JDPStatusMessage)
Validate the given date.
 o isvalidDate(TextField, JDPStatusMessage, String)
Validate the given date.
 o loadColors(List)
Load a list with the available colors.
 o loadODBCList(List)
Load a List with the complete list of ODBC types.
 o ntoa(float)
Convert a numeric value to a string with fractions.
 o padl(String, int)
Pad a string with blank spaces.
 o padr(String, int)
Pad a string with blank spaces.
 o readFromFile(String)
Read a text file on the server.
 o replace(String, String, String)
Replace characters in a string with other characters.
 o replace(String, String, String, int)
Replace characters in a string with other characters.
 o rtrim(String)
Trim trailing blanks from a string.
 o setColorFactor(double)
Set the factor to use for the brighter() and darker() methods (0.1-1.0).
 o setSpace(String)
Set a string to a single space if null
 o setSqlMessage(JDPJagg, String)
Retrieve just the SQL Message from an SQL Error.
 o sqlConvert(String, int, String)
Convert this field depending on the type and Database.
 o sqlRequiresChange(JDPJagg, int)
Check if specific changes need to be made to an SQL for the given datasource type.
 o str(float, int, int)
Format a numeric value into a string.
 o StringHeight(Graphics)
Get the height of the font in use by the Graphics object.
 o StringWidth(Graphics, String)
Calculate the width of a String given the Graphics object using the current Font.
 o tonum(String)
Format a numeric string value into a string.
 o writeToFile(String, String, String)
Write a text file on the server.

Variables

 o controlColor
 public static Color controlColor
 o numColors
 public static int numColors
 o textHighlightText
 public static Color textHighlightText
 o textHighlight
 public static Color textHighlight

Constructors

 o JDPUtils
 public JDPUtils(JDPUser user)
Creates utilities class.

Parameters:
JDPUser - the global user parameter used to pass handles in JDP.

Methods

 o getControlColor
 public static Color getControlColor()
Get the System background color.

Returns:
the system background color.
 o getNumColors
 public static int getNumColors()
Get the number of colors we are presently running in.

Returns:
the number of colors we are presently running in.
 o getTextHighlightText
 public static Color getTextHighlightText()
Get the Text color for highlighted text.

Returns:
the Text color for highlighted text.
 o getTextHighlight
 public static Color getTextHighlight()
Get the background color for highlighted text.

Returns:
the background color for highlighted text.
 o setColorFactor
 public static void setColorFactor(double factor)
Set the factor to use for the brighter() and darker() methods (0.1-1.0).

Parameters:
factor - the factor to use for the brighter() and darker() methods.
 o brighter
 public static Color brighter(Color thisColor)
Returns a brighter version of this color.

 o darker
 public static Color darker(Color thisColor)
Returns a darker version of this color.

 o cursor
 public void cursor(Object tfield)
Position the Cusror on a particular Component.

Parameters:
object - the object to position the cursor to.
 o isOdbcNum
 public static boolean isOdbcNum(int dtype)
Check if this field type is an ODBC number.

Parameters:
dtype - ODBC datatype.
Returns:
true if datatype is of the expected type.
 o isOdbcInt
 public static boolean isOdbcInt(int dtype)
Check if this field type is an ODBC integer.

Parameters:
dtype - ODBC datatype.
Returns:
true if datatype is of the expected type.
 o isOdbcFloat
 public static boolean isOdbcFloat(int dtype)
Check if this field type is an ODBC float.

Parameters:
dtype - ODBC datatype.
Returns:
true if datatype is of the expected type.
 o isOdbcChar
 public static boolean isOdbcChar(int dtype)
Check if this field type is an ODBC character field.

Parameters:
dtype - ODBC datatype.
Returns:
true if datatype is of the expected type.
 o isOdbcMemo
 public static boolean isOdbcMemo(int dtype)
Check if this field type is an ODBC memo or text field.

Parameters:
dtype - ODBC datatype.
Returns:
true if datatype is of the expected type.
 o isOdbcBinary
 public static boolean isOdbcBinary(int dtype)
Check if this field type is an ODBC binary.

Parameters:
dtype - ODBC datatype.
Returns:
true if datatype is of the expected type.
 o isOdbcDate
 public static boolean isOdbcDate(int dtype)
Check if this field type is an ODBC date.

Parameters:
dtype - ODBC datatype.
Returns:
true if datatype is of the expected type.
 o isOdbcEqual
 public static boolean isOdbcEqual(int type1,
                                   int type2)
Check if the two field types are equivalent for SQL purposes.

Parameters:
type1 - ODBC datatype.
type2 - ODBC datatype.
Returns:
true if datatypes are equivalent.
 o sqlConvert
 public static String sqlConvert(String sqlString,
                                 int dt,
                                 String datasourceType)
Convert this field depending on the type and Database.

Parameters:
sqlString - SQL string to convert.
datasourceType - type of database.
Returns:
converted SQL String.
 o getODBCValue
 public static int getODBCValue(String dataType)
Retrieve the ODBC value of this datatype.

Parameters:
dataType - ODBC data type.
Returns:
ODBC datatype value.
 o getODBCValue
 public static String getODBCValue(int dataType)
Retrieve the ODBC value of this datatype.

Parameters:
dataType - ODBC data type value.
Returns:
ODBC datatype.
 o loadODBCList
 public static void loadODBCList(List odbcList)
Load a List with the complete list of ODBC types.

Parameters:
odbcList - List object to load.
 o ischaracter
 public boolean ischaracter(Component nval,
                            JDPStatusMessage mainmsg)
Validate that a TextComponent has an entry in it.

Parameters:
comp - text component to validate.
mainmsg - handle to status message object for any error messages.
Returns:
true if component is not empty.
 o ischaracter
 public boolean ischaracter(Component nval,
                            JDPStatusMessage mainmsg,
                            String message)
Validate that a TextComponent has an entry in it.

Parameters:
comp - text component to validate.
mainmsg - handle to status message object for any error messages.
message - message to display if text component is empty.
Returns:
true if component is not empty.
 o isnumeric
 public boolean isnumeric(Component nval,
                          JDPStatusMessage mainmsg)
Validate that a TextComponent has an numeric entry in it.

Parameters:
comp - text component to validate.
mainmsg - handle to status message object for any error messages.
Returns:
true if component has a valid numeric entry.
 o isnumeric
 public boolean isnumeric(Component nval,
                          JDPStatusMessage mainmsg,
                          String message)
Validate that a TextComponent has an numeric entry in it.

Parameters:
comp - text component to validate.
mainmsg - handle to status message object for any error messages.
message - message to display if text component is empty.
Returns:
true if component has a valid numeric entry.
 o isfloat
 public boolean isfloat(Component nval,
                        JDPStatusMessage mainmsg)
Validate that a TextComponent has an float entry in it.

Parameters:
comp - text component to validate.
mainmsg - handle to status message object for any error messages.
Returns:
true if component has a valid numeric entry.
 o isfloat
 public boolean isfloat(Component nval,
                        JDPStatusMessage mainmsg,
                        String message)
Validate that a TextComponent has an float entry in it.

Parameters:
comp - text component to validate.
mainmsg - handle to status message object for any error messages.
message - message to display if text component is empty.
Returns:
true if component has a valid numeric entry.
 o ntoa
 public String ntoa(float nval)
Convert a numeric value to a string with fractions.

Parameters:
nval - the float value to convert.
Returns:
the equivalent value in fraction format.
 o aton
 public float aton(String aval)
Convert a fraction to a numeric with decimals.

Parameters:
aval - the fraction value to convert.
Returns:
the equivalent float value.
 o str
 public String str(float nval,
                   int len,
                   int dec)
Format a numeric value into a string.

Parameters:
nval - the float value to convert.
len - the number of significant digits to format to.
dec - the number of decimal places to convert to.
Returns:
the equivalent string value.
 o tonum
 public static String tonum(String nstring)
Format a numeric string value into a string.

Parameters:
nstring - the numeric string value.
Returns:
the equivalent string value with nulls or spaces removed.
 o setSpace
 public static String setSpace(String nstring)
Set a string to a single space if null

Parameters:
nstring - the numeric string value.
Returns:
the equivalent string value with nulls or spaces removed.
 o padl
 public String padl(String nstring,
                    int len)
Pad a string with blank spaces.

Parameters:
nstring - the numeric string value.
len - the length to pad to.
Returns:
the padded string value.
 o padr
 public String padr(String nstring,
                    int len)
Pad a string with blank spaces.

Parameters:
nstring - the numeric string value.
len - the length to pad to.
Returns:
the padded string value.
 o replace
 public String replace(String dstring,
                       String searchString,
                       String replaceString)
Replace characters in a string with other characters.

Parameters:
dstring - the string to change.
searchString - the string to search for.
replaceString - the string to replace the searchString with.
Returns:
the resulting string value.
 o replace
 public static String replace(String dstring,
                              String searchString,
                              String replaceString,
                              int occurences)
Replace characters in a string with other characters.

Parameters:
dstring - the string to change.
searchString - the string to search for.
replaceString - the string to replace the searchString with.
occurences - the number of occurences to replace.
Returns:
the resulting string value.
 o insertTabs
 public static void insertTabs(TextArea thisTextArea)
Auto insert tabs into a text area for source editing purposes

Parameters:
thisTextArea - the textarea to format after a new line character has been pressed.
 o getTabPanel
 public static JDPTabSelectPanel getTabPanel(Component thisPanel)
Get the handle to the tab select panel above this Component.

Parameters:
thisPanel - the current panel.
Returns:
the handle to the parent tab panel.
 o getDataSourceType
 public String getDataSourceType(JDPJagg jaggSQL)
Get the type of the data source being used.

Parameters:
jaggSQL - the instance of JDPJagg to get the datasource type.
Returns:
the type of the datasource/database.
 o getFieldQuote
 public static String getFieldQuote(int fieldType,
                                    String dsnType)
Get the field quote type for this datatype and datasource

Parameters:
fieldType - the ODBC field type
dsnType - the type of datasource
 o sqlRequiresChange
 public boolean sqlRequiresChange(JDPJagg jaggSQL,
                                  int testNum)
Check if specific changes need to be made to an SQL for the given datasource type.

Parameters:
jaggSQL - the instance of JDPJagg to get the datasource type.
testNum - the number of the text to perform (presently only 0 is implemented).
Returns:
the specified datasource requires a change.
 o setSqlMessage
 public void setSqlMessage(JDPJagg jaggSQL,
                           String SQL)
Retrieve just the SQL Message from an SQL Error.

Parameters:
jaggSQL - the instance of JDPJagg to get the datasource type.
SQL - the SQL that was run that caused the error.
 o execSql
 public int execSql(JDPStatusMessage message,
                    String SQL,
                    Vector resultvector)
Run an SQL and get the results.

Parameters:
message - the handle to the status message bar for messages.
SQL - the SQL that to run.
resultvector - the vector to place the results in.
Returns:
the number of rows returned.
 o execSql
 public int execSql(JDPJagg jaggSQL,
                    JDPStatusMessage message,
                    String SQL,
                    Vector resultvector)
Run an SQL and get the results.

Parameters:
jaggSQL - the handle to the Jagg class for running the SQL.
message - the handle to the status message bar for messages.
SQL - the SQL that to run.
resultvector - the vector to place the results in.
Returns:
the number of rows returned.
 o getFileNames
 public String[] getFileNames(String dirPath)
Get the file name from the specified directory path.

Parameters:
dirPath - the directory path to get the file names from.
Returns:
the list of file names.
 o readFromFile
 public String readFromFile(String filename)
Read a text file on the server.

Parameters:
filename - the full or partial path of the file name on the server.
Returns:
the contents of the file.
 o writeToFile
 public boolean writeToFile(String filename,
                            String outputText,
                            String outputFormat)
Write a text file on the server.

Parameters:
filename - the full or partial path of the file name on the server.
outputText - the text to write to the file.
outputFormat - the output format (w, w+, a, a+).
Returns:
true if the write was successful.
 o getRelatedAppPath
 public String getRelatedAppPath(String docExtension,
                                 String docMessage)
Retrieve the path of the application that handles the requested extension.

Parameters:
docExtension - the extension of the doc to be opened.
dialogMessage - the message to display on the dialog.
Returns:
true if the date is valid.
 o isvalidDate
 public boolean isvalidDate(TextField nval,
                            JDPStatusMessage mainmsg)
Validate the given date.

Parameters:
nval - the TextField containing the date.
mainmsg - the handle to the status bar for error messages.
Returns:
true if the date is valid.
 o isvalidDate
 public boolean isvalidDate(TextField dval,
                            JDPStatusMessage mainmsg,
                            String message)
Validate the given date.

Parameters:
nval - the TextField containing the date.
mainmsg - the handle to the status bar for error messages.
message - the message to display if the data is not valid.
Returns:
true if the date is valid.
 o dateFormat
 public String dateFormat(String m,
                          String d,
                          String y,
                          String dFormat)
Format the output date.

Parameters:
month - the month.
day - the day.
year - the year.
dFormat - the format in any combination of (mm/dd/yy).
Returns:
the formatted date.
 o rtrim
 public String rtrim(String svalue)
Trim trailing blanks from a string.

Parameters:
svalue - the string value.
Returns:
the trimmed string.
 o fmtcomma
 public String fmtcomma(int ivalue)
Format an int into a string with commas.

Parameters:
ivalue - the integer value.
Returns:
the formatted string.
 o StringHeight
 public int StringHeight(Graphics gr)
Get the height of the font in use by the Graphics object.

Parameters:
gr - the graphics object.
Returns:
the height of the font.
 o StringWidth
 public int StringWidth(Graphics gr,
                        String thisString)
Calculate the width of a String given the Graphics object using the current Font.

Parameters:
gr - the graphics object.
thisString - the string to determine the width.
Returns:
the width of the string.
 o _cvtcolor
 public Color _cvtcolor(String ccolor)
Convert a string to a color.

Parameters:
ccolor - the string color.
Returns:
the actual color.
 o _cvtbcolor
 public static String _cvtbcolor(Color ccolor)
Convert a color to a string.

Parameters:
ccolor - the actual color.
Returns:
the string color.
 o loadColors
 public static void loadColors(List list)
Load a list with the available colors.

Parameters:
list - the list to load.
 o getClass
 public static Class getClass(String compType)
Get a Class object of the requested type.

Parameters:
type - the type of the Object to get a Class for.
Returns:
a Class instance of the specified type.
 o createObject
 public static Object createObject(Class objectType,
                                   String objectValue)
Create an object of the requested type using the supplied value.

Parameters:
type - the type of the Object to create.
value - the value of the Object to create.
Returns:
an Object of the specified type.
 o getMenuPanel
 public JDPTabSelectPanel getMenuPanel()
Retrieve the handle to the menu panel of JDP so the menu can be manipulated programatically.

Returns:
the handle to the menu panel.
 o getInstanceHandle
 public Object getInstanceHandle(String instanceName,
                                 boolean autoLoad)
Attempt to retrieve the handle to a class of this type that has registered itself on the global handle. All classes loaded as a menu option will automatically have registered. If the menu option is not loaded then load it first if requested.

Parameters:
instanceName - the name of the class type to search for.
autoLoad - whether to auto load the menu tab if not already loaded