    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.

##

JCConverter()

##

getParam(Applet, Component, String, String)
  Gets a parameter of the applet in the following precedence:

       <component_name>.<param>
       <param>

toBoolean(String, boolean)
  Converts a string to a boolean.
toColor(String)
  Converts a string to an AWT Color.
toColor(String, Color)
  Converts a string to an AWT Color.
toColorList(String, Color[])
  Converts a string to an array of Colors.
toDate(String, Date)
toDimension(String, Dimension)
  Converts a string to a Dimension instance.
toDouble(String, double)
  Converts a string to a double.
toEnum(String, String, String[], int[], int)
  Converts a string to an enum.
toEnum(String, String, String[], long[], long)
  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 an AWT font instance.
toFont(String, Font)
  Converts a font name to an AWT 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, int[])
  Converts a string to an array of integers based on the provided delimiter.
toJCString(Component, String, Object)
  Converts a string to a String or JCString.
toPoint(String, Point)
  Converts a string to a Point instance.
toStringList(String)
  Converts a string to an array of Strings.
toVector(Component, String, char, boolean)
  Converts a delimited list of tokens to a JCVector containing Strings or JCStrings.
toVector(Component, String, char, boolean, JCVector)
  Converts a delimited list of tokens to a JCVector containing Strings or JCStrings.

##

JCConverter

     public JCConverter()

##

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

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

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

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

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

toStringList

     public static String[] toStringList(String s)

  Converts a string to an array of Strings.

  Parameters:
    s - the comma-separated strings

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

toDate

     public Date toDate(String s,
                        Date def)

    All Packages  Class Hierarchy  This Package  Previous  Next  Index