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