Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## de.caff.gimmix
Class Utility

    java.lang.Object
      de.caff.gimmix.Utility

    public class Utility

extends java.lang.Object

Utility contains some helpful functionality. Main thing to know is that the `Utility.setApplet(java.applet.Applet)` method has to be called explicitely in the `init()` method of an Applet for everything to work smoothly.

Constructor Summary
`Utility()`

Method Summary
`static boolean` | `areWeInAnApplet()` Are we running an applet?
`static boolean` | `areWeOnDOS()` Test wether our System is a DOS.
`static java.lang.String` | `compileString(java.lang.String tag, java.lang.Object[] args, java.util.ResourceBundle res)` Compile a formatted string with maximum 10 args.
`static void` | `debug(java.lang.Object x)` Print message if debug mode is on.
`static void` | `debug(java.lang.Throwable x)` Print the stack trace if debug mode is on.
`static boolean` | `equalBytes(byte[] arr1, int off1, byte[] arr2, int off2, int len)` Compare two byte arrays.
`static java.applet.Applet` | `getApplet()` Get the applet we are running in (if any).
`static boolean` | `getBooleanParameter(java.lang.String key, boolean def)` Look for a boolean applet parameter or application property.
`static java.awt.Color` | `getColorParameter(java.lang.String key, java.awt.Color def)` Look for a color applet parameter or application property.
`static double` | `getDoubleParameter(java.lang.String key, double def)` Look for a double applet parameter or application property.
`static float` | `getFloatParameter(java.lang.String key, float def)` Look for a float applet parameter or application property.
`static java.awt.Frame` | `getFrame(java.awt.Component comp)` Method to get the frame parent of any component.
`static int` | `getIntParameter(java.lang.String key, int def)` Look for a integer applet parameter or application property.
`static int` | `getIntParameter(java.lang.String key, int def, int base)` Look for an integer applet parameter or application property.
`static java.lang.String` | `getStringParameter(java.lang.String key, java.lang.String def)` Look for a String applet parameter or application property.
`static boolean` | `globEquals(java.lang.String mask, java.lang.String str)` An equal function which accepts globbing.
`static boolean` | `isDebug()` Get the debug mode.
`static java.awt.Image` | `loadImage(java.lang.String path)` Load an image and prepare a representation.
`static java.awt.Image` | `loadImage(java.lang.String path, java.awt.Component renderer)` Load an image and prepare a representation.
`static java.lang.String` | `loadText(java.lang.String path)` Load a text file into a string.
`static void` | `printProperties()` In debug mode: print properties to console.
`static void` | `printProperty(java.lang.String prop)` Print a given property to the console.
`static void` | `setApplet(java.applet.Applet applet)` Set the applet we are running in (if any).
`static void` | `setDebug(boolean mode)` Set the debugging mode.
`static void` | `setResourceDir(java.lang.String dir)` Set the resource directory.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### Utility

    public Utility()

Method Detail

### setDebug

    public static void setDebug(boolean mode)

  Set the debugging mode.

  Parameters:
    `mode` - new mode

### isDebug

    public static boolean isDebug()

  Get the debug mode.

  Returns:
    debug mode

### loadImage

    public static java.awt.Image loadImage(java.lang.String path)

  Load an image and prepare a representation. Used for static images to be loaded in an very early stage of program execution.

  Parameters:
    `path` - path of the image file
  Returns:
    the loaded image

### loadImage

    public static java.awt.Image loadImage(java.lang.String path,
                                           java.awt.Component renderer)

  Load an image and prepare a representation. Used for static images to be loaded in an very early stage of program execution.

  Parameters:
    `path` - path of the image file
    `renderer` - renderer used to render the image
  Returns:
    the loaded image

### loadText

    public static java.lang.String loadText(java.lang.String path)

  Load a text file into a string.

  Parameters:
    `path` - name of the text file
  Returns:
    the loaded text

### areWeOnDOS

    public static boolean areWeOnDOS()

  Test wether our System is a DOS.

  Returns:
    true we are on DOS

### setResourceDir

    public static void setResourceDir(java.lang.String dir)

  Set the resource directory.

  Parameters:
    `dir` - the image drirectory

### compileString

    public static java.lang.String compileString(java.lang.String tag,
                                                 java.lang.Object[] args,
                                                 java.util.ResourceBundle res)

  Compile a formatted string with maximum 10 args.

        Special signs:
           %#  where hash is a digit from 0 to 9 means insert arg #
           @#  where hash is a digit from 0 to 9 means insert localized arg #
           %%  means %
           @&@64;  means @

  Parameters:
    `tag` - resource tag for format string
    `args` - arguments for insertion
    `res` - active resource bundle
  Returns:
    String with inserted args.

### getFrame

    public static java.awt.Frame getFrame(java.awt.Component comp)

  Method to get the frame parent of any component.

  Parameters:
    `comp` - the component to search the frame for
  Returns:
    the frame parent of the component

### equalBytes

    public static boolean equalBytes(byte[] arr1,
                                     int off1,
                                     byte[] arr2,
                                     int off2,
                                     int len)

  Compare two byte arrays. Compare `len` bytes from array 1 starting with offset 1 with `len` bytes from array 2 starting with offset 2. Will return always `true` for `len ≤= 0`

  Parameters:
    `arr1` - array 1
    `off1` - offset 1
    `arr2` - array 2
    `off2` - offset 2
    `len` - length to compare
  Returns:
    `true` if both chunks are equal
    `false` otherwise

### setApplet

    public static void setApplet(java.applet.Applet applet)

  Set the applet we are running in (if any).

  Parameters:
    `applet` - applet we are running in (if `null` then we are running in an application

### getApplet

    public static java.applet.Applet getApplet()

  Get the applet we are running in (if any).

  Returns:
    applet or `null`

### areWeInAnApplet

    public static boolean areWeInAnApplet()

  Are we running an applet?

  Returns:
    the answer

### getBooleanParameter

    public static boolean getBooleanParameter(java.lang.String key,
                                              boolean def)

  Look for a boolean applet parameter or application property.

  Parameters:
    `key` - parameter key
    `def` - default value
  Returns:
    the parameter value (if set) or the default

### getStringParameter

    public static java.lang.String getStringParameter(java.lang.String key,
                                                      java.lang.String def)

  Look for a String applet parameter or application property.

  Parameters:
    `key` - parameter key
    `def` - default value
  Returns:
    the parameter value (if set) or the default

### getColorParameter

    public static java.awt.Color getColorParameter(java.lang.String key,
                                                   java.awt.Color def)

  Look for a color applet parameter or application property.

  Parameters:
    `key` - parameter key
    `def` - default value
  Returns:
    the parameter value (if set) or the default

### getIntParameter

    public static int getIntParameter(java.lang.String key,
                                      int def)

  Look for a integer applet parameter or application property.

  Parameters:
    `key` - parameter key
    `def` - default value
  Returns:
    the parameter value (if set) or the default

### getIntParameter

    public static int getIntParameter(java.lang.String key,
                                      int def,
                                      int base)

  Look for an integer applet parameter or application property.

  Parameters:
    `key` - parameter key
    `def` - default value
    `base` - number base
  Returns:
    the parameter value (if set) or the default

### getDoubleParameter

    public static double getDoubleParameter(java.lang.String key,
                                            double def)

  Look for a double applet parameter or application property.

  Parameters:
    `key` - parameter key
    `def` - default value
  Returns:
    the parameter value (if set) or the default

### getFloatParameter

    public static float getFloatParameter(java.lang.String key,
                                          float def)

  Look for a float applet parameter or application property.

  Parameters:
    `key` - parameter key
    `def` - default value
  Returns:
    the parameter value (if set) or the default

### debug

    public static void debug(java.lang.Object x)

  Print message if debug mode is on.

  Parameters:
    `x` - object which's toString is called

### debug

    public static void debug(java.lang.Throwable x)

  Print the stack trace if debug mode is on.

  Parameters:
    `x` - exception

### printProperty

    public static void printProperty(java.lang.String prop)

  Print a given property to the console. Catch possible Security exceptions. Does nothing if not in debug mode.

  Parameters:
    `prop` - poperty name

### printProperties

    public static void printProperties()

  In debug mode: print properties to console.

### globEquals

    public static boolean globEquals(java.lang.String mask,
                                     java.lang.String str)

  An equal function which accepts globbing. This method accepts the glob chars `'*'` (for any number of chars) and `'?'` (any single char).

  Parameters:
    `mask` - glob mask (containing special chars)
    `str` - string to be checked against mask
  Returns:
    wether the string matches the mask

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD