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.


Variable Index

 o param_source
Hash table of alternate parameter sources

Constructor Index

 o JCUtilConverter()

Method Index

 o error(String)
Writes a parse error message to stdout.
 o error(String, String)
Writes a parse error message to stdout.
 o getParam(Applet, Component, String)
Gets a parameter value from the applet or source.
 o getParam(Applet, Component, String, String)
Gets a parameter of the applet in the following precedence:
<component_name>.<param>
<param>
 o setParamSource(Component, String)
Sets the source from which getParam should read parameter values.
 o toBoolean(Applet, Component, String, String, boolean)
Retrieves a parameter and converts its value to a boolean value.
 o toColor(String)
Converts a string to an AWT Color.
 o toColorList(String)
Converts a string to an array of AWT Color instances.
 o toFont(String)
Converts a font name to an AWT font instance.
 o toImage(Component, String)
Returns an image which gets pixel data from the specified file.
 o toInt(String, int)
Converts a string to an integer.
 o toIntList(String, char)
Converts a string to an array of integers based on the provided delimiter.
 o toNewLine(String)
Converts all occurrences of "\n" to newlines.
 o toVector(Component, String, char, boolean)
Converts a delimited list of tokens to a JCVector.
 o toVectorFromCSV(Component, String)
Converts a string using comma-separated value format.
 o trim(Object)
Returns a trimmed string, with trailing nulls removed.

Variables

 o param_source

  public static Hashtable param_source
Hash table of alternate parameter sources

Constructors

 o JCUtilConverter

  public JCUtilConverter()

Methods

 o 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

 o 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

 o 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

 o 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

 o error

  public static void error(String msg)
Writes a parse error message to stdout.
Parameters:
token - the string which could not be parsed

 o 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.

 o 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

 o 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

 o 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.

 o toNewLine

  public static String toNewLine(String string)
Converts all occurrences of "\n" to newlines.
Parameters:
string - String to convert.
converted - string

 o 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.

 o 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

 o 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

 o 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.

 o 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.

 o 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