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

## gnu
Class UUtilities

    java.lang.Object
      gnu.UUtilities

    public class UUtilities

extends java.lang.Object

This class contains a bunch of methods, useful for the programmer.

Version:
  2.3.0
Author:
  Romain Guy, Slava Pestov, James Gosling
See Also:
  `Jext`

Field Summary
`static java.lang.String` | `JDK_VERSION` JDK release version.
`static int` | `OPEN` This constant defines an open dialog box.
`static int` | `SAVE` This constant defines a save dialog box.
`static int` | `SCRIPT` This constant defines an open dialog box.

Constructor Summary
`UUtilities()`

Method Summary
`static void` | `beep()` Used to 'beep' the user.
`static boolean` | `beginsWithRoot(java.lang.String path)` It can be necessary to check if a path specified by the user is an absolute path (i.e C:\Gfx\3d\Utils is absolute whereas ..
`static void` | `centerComponent(java.awt.Component compo)` A very nice trick is to center windows on screen, this method helps you to to that.
`static void` | `centerComponentChild(java.awt.Component parent, java.awt.Component child)` A very nice trick is to center dialog with their parent.
`static java.lang.String` | `chooseFile(java.awt.Component owner, int mode)` Display a file chooser dialog box.
`static java.lang.String` | `classToFile(java.lang.String name)` Converts a clas name to a file name.
`static java.lang.String` | `constructPath(java.lang.String change)` Constructs a new path from current user path.
`static java.lang.String` | `createWhiteSpace(int len)` Create a blank String made of spaces.
`static java.lang.String` | `createWhiteSpace(int len, int tabSize)` Create a blank String made of tabs.
`static java.lang.String` | `fileToClass(java.lang.String name)` Converts a file name to a class name.
`static java.lang.String` | `getHomeDirectory()` Returns user's home directory.
`static int` | `getLeadingWhiteSpace(java.lang.String str)` Returns the number of leading white space characters in the specified string.
`static int` | `getLeadingWhiteSpaceWidth(java.lang.String str, int tabSize)` Returns the width of the leading white space in the specified string.
`static int` | `getRealLength(java.lang.String str, int tabSize)`
`static java.lang.String` | `getRoot(java.lang.String path)` It can be necessary to determine which is the root of a path.
`static java.awt.Dimension` | `getScreenDimension()` This methods is used to determine screen's dimensions.
`static java.lang.String` | `getShortStringOf(java.lang.String longString, int maxLength)` Some String can be too long to be correctly displayed on the screen.
`static java.lang.String` | `getUserDirectory()` Returns user directory.
`static java.lang.String[]` | `getWildCardMatches(java.lang.String s, boolean sort)` When the user has to specify file names, he can use wildcards (*, ?).
`static java.lang.String[]` | `getWildCardMatches(java.lang.String path, java.lang.String s, boolean sort)` When the user has to specify file names, he can use wildcards (*, ?).
`static java.lang.String` | `globToRE(java.lang.String glob)` Turns a Un*x glob filter to regexp one
`static java.io.File[]` | `listFiles(java.lang.String[] names, boolean construct)` Lists content of a directory.
`static java.io.File[]` | `listFiles(java.lang.String[] names, java.lang.String path, boolean construct)` Lists content of a directory.
`static boolean` | `match(java.lang.String pattern, java.lang.String string)` This method can determine if a String matches a pattern of wildcards
`static void` | `setCursorOnWait(java.awt.Component comp, boolean on)` Long operations need to display an hourglass.
`static void` | `showError(java.lang.String message)` Display an error message in a dialog box.
`static void` | `showMessage(java.lang.String message)` Display a sample message in a dialog box.
`static void` | `showMessage(java.lang.String title, java.lang.String message)` Display a sample message in a dialog box.
`static void` | `sortStrings(java.lang.String[] strings)` Deprecated. Use the standard Java java.util.Array.sort instead.

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

Field Detail

### OPEN

    public static final int OPEN

  This constant defines an open dialog box.

  See Also:
    Constant Field Values

### SAVE

    public static final int SAVE

  This constant defines a save dialog box.

  See Also:
    Constant Field Values

### SCRIPT

    public static final int SCRIPT

  This constant defines an open dialog box.

  See Also:
    Constant Field Values

### JDK_VERSION

    public static final java.lang.String JDK_VERSION

  JDK release version.

Constructor Detail

### UUtilities

    public UUtilities()

Method Detail

### showMessage

    public static void showMessage(java.lang.String message)

  Display a sample message in a dialog box.

  Parameters:
    `message` - The message to display

### showError

    public static void showError(java.lang.String message)

  Display an error message in a dialog box.

  Parameters:
    `message` - The message to display

### showMessage

    public static void showMessage(java.lang.String title,
                                   java.lang.String message)

  Display a sample message in a dialog box.

  Parameters:
    `message` - The message to display

### getScreenDimension

    public static java.awt.Dimension getScreenDimension()

  This methods is used to determine screen's dimensions.

  Returns:
    A `Dimension` object containing screen's resolution

### centerComponent

    public static void centerComponent(java.awt.Component compo)

  A very nice trick is to center windows on screen, this method helps you to to that.

  Parameters:
    `compo` - The `Component` to center

### centerComponentChild

    public static void centerComponentChild(java.awt.Component parent,
                                            java.awt.Component child)

  A very nice trick is to center dialog with their parent.

  Parameters:
    `parent` - The parent `Component`
    `child` - The `Component` to center

### classToFile

    public static java.lang.String classToFile(java.lang.String name)

  Converts a clas name to a file name. All periods are replaced with slashes and the '.class' extension is added.

  Parameters:
    `name` - The class name

### fileToClass

    public static java.lang.String fileToClass(java.lang.String name)

  Converts a file name to a class name. All slash characters are replaced with periods and the trailing '.class' is removed.

  Parameters:
    `name` - The file name

### beep

    public static void beep()

  Used to 'beep' the user.

### setCursorOnWait

    public static void setCursorOnWait(java.awt.Component comp,
                                       boolean on)

  Long operations need to display an hourglass.

  Parameters:
    `comp` - The `JComponent` on which to apply the hour glass cursor
    `on` - If true, we set the cursor on the hourglass

### chooseFile

    public static java.lang.String chooseFile(java.awt.Component owner,
                                              int mode)

  Display a file chooser dialog box.

  Parameters:
    `owner` - `Component` which 'owns' the dialog
    `mode` - Can be either `OPEN`, `SCRIPT` or `SAVE`
  Returns:
    The path to selected file, null otherwise

### createWhiteSpace

    public static java.lang.String createWhiteSpace(int len)

  Create a blank String made of spaces.

  Parameters:
    `len` - Amount of spaces contained in the String
  Returns:
    A blank `String`

### createWhiteSpace

    public static java.lang.String createWhiteSpace(int len,
                                                    int tabSize)

  Create a blank String made of tabs.

  Parameters:
    `len` - Amount of spaces contained in the String
    `tabSize` - Tabulation size
  Returns:
    A blank `String`

### getLeadingWhiteSpace

    public static int getLeadingWhiteSpace(java.lang.String str)

  Returns the number of leading white space characters in the specified string.

  Parameters:
    `str` - The string

### getLeadingWhiteSpaceWidth

    public static int getLeadingWhiteSpaceWidth(java.lang.String str,
                                                int tabSize)

  Returns the width of the leading white space in the specified string.

  Parameters:
    `str` - The string
    `tabSize` - The tab size

### getRealLength

    public static int getRealLength(java.lang.String str,
                                    int tabSize)

### getShortStringOf

    public static java.lang.String getShortStringOf(java.lang.String longString,
                                                    int maxLength)

  Some String can be too long to be correctly displayed on the screen. Mainly when it is a path to a file. This method truncate a String.

  Parameters:
    `longString` - The `String` to be truncated
    `maxLength` - The maximum length of the `String`
  Returns:
    The truncated string

### constructPath

    public static java.lang.String constructPath(java.lang.String change)

  Constructs a new path from current user path. This is an easy way to get a path if the user specified, for example, "..\Java" as new path. This method will return the argument if this one is a path to a root (i.e, if `change` is equal to C:\Jdk, constructPath will return C:\Jdk).

  Parameters:
    `change` - The modification to apply to the path

### beginsWithRoot

    public static boolean beginsWithRoot(java.lang.String path)

  It can be necessary to check if a path specified by the user is an absolute path (i.e C:\Gfx\3d\Utils is absolute whereas ..\Jext is relative).

  Parameters:
    `path` - The path to check
  Returns:
    `true` if `path` begins with a root name

### getUserDirectory

    public static java.lang.String getUserDirectory()

  Returns user directory.

### getHomeDirectory

    public static java.lang.String getHomeDirectory()

  Returns user's home directory.

### getRoot

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

  It can be necessary to determine which is the root of a path. For example, the root of D:\Projects\Java is D:\.

  Parameters:
    `path` - The path used to get a root
  Returns:
    The root which contais the specified path

### getWildCardMatches

    public static java.lang.String[] getWildCardMatches(java.lang.String s,
                                                        boolean sort)

  When the user has to specify file names, he can use wildcards (*, ?). This methods handles the usage of these wildcards.

  Parameters:
    `s` - Wilcards
    `sort` - Set to true will sort file names
  Returns:
    An array of String which contains all files matching `s` in current directory.

### getWildCardMatches

    public static java.lang.String[] getWildCardMatches(java.lang.String path,
                                                        java.lang.String s,
                                                        boolean sort)

  When the user has to specify file names, he can use wildcards (*, ?). This methods handles the usage of these wildcards.

  Parameters:
    `path` - The path were to search
    `s` - Wilcards
    `sort` - Set to true will sort file names
  Returns:
    An array of String which contains all files matching `s` in current directory.

### match

    public static boolean match(java.lang.String pattern,
                                java.lang.String string)

  This method can determine if a String matches a pattern of wildcards

  Parameters:
    `pattern` - The pattern used for comparison
    `string` - The String to be checked
  Returns:
    true if `string` matches `pattern`

### sortStrings

    public static void sortStrings(java.lang.String[] strings)

  Deprecated. Use the standard Java java.util.Array.sort instead.

  Quick sort an array of Strings.

  Parameters:
    `string` - Strings to be sorted

### listFiles

    public static java.io.File[] listFiles(java.lang.String[] names,
                                           boolean construct)

  Lists content of a directory.

  Parameters:
    `names` - Names of the files
    `construct` - Set it to true if names does not contain full paths
  Returns:
    An array of Files

### listFiles

    public static java.io.File[] listFiles(java.lang.String[] names,
                                           java.lang.String path,
                                           boolean construct)

  Lists content of a directory.

  Parameters:
    `names` - Names of the files
    `path` - Base path for files
    `construct` - Set it to true if names does not contain full paths
  Returns:
    An array of Files

### globToRE

    public static java.lang.String globToRE(java.lang.String glob)

  Turns a Un*x glob filter to regexp one

  Parameters:
    `glob` - Globbed filter

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

Copyright © Madkit Team (O. Gutknecht, J. Ferber, F. Michel et al.) All Rights Reserved.