UTJML

edu.utep.cs.utjml.canica
Class Util

java.lang.Object
  extended by edu.utep.cs.utjml.canica.Util
All Implemented Interfaces:
Constants

public abstract class Util
extends Object
implements Constants

A utility class that provides various static utility methods.

Author:
Yoonsik Cheon and Angelica B. Perez

Field Summary
 
Fields inherited from interface edu.utep.cs.utjml.canica.Constants
BLANK_ICON, CLASS_EXTENSION, COLOR_EXPLORER, COLOR_OUTPUT, COPYRIGHT, DEBUG, EDIT_MENU_NAME, EXPLORER_DIR, EXPLORER_ROOT, FILE_MENU_NAME, FILE_SEPARATOR, HELP_MENU_NAME, ICON_ABOUT, ICON_BROWSER, ICON_CASE_ACCEPTED, ICON_CASE_REJECTED, ICON_CHECK_JML, ICON_CLASS, ICON_COMMENT, ICON_COMPILE_FORTEST, ICON_COMPILE_JAVA, ICON_COMPILE_JML, ICON_COMPILE_JML_TEST, ICON_CONSOLE_VIEW, ICON_COPY, ICON_CUT, ICON_DELETE, ICON_ERROR, ICON_FILE, ICON_FOLDER, ICON_GOTO, ICON_HOME, ICON_INFORM, ICON_JAVA_FILE, ICON_JML_LOGO, ICON_JML_LOGO_ICONBEST, ICON_LOAD_ANDTEST, ICON_METHOD, ICON_NEW, ICON_NEWTESTSUITE, ICON_NOTE, ICON_OPEN, ICON_PASTE, ICON_PREFERENCES, ICON_PRINT, ICON_QUESTION, ICON_REDO, ICON_RUN, ICON_RUN_TEST, ICON_SAVE, ICON_SAVEALL, ICON_SAVEAS, ICON_SELECT_ALL, ICON_TEST_FILE, ICON_TEST_WIZARD, ICON_TESTCASE, ICON_TESTCASE_ERROR, ICON_TESTCASE_FAIL, ICON_TESTCASE_HIERARCHY, ICON_TESTCASE_OK, ICON_TESTCASE_RUNS, ICON_UNCOMMENT, ICON_UNDO, ICON_UNKNOWN, ICON_WARN, INSERT_MENU_NAME, JAVA, JAVA_EXTENSION, JAVAC, JUNIT_SWINGGUI_TESTRUNNER, looks, NEWLINE, OPTION_MENU_NAME, PATH_SEPARATOR, SEARCH_MENU_NAME, TEST_MENU_NAME, TOOL_MENU_NAME, VERSION, WEB_PAGE_LOCATION, WEB_PAGE_NAME, WINDOW_HEIGHT, WINDOW_MIN_HEIGHT, WINDOW_MIN_WIDTH, WINDOW_WIDTH
 
Method Summary
static void centerWindow(Component window)
          Centers the given window within the screen.
static ComponentListener createComponentListener(int w, int h)
          Returns a component listener that prohibits the component c from being resized smaller than the width w and the height h.
static void debug(String msg)
          Prints the given message on stdout if the debug flag Constants.DEBUG is true; otherwise, do nothing.
static ImageIcon getIcon(String name)
          Returns an image icon whose image is read from the file named name.
static void invokeAndWait(Runnable job)
          Runs the given job in a thread-safe way.
static boolean isClassFile(File file)
          Returns true if the given file is a Java class file.
static boolean isClassFile(String name)
          Returns true if the given file name ends with the class extension.
static boolean isJavaFile(File file)
          Returns true if the given file is a Java source file.
static boolean isJavaFile(String name)
          Returns true if the argument names a Java source file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

invokeAndWait

public static void invokeAndWait(Runnable job)
Runs the given job in a thread-safe way.


centerWindow

public static void centerWindow(Component window)
Centers the given window within the screen.

Parameters:
window - The window to center.

    requires window != null;
 

getIcon

public static ImageIcon getIcon(String name)
Returns an image icon whose image is read from the file named name. A null is returned if reading the file fails.


debug

public static void debug(String msg)
Prints the given message on stdout if the debug flag Constants.DEBUG is true; otherwise, do nothing.


isJavaFile

public static boolean isJavaFile(String name)
Returns true if the argument names a Java source file. I.e., it ends with the Java extension (.java). If the argument is null, false is returned.


isJavaFile

public static boolean isJavaFile(File file)
Returns true if the given file is a Java source file. I.e., it ends with the Java extension (.java).


isClassFile

public static boolean isClassFile(File file)
Returns true if the given file is a Java class file. I.e., it ends with the Java extension (.class).


isClassFile

public static boolean isClassFile(String name)
Returns true if the given file name ends with the class extension.

Parameters:
name - File name
Returns:
True if is class file, false otherwise.

createComponentListener

public static ComponentListener createComponentListener(int w,
                                                        int h)
Returns a component listener that prohibits the component c from being resized smaller than the width w and the height h.


UTJML

UTJML is Copyright (C) 2004-2006 by University of Texas at El Paso and is distributed under the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This release depends on code from the JML project.