|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--ix.util.Util
Class for useful static methods that don't belong anywhere else.
Collect
,
Fn
,
Strings
Inner Class Summary | |
static class |
Util.NameGenerator
Name generator a la gensym. |
Constructor Summary | |
Util()
|
Method Summary | |
static java.lang.String |
askLine(java.lang.String prompt)
Simple, text-based user interaction. |
static java.lang.Object |
copy(java.lang.Object obj)
Returns a top-level copy of the object. |
static java.lang.Object |
copy(java.lang.Object obj,
java.lang.Class resultClass)
Returns a top-level copy as an instance of the specified result class. |
static boolean |
dialogConfirms(java.awt.Component parent,
java.lang.String text)
Displays a confirmation dialog. |
static void |
displayAndWait(java.awt.Component parentComponent,
java.lang.Object message)
Asks the GUI event-handling thread to displays a text message in a dialogue box and does not return until this has occurred. |
static void |
displayMessage(java.awt.Component parentComponent,
java.lang.Object message)
Asks the GUI event-handling thread to displays a text message in a dialogue box. |
static java.lang.String |
generateName(java.lang.String base)
Generates a name unique within this VM that begins with the specified base string. |
static java.lang.String |
getHostName()
Returns the name of the machine that is running this JVM. |
static java.lang.String |
getUserName()
Returns the name of the user who started this JVM. |
static java.lang.Object |
makeInstance(java.lang.Class c)
Makes an instance of a class using the 0-argument constructor. |
static void |
notImplemented(java.awt.Component parent,
java.lang.String item)
Brings up a message that the given string item is not yet supported. |
static void |
printGreeting(java.lang.String name)
A method to print the name of the system, the release version, and the release date. |
static void |
printLines(java.lang.String[] lines)
Print the elements of a String[] array to System.out as lines. |
static java.lang.String |
quote(java.lang.String text)
Puts double quotes around a string. |
static java.lang.String |
readLine(java.io.InputStream is)
Reads a line from an InputStream and returns it as a String. |
static javax.swing.ImageIcon |
resourceImageIcon(java.lang.String name)
Constructs an ImageIcon from the named (image) resource found on the system's class path. |
static javax.swing.ImageIcon |
resourceImageIconFromFile(java.lang.String filename)
Deprecated. As of April 1, 2002; try resourceImageIcon(String) . |
Methods inherited from class java.lang.Object |
|
Constructor Detail |
public Util()
Method Detail |
public static void printGreeting(java.lang.String name)
public static void displayMessage(java.awt.Component parentComponent, java.lang.Object message)
Always calls SwingUtilities.invokeLater(Runnable)
,
which puts the request at the end of the queue even if called
from the event dispatching thread.
parentComponent
- determines the Frame in which dialogs
are displayed.message
- the contents of the message.public static void displayAndWait(java.awt.Component parentComponent, java.lang.Object message)
If this method is called outside the event dispatching
thread, it calls SwingUtilities.invokeAndWait(Runnable)
.
parentComponent
- determines the Frame in which dialogs
are displayed.text
- the contents of the message.public static void notImplemented(java.awt.Component parent, java.lang.String item)
public static boolean dialogConfirms(java.awt.Component parent, java.lang.String text)
public static javax.swing.ImageIcon resourceImageIcon(java.lang.String name)
public static javax.swing.ImageIcon resourceImageIconFromFile(java.lang.String filename)
resourceImageIcon(String)
.
public static java.lang.String getUserName()
public static java.lang.String getHostName() throws java.net.UnknownHostException
public static java.lang.String quote(java.lang.String text)
public static java.lang.String generateName(java.lang.String base)
public static java.lang.Object copy(java.lang.Object obj) throws java.lang.InstantiationException, java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
ObjectCopier
public static java.lang.Object copy(java.lang.Object obj, java.lang.Class resultClass) throws java.lang.InstantiationException, java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
ObjectCopier
public static java.lang.Object makeInstance(java.lang.Class c)
java.lang.Error
- if the attempt fails.public static void printLines(java.lang.String[] lines)
public static java.lang.String askLine(java.lang.String prompt)
If askLine blocks when reading, we'd like other threads to be able to run; but that doesn't seem to happen reliably. Presumably, this is a bug. In any case, askLine works around the problem by having a loop that checks whether input is available and sleeps for a second if it isn't.
public static java.lang.String readLine(java.io.InputStream is)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |