All Packages Class Hierarchy This Package Previous Next Index
Class jclass.util.JCUtilConverter
java.lang.Object
|
+----jclass.util.JCUtilConverter
- public class JCUtilConverter
- extends Object
JCUtilConverter contains static methods for retrieving parameters from
a source file or applet, and for converting parameters to
particular data types.
-
conv
-
-
param_source
- Hash table of alternate parameter sources.
-
JCUtilConverter()
-
-
checkEnum(int, String, int[])
- Checks the validity of an enum.
-
error(String)
- Writes a parse error message to stdout.
-
error(String, String)
- Writes a parse error message to stdout.
-
fromEnum(int, String, String, String[][], int[][], String)
- Converts an enum to a string.
-
fromEnum(int, String[], int[])
- Converts an enum to a string.
-
fromNewLine(String)
- Converts all occurrences of char '\n' to string "\n"
-
getParam(Applet, Component, String)
- Gets a parameter value from the applet or source.
-
getParam(Applet, Component, String, String)
- Gets a parameter of the applet in the following precedence:
<component_name>.<param>
<param>
-
removeEscape(String)
- Removes "escape" characters (backslashes) from the string.
-
setParamSource(Component, String)
- Sets the source from which getParam should read parameter values.
-
toBoolean(Applet, Component, String, String, boolean)
- Retrieves a parameter and converts its value to a boolean value.
-
toBoolean(String, boolean)
- Converts a string to a boolean.
-
toColor(String)
- Converts a string to a Color.
-
toColor(String, Color)
- Converts a string to a Color.
-
toColorList(String)
- Converts a string to an array of Colors.
-
toColorList(String, Color[])
- Converts a string to an array of Colors.
-
toDate(String, Date)
- Converts a String to a Date
-
toDimension(String, Dimension)
- Converts a string to a Dimension instance.
-
toDouble(String, double)
- Converts a string to an double.
-
toEnum(String, String, String, String[][], int[][], int)
- Converts a string to an enum.
-
toEnum(String, String, String[], int[], int)
- Converts a string to an enum.
-
toEnum(String, String, String[], long[], long)
- Converts a string to an enum.
-
toEnum(String, String[], int[], int)
- Converts a string to an enum.
-
toEnumList(String, String, String[], int[], int[])
- Converts a string to a list of enums.
-
toFont(String)
- Converts a font name to a font instance.
-
toFont(String, Font)
- Converts a font name to a font instance.
-
toImage(Component, String)
- Returns an image which gets pixel data from the specified file.
-
toImage(Component, String, Image)
- Returns an image which gets pixel data from the specified file.
-
toImageList(Component, String, Image[])
- Returns an array of images which get pixel data from the specified file.
-
toInsets(String, Insets)
- Converts a string to an Insets instance.
-
toInt(String, int)
- Converts a string to an integer.
-
toIntList(String, char)
- Converts a string to an array of integers based on the
provided delimiter.
-
toIntList(String, char, int[])
- Converts a string to an array of integers based on the
provided delimiter.
-
toNewLine(String)
- Converts all occurrences of "\n" to newlines.
-
toPoint(String, Point)
- Converts a string to a Point instance.
-
toString(Object)
- Converts an object to a string.
-
toStringList(String)
- Converts a string to an array of Strings.
-
toVector(Component, String, char, boolean)
- Converts a delimited list of tokens to a JCVector.
-
toVector(Component, String, char, boolean, JCVector)
- Converts a delimited list of tokens to a JCVector.
-
toVectorFromCSV(Component, String)
- Converts a string using comma-separated value format.
-
toVectorFromCSV(Component, String, JCVector)
- Converts a string using comma-separated value format.
-
trim(Object)
- Returns a trimmed string, with trailing nulls removed
-
waitForImage(Component, Image)
- Waits for an image to be loaded, using the MediaTracker class.
conv
public static JCConverter conv
param_source
public static Hashtable param_source
- Hash table of alternate parameter sources.
JCUtilConverter
public JCUtilConverter()
setParamSource
public static void setParamSource(Component key,
String source)
- Sets the source from which getParam should read parameter values.
- Parameters:
- source - a Vector of Strings; if null, getParam will read values from its specified applet
- See Also:
- getParam
getParam
public static String getParam(Applet app,
Component key,
String param)
- Gets a parameter value from the applet or source.
- Parameters:
- app - the applet used to retrieve the parameter
- key - the component used as the key for the parameter source hash table
- param - the parameter to retrieve
- Returns:
- parameter value
getParam
public static String getParam(Applet app,
Component comp,
String comp_name,
String param)
- Gets a parameter of the applet in the following precedence:
<component_name>.<param>
<param>
- Parameters:
- app - the applet whose parameter value is retrieved; if setParamSource() has
previously been called, the value will be read from the specified buffer
- comp - the component used for converting images (if any) and for retrieving the parameter source
- comp_name - the component name
- param - the parameter to retrieve
- Returns:
- value string, or null if the param could not be found
- See Also:
- setParamSource, getParameter
error
public static void error(String s,
String token)
- Writes a parse error message to stdout.
- Parameters:
- s - the entire string being parsed
- token - the string which could not be parsed
error
public static void error(String msg)
- Writes a parse error message to stdout.
- Parameters:
- token - the string which could not be parsed
trim
public static String trim(Object obj)
- Returns a trimmed string, with trailing nulls removed
- Parameters:
- obj - the object to trim
- String - the version of the object with trailing nulls removed
toInt
public static int toInt(String s,
int def)
- Converts a string to an integer.
- Parameters:
- string - the string for conversion
- def - the default value to be used when a parsing error occurs
toDouble
public static double toDouble(String s,
double def)
- Converts a string to an double.
- Parameters:
- string - the string for conversion
- def - the default value to be used when a parsing error occurs
toBoolean
public static boolean toBoolean(String s,
boolean def)
- Converts a string to a boolean.
- Parameters:
- s - the string for conversion
- def - the default value to be used when a parsing error occurs
toBoolean
public static boolean toBoolean(Applet app,
Component comp,
String comp_name,
String param,
boolean def)
- Retrieves a parameter and converts its value to a boolean value.
- Parameters:
- app - the applet used to retrieve the parameter value
- comp - key used for the parameter source hash table
- comp_name - the component name
- param - the parameter to retrieve
- def - the default value
toStringList
public static String[] toStringList(String s)
- Converts a string to an array of Strings.
- Parameters:
- s - the comma-separated strings
toIntList
public static int[] toIntList(String s,
char delim)
- Converts a string to an array of integers based on the
provided delimiter.
- Parameters:
- s - the string which will be converted to integers
- delim - the delimiter separating the integers in the string
toIntList
public static int[] toIntList(String s,
char delim,
int def[])
- Converts a string to an array of integers based on the
provided delimiter.
- Parameters:
- s - the string which will be converted to integers
- delim - the delimiter separating the integers in the string
- def - the default value, returned if a parse error occurs
toNewLine
public static String toNewLine(String string)
- Converts all occurrences of "\n" to newlines.
fromNewLine
public static String fromNewLine(String s)
- Converts all occurrences of char '\n' to string "\n"
toVector
public static JCVector toVector(Component comp,
String s,
char delim,
boolean convert)
- Converts a delimited list of tokens to a JCVector.
- Parameters:
- comp - any component
- s - the string to convert
- delim - the delimiter that separates the tokens in the string
- convert - if true, a token is converted to a JCString
if it contains a square bracket ([)
toVector
public static JCVector toVector(Component comp,
String s,
char delim,
boolean convert,
JCVector def)
- Converts a delimited list of tokens to a JCVector.
- Parameters:
- comp - any component
- s - the string to convert
- delim - the delimiter that separates the tokens in the string
- convert - if true, a token is converted to a JCString
if it contains a square bracket ([)
- def - the default value, returned if a parse error occurs
toVectorFromCSV
public static JCVector toVectorFromCSV(Component comp,
String s)
- Converts a string using comma-separated value format.
- Parameters:
- comp - any component
- s - the string to be tokenized
toVectorFromCSV
public static JCVector toVectorFromCSV(Component comp,
String s,
JCVector def)
- Converts a string using comma-separated value format.
- Parameters:
- comp - any component
- s - the string to be tokenized
- def - the default value, returned if a parse error occurs
toImage
public static Image toImage(Component comp,
String file,
Image def)
- Returns an image which gets pixel data from the specified file.
The MediaTracker class is used to wait until the image is loaded.
- Parameters:
- c - the component that is loading the image. If the component
is an applet in a browser, Applet.getImage() is used in order to take
advantage of Applet.getDocumentBase()
- file - the file containing the image to be loaded; if an http protocol is not specified (a ":" is not present), the current working directory is prepended to the file name
- def - the default value, returned if a parse error occurs
- See Also:
- MediaTracker
toImage
public static Image toImage(Component comp,
String file)
- Returns an image which gets pixel data from the specified file.
The MediaTracker class is used to wait until the image is loaded.
- Parameters:
- c - the component that is loading the image. If the component
is an applet in a browser, Applet.getImage() is used in order to take
advantage of Applet.getDocumentBase()
- file - the file containing the image to be loaded; if an http protocol is not specified (a ":" is not present), the current working directory is prepended to the file name
- See Also:
- MediaTracker
waitForImage
public static boolean waitForImage(Component comp,
Image image)
- Waits for an image to be loaded, using the MediaTracker class.
- Returns:
- false if an error occurred
- See Also:
- MediaTracker
toImageList
public static Image[] toImageList(Component comp,
String s,
Image def[])
- Returns an array of images which get pixel data from the specified file.
- Parameters:
- s - comma-separated list of files
- def - the default value, returned if a parse error occurs
- See Also:
- toImage
toColorList
public static Color[] toColorList(String s,
Color def[])
- Converts a string to an array of Colors.
- Parameters:
- s - the string containing color names separated by commas
- def - the default value, returned if a parse error occurs
toColorList
public static Color[] toColorList(String s)
- Converts a string to an array of Colors.
- Parameters:
- s - the comma-separated color names
toColor
public static Color toColor(String s,
Color def)
- Converts a string to a Color.
- Parameters:
- s - the string containing a color name
- def - the default value, returned if a parse error occurs
toColor
public static Color toColor(String s)
- Converts a string to a Color.
- Parameters:
- s - the string containing a color name
toFont
public static Font toFont(String s,
Font def)
- Converts a font name to a font instance.
- Parameters:
- s - the string containing font name
- def - the default value, returned if a parse error occurs
toFont
public static Font toFont(String s)
- Converts a font name to a font instance.
- Parameters:
- s - the string containing font name
toEnum
public static int toEnum(String string,
String type,
String param,
String strings[][],
int values[][],
int def)
- Converts a string to an enum. If the string cannot be converted,
an error message is written to the console.
- Parameters:
- string - the string to be converted
- type - the enum type
- param - the optional PARAM name for the enum, used for the error message
- strings - the first item in each list is the enum type;
each string has a corresponding value in the values array
- values - list of values corresponding to the strings
- def - the default value, returned if the string could not be converted
- Returns:
- either the converted value or the default
toEnum
public static int toEnum(String s,
String type,
String strings[],
int values[],
int def)
- Converts a string to an enum. If the string cannot be converted,
an error message is written to the console.
- Parameters:
- s - the string to be converted
- type - the enum type (for the console message)
- strings - list of valid strings
- values - list of values corresponding to each string
- def - the default value, returned if the string could not be converted
- Returns:
- either the converted value or the default
toEnum
public static long toEnum(String s,
String type,
String strings[],
long values[],
long def)
- Converts a string to an enum. If the string cannot be converted,
an error message is written to the console.
- Parameters:
- s - the string to be converted
- type - the enum type (for the console message)
- strings - list of valid strings
- values - list of values corresponding to each string
- def - the default value, returned if the string could not be converted
- Returns:
- either the converted value or the default
toEnum
public static int toEnum(String s,
String strings[],
int values[],
int def)
- Converts a string to an enum.
- Parameters:
- s - the string to be converted
- strings - list of valid strings
- values - list of values corresponding to each string
- def - the default value, returned if the string could not be converted
- Returns:
- the converted value or the default
toEnumList
public static int[] toEnumList(String s,
String type,
String strings[],
int values[],
int def[])
- Converts a string to a list of enums. If the string cannot be converted,
an error message is written to the console.
- Parameters:
- s - the comma-separated list of enums
- type - the enum type
- strings - valid strings
- values - list of values corresponding to each string
- def - the default value, returned if the string could not be converted
- Returns:
- either the converted value or the default
fromEnum
public static String fromEnum(int value,
String strings[],
int values[])
- Converts an enum to a string.
- Parameters:
- value - the enum to be converted
- strings - list of valid strings
- values - list of values corresponding to each string
- Returns:
- either the converted value or null
fromEnum
public static String fromEnum(int value,
String param,
String type,
String strings[][],
int values[][],
String def)
- Converts an enum to a string. If the enum cannot be converted,
an error message is written to the console.
- Parameters:
- value - the enum to be converted
- param - the optional PARAM name for the enum, used for the error message
- type - the enum type
- strings - The first item in each list is the enum type;
each string has a corresponding value in the values array.
- values - list of values corresponding to the strings
- def - the default value, returned if the enum could not be converted
- Returns:
- either the converted value or the default
checkEnum
public static void checkEnum(int value,
String param,
int values[])
- Checks the validity of an enum.
- Parameters:
- param - enum name, used for error message
- Throws: IllegalArgumentException
- If the value is invalid
toInsets
public static Insets toInsets(String s,
Insets def)
- Converts a string to an Insets instance.
- Parameters:
- s - the string containing the top, left, bottom and right values, separated by commas
- def - the default value, returned if the string could not be converted
toDimension
public static Dimension toDimension(String s,
Dimension def)
- Converts a string to a Dimension instance.
- Parameters:
- s - the string in the format [width]x[height]
- def - the default value, returned if the string could not be converted
toPoint
public static Point toPoint(String s,
Point def)
- Converts a string to a Point instance.
- Parameters:
- s - the string in the format [x],[y]
- def - the default value, returned if the string could not be converted
toString
public static String toString(Object o)
- Converts an object to a string. If a String, newlines are replaced by "\n".
If a Vector, it is converted to a comma-separated list.
toDate
public static Date toDate(String s,
Date def)
- Converts a String to a Date
removeEscape
public static String removeEscape(String s)
- Removes "escape" characters (backslashes) from the string.
All Packages Class Hierarchy This Package Previous Next Index