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.

param_source
- Hash table of alternate parameter sources

JCUtilConverter()

error(String)
- Writes a parse error message to stdout.
error(String,
String)
- Writes a parse error message to stdout.
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>
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.
toColor(String)
- Converts a string to an AWT Color.
toColorList(String)
- Converts a string to an array of AWT Color instances.
toFont(String)
- Converts a font name to an AWT font instance.
toImage(Component,
String)
- Returns an image which gets pixel data from the specified file.
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.
toNewLine(String)
- Converts all occurrences of "\n" to newlines.
toVector(Component,
String, char, boolean)
- Converts a delimited list of tokens to a JCVector.
toVectorFromCSV(Component,
String)
- Converts a string using comma-separated value format.
trim(Object)
- Returns a trimmed string, with trailing nulls removed.

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:
- paramter 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 paramter 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, getParam
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 string,
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
- Returns:
- the integer representation of string
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
- Returns:
- Boolean value
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.
- Returns:
- array of integers take from the string.
toNewLine
public static String toNewLine(String string)
- Converts all occurrences of "\n" to newlines.
- Parameters:
- string - String to convert.
- converted - string
toVector
public static JCVector toVector(Component c,
String s,
char delim,
boolean convert)
- Converts a delimited list of tokens to a JCVector.
- Parameters:
- s - the string to convert
- delim - the delimiter that separates the tokens in the string
- convert - if this is true, a token is converted to a JCString if it
contains an square bracket ([).
- Returns:
- array of tokens.
toVectorFromCSV
public static JCVector toVectorFromCSV(Component c,
String s)
- Converts a string using comma-separated value format.
- Parameters:
- s - the string to be tokenized
- Returns:
- array of tokens
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, 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.
- Returns:
- the Image instance
- See Also:
- MediaTracker
toColorList
public static Color[] toColorList(String s)
- Converts a string to an array of AWT Color instances.
- Parameters:
- s - the string containing color names separated by commas
- Returns:
- array of java.awt.Color.
toColor
public static Color toColor(String s)
- Converts a string to an AWT Color.
- Parameters:
- s - the string containing a color name
- Returns:
- the color instance.
toFont
public static Font toFont(String s)
- Converts a font name to an AWT font instance.
- Parameters:
- s - the string containing font name
- Returns:
- font instance
All Packages Class Hierarchy This Package Previous Next Index