All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class jclass.util.JCConverter

java.lang.Object
   |
   +----jclass.util.JCConverter

public class JCConverter
extends Object
JCConverter contains methods for retrieving parameters from a source file or applet, and for converting parameters to particular data types.


Constructor Index

 o JCConverter()

Method Index

 o getParam(Applet, Component, String, String)
Gets a parameter of the applet in the following precedence:
 <component_name>.<param>
 <param>
 
 o toBoolean(String, boolean)
Converts a string to a boolean.
 o toColor(String)
Converts a string to an AWT Color.
 o toColor(String, Color)
Converts a string to an AWT Color.
 o toColorList(String, Color[])
Converts a string to an array of Colors.
 o toDate(String, Date)
 o toDimension(String, Dimension)
Converts a string to a Dimension instance.
 o toDouble(String, double)
Converts a string to a double.
 o toEnum(String, String, String[], int[], int)
Converts a string to an enum.
 o toEnum(String, String, String[], long[], long)
Converts a string to an enum.
 o toEnumList(String, String, String[], int[], int[])
Converts a string to a list of enums.
 o toFont(String)
Converts a font name to an AWT font instance.
 o toFont(String, Font)
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 toImage(Component, String, Image)
Returns an image which gets pixel data from the specified file.
 o toImageList(Component, String, Image[])
Returns an array of images which get pixel data from the specified file.
 o toInsets(String, Insets)
Converts a string to an Insets instance.
 o toInt(String, int)
Converts a string to an integer.
 o toIntList(String, char, int[])
Converts a string to an array of integers based on the provided delimiter.
 o toJCString(Component, String, Object)
Converts a string to a String or JCString.
 o toPoint(String, Point)
Converts a string to a Point instance.
 o toStringList(String)
Converts a string to an array of Strings.
 o toVector(Component, String, char, boolean)
Converts a delimited list of tokens to a JCVector containing Strings or JCStrings.
 o toVector(Component, String, char, boolean, JCVector)
Converts a delimited list of tokens to a JCVector containing Strings or JCStrings.

Constructors

 o JCConverter
 public JCConverter()

Methods

 o getParam
 public 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
 o toInt
 public int toInt(String s,
                  int def)
Converts a string to an integer.

Parameters:
s - the string for conversion
def - the default value to be used when a parsing error occurs
 o toDouble
 public double toDouble(String s,
                        double def)
Converts a string to a double.

Parameters:
s - the string for conversion
def - the default value to be used when a parsing error occurs
 o toBoolean
 public boolean toBoolean(String s,
                          boolean def)
Converts a string to a boolean.

Parameters:
string - the string for conversion
def - the default value to be used when a parsing error occurs
 o toIntList
 public 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
Returns:
array of integers take from the string
 o toStringList
 public static String[] toStringList(String s)
Converts a string to an array of Strings.

Parameters:
s - the comma-separated strings
 o toVector
 public JCVector toVector(Component comp,
                          String s,
                          char delim,
                          boolean convert,
                          JCVector def)
Converts a delimited list of tokens to a JCVector containing Strings or JCStrings.

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
 o toVector
 public JCVector toVector(Component comp,
                          String s,
                          char delim,
                          boolean convert)
Converts a delimited list of tokens to a JCVector containing Strings or JCStrings.

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 ([).
See Also:
JCString
 o toJCString
 public Object toJCString(Component comp,
                          String s,
                          Object def)
Converts a string to a String or JCString. A token is converted to a JCString if it contains a square bracket ([).

Parameters:
comp - any component
s - the string to convert
def - the default value, returned if a parse error occurs
See Also:
JCString
 o toImage
 public 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:
comp - 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
 o toImage
 public 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:
comp - 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
Returns:
null if a parse error occurs
See Also:
MediaTracker
 o toImageList
 public 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
 o toColorList
 public Color[] toColorList(String s,
                            Color def[])
Converts a string to an array of Colors.

Parameters:
s - comma-separated list of colors
def - the default value, returned if a parse error occurs
 o toColor
 public Color toColor(String s,
                      Color def)
Converts a string to an AWT Color.

Parameters:
s - the string containing a color name
def - the default value, returned if a parse error occurs
 o toColor
 public Color toColor(String s)
Converts a string to an AWT Color.

Parameters:
s - the string containing a color name
Returns:
null if parsing error occurred
 o toFont
 public Font toFont(String s,
                    Font def)
Converts a font name to an AWT font instance.

Parameters:
s - the string containing font name
def - the default value, returned if a parse error occurs
 o toFont
 public Font toFont(String s)
Converts a font name to an AWT font instance.

Parameters:
s - the string containing font name
Returns:
null if parsing error occurred
 o toEnum
 public 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, used for printing error messages
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
 o toEnum
 public 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, used for printing error messages
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
 o toEnumList
 public 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
 o toInsets
 public 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
 o toDimension
 public 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
 o toPoint
 public 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
 o toDate
 public Date toDate(String s,
                    Date def)

All Packages  Class Hierarchy  This Package  Previous  Next  Index