Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.jext
Class Utilities  view Utilities download Utilities.java

java.lang.Object
  extended byorg.jext.Utilities

public class Utilities
extends java.lang.Object

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

Version:
2.3.0

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
Utilities()
           
 
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 ..\Jext is relative).
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[] chooseFiles(java.awt.Component owner, int mode)
          Display a file chooser dialog box and returns selected files.
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 void copy(java.io.InputStream in, java.io.OutputStream out, boolean threaded)
          Convenience method for calling
static void copy(java.io.InputStream in, java.io.OutputStream out, boolean threaded, org.jext.misc.HandlingRunnable notify)
          Deprecated. maybe, use the version with a CopyThread as second parameter instead(I think it's cleaner, this version should go away).
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 void downloadFile(java.net.URL source, java.lang.String outPath, boolean threaded)
           
static void downloadFile(java.net.URL source, java.lang.String outPath, boolean threaded, org.jext.misc.HandlingRunnable notify)
          Downloads the file specified in the URL to the File with the outPath path using copy() (so see copy() for infos about notify and threaded).
static java.lang.String fileToClass(java.lang.String name)
          Converts a file name to a class name.
private static javax.swing.JFileChooser getFileChooser(java.awt.Component owner, int mode)
           
static java.lang.String getHomeDirectory()
          Returns user's home directory.
static javax.swing.ImageIcon getIcon(java.lang.String picture, java.lang.Class source)
          We may need to load and display images.
static java.awt.Image getImage(java.lang.String picture, java.lang.Class source)
          We may need to load and display images.
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

Utilities

public Utilities()
Method Detail

showMessage

public static void showMessage(java.lang.String message)
Display a sample message in a dialog box.


showError

public static void showError(java.lang.String message)
Display an error message in a dialog box.


showMessage

public static void showMessage(java.lang.String title,
                               java.lang.String message)
Display a sample message in a dialog box.


getScreenDimension

public static java.awt.Dimension getScreenDimension()
This methods is used to determine screen's dimensions.


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.


centerComponentChild

public static void centerComponentChild(java.awt.Component parent,
                                        java.awt.Component child)
A very nice trick is to center dialog with their parent.


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.


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.


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.


getIcon

public static javax.swing.ImageIcon getIcon(java.lang.String picture,
                                            java.lang.Class source)
We may need to load and display images.


getImage

public static java.awt.Image getImage(java.lang.String picture,
                                      java.lang.Class source)
We may need to load and display images.


chooseFiles

public static java.lang.String[] chooseFiles(java.awt.Component owner,
                                             int mode)
Display a file chooser dialog box and returns selected files.


chooseFile

public static java.lang.String chooseFile(java.awt.Component owner,
                                          int mode)
Display a file chooser dialog box.


getFileChooser

private static javax.swing.JFileChooser getFileChooser(java.awt.Component owner,
                                                       int mode)

createWhiteSpace

public static java.lang.String createWhiteSpace(int len)
Create a blank String made of spaces.


createWhiteSpace

public static java.lang.String createWhiteSpace(int len,
                                                int tabSize)
Create a blank String made of tabs.


getLeadingWhiteSpace

public static int getLeadingWhiteSpace(java.lang.String str)
Returns the number of leading white space characters in the specified string.


getLeadingWhiteSpaceWidth

public static int getLeadingWhiteSpaceWidth(java.lang.String str,
                                            int tabSize)
Returns the width of the leading white space in the specified string.


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.


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


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


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:\.


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.


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.


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


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.


listFiles

public static java.io.File[] listFiles(java.lang.String[] names,
                                       boolean construct)
Lists content of a directory.


listFiles

public static java.io.File[] listFiles(java.lang.String[] names,
                                       java.lang.String path,
                                       boolean construct)
Lists content of a directory.


globToRE

public static java.lang.String globToRE(java.lang.String glob)
Turns a Un*x glob filter to regexp one


downloadFile

public static void downloadFile(java.net.URL source,
                                java.lang.String outPath,
                                boolean threaded)
                         throws java.io.IOException
Since:
Jext 3.2pre4

downloadFile

public static void downloadFile(java.net.URL source,
                                java.lang.String outPath,
                                boolean threaded,
                                org.jext.misc.HandlingRunnable notify)
                         throws java.io.IOException
Downloads the file specified in the URL to the File with the outPath path using copy() (so see copy() for infos about notify and threaded).

Since:
Jext 3.2pre4

copy

public static void copy(java.io.InputStream in,
                        java.io.OutputStream out,
                        boolean threaded)
                 throws java.io.IOException
Convenience method for calling

Since:
Jext 3.2pre4

copy

public static void copy(java.io.InputStream in,
                        java.io.OutputStream out,
                        boolean threaded,
                        org.jext.misc.HandlingRunnable notify)
                 throws java.io.IOException
Deprecated. maybe, use the version with a CopyThread as second parameter instead(I think it's cleaner, this version should go away).

This method copy the content of the InputStream in to the OutputStream out, in the calling thread or in a new one. If threaded is true, a new thread is created, and notify will be called at the end, and will have passed the exception eventually thrown while doing the copy. Otherwise, the copy is done synchronously; if an exception is thrown during the copy it is dispatched to the calling method, otherwise the notify is called.

Since:
Jext 3.2pre4