edu.rice.cs.javalanglevels.util
Class Utilities

java.lang.Object
  extended by edu.rice.cs.javalanglevels.util.Utilities

public class Utilities
extends Object


Constructor Summary
Utilities()
           
 
Method Summary
static
<T> T[]
catenate(T[] A, T[] B)
           
static void clearEventQueue()
           
static boolean contains(Object[] a, Object elt)
          The standard java.util contains method on arrays of reference type.
static void copyFile(File sourceFile, File destFile)
          A file copy method taken from the web.
static AbstractAction createDelegateAction(String newName, Action delegate)
           
static String getClipboardSelection(Component c)
           
static String getStackTrace()
          Gets the stack trace of the current code.
static String getStackTrace(Throwable t)
          Gets the stack trace of the given Throwable as a String.
static boolean hasVisibilityModifier(String[] modifiers)
           
static void invokeAndWait(Runnable task)
           
static void invokeLater(Runnable task)
          Runs the task synchronously if the current thread is the event thread; otherwise passes it to the event thread to be run asynchronously after all events already on the queue have been processed.
static boolean isAbstract(ModifiersAndVisibility mav)
           
static boolean isAbstract(String[] modifiers)
           
static boolean isFinal(ModifiersAndVisibility mav)
           
static boolean isFinal(String[] modifiers)
           
static boolean isPrivate(ModifiersAndVisibility mav)
           
static boolean isPrivate(String[] modifiers)
           
static boolean isProtected(ModifiersAndVisibility mav)
           
static boolean isProtected(String[] modifiers)
           
static boolean isPublic(ModifiersAndVisibility mav)
           
static boolean isPublic(String[] modifiers)
           
static boolean isStatic(ModifiersAndVisibility mav)
           
static boolean isStatic(String[] modifiers)
           
static void main(String[] args)
           
static void show(String msg)
          Show a modal debug message box with an OK button regardless of TEST_MODE.
static void showDebug(String msg)
          Shows a modal debug message box with an OK button when not in TEST_MODE.
static void showMessageBox(String msg, String title)
          Shows a modal message box with an OK button.
static void showStackTrace(Throwable t)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Utilities

public Utilities()
Method Detail

copyFile

public static void copyFile(File sourceFile,
                            File destFile)
                     throws IOException
A file copy method taken from the web.

Throws:
IOException

invokeLater

public static void invokeLater(Runnable task)
Runs the task synchronously if the current thread is the event thread; otherwise passes it to the event thread to be run asynchronously after all events already on the queue have been processed.


invokeAndWait

public static void invokeAndWait(Runnable task)

main

public static void main(String[] args)

clearEventQueue

public static void clearEventQueue()

show

public static void show(String msg)
Show a modal debug message box with an OK button regardless of TEST_MODE.

Parameters:
msg - string to display

showDebug

public static void showDebug(String msg)
Shows a modal debug message box with an OK button when not in TEST_MODE.

Parameters:
msg - string to display

showMessageBox

public static void showMessageBox(String msg,
                                  String title)
Shows a modal message box with an OK button.

Parameters:
msg - string to display

showStackTrace

public static void showStackTrace(Throwable t)

getClipboardSelection

public static String getClipboardSelection(Component c)
Returns:
a string with the current clipboard selection, or null if not available.

createDelegateAction

public static AbstractAction createDelegateAction(String newName,
                                                  Action delegate)
Returns:
an action with a new name that delegates to another action.

getStackTrace

public static String getStackTrace(Throwable t)
Gets the stack trace of the given Throwable as a String.

Parameters:
t - the throwable object for which to get the stack trace
Returns:
the stack trace of the given Throwable

getStackTrace

public static String getStackTrace()
Gets the stack trace of the current code. Does not include this method.

Returns:
the stack trace for the current code

contains

public static boolean contains(Object[] a,
                               Object elt)
The standard java.util contains method on arrays of reference type.

Returns:
true iff the value elt appears in a.

hasVisibilityModifier

public static boolean hasVisibilityModifier(String[] modifiers)
Returns:
true iff that has a visibility modifier.

isFinal

public static boolean isFinal(String[] modifiers)
Returns:
true iff that has "final" as a modifier.

isStatic

public static boolean isStatic(String[] modifiers)
Returns:
true iff that has "final" as a modifier.

isPublic

public static boolean isPublic(String[] modifiers)
Returns:
true iff that has "public" as a modifier.

isProtected

public static boolean isProtected(String[] modifiers)
Returns:
true iff that has "protected" as a modifier.

isPrivate

public static boolean isPrivate(String[] modifiers)
Returns:
true iff that has "protected" as a modifier.

isAbstract

public static boolean isAbstract(String[] modifiers)
Returns:
true iff that has "abstract" as a modifier.

isFinal

public static boolean isFinal(ModifiersAndVisibility mav)
Returns:
true iff that has "final" as a modifier.

isStatic

public static boolean isStatic(ModifiersAndVisibility mav)
Returns:
true iff that has "final" as a modifier.

isPublic

public static boolean isPublic(ModifiersAndVisibility mav)
Returns:
true iff that has "public" as a modifier.

isProtected

public static boolean isProtected(ModifiersAndVisibility mav)
Returns:
true iff that has "public" as a modifier.

isPrivate

public static boolean isPrivate(ModifiersAndVisibility mav)
Returns:
true iff that has "public" as a modifier.

isAbstract

public static boolean isAbstract(ModifiersAndVisibility mav)
Returns:
true iff that has "abstract" as a modifier.

catenate

public static <T> T[] catenate(T[] A,
                               T[] B)