edu.upenn.crimson
Class CrimsonUtils

java.lang.Object
  extended by edu.upenn.crimson.CrimsonUtils

public class CrimsonUtils
extends java.lang.Object

CrimsonUtils. Miscellaneous functions.

Version:
$Id: CrimsonUtils.java,v 1.19 2009/07/25 03:37:09 fisher Exp $

Field Summary
private static java.lang.String DATABASE
          String containing database name (SID).
private static java.lang.String DB_TYPE
          String containing type of database ("oracle" or "mysql").
static int ERROR
           
static int FEEDBACK
           
static javax.swing.JTextArea guiMessages
          If not null, all error and warning messages will be sent here.
private static int PORT
          String containing port connection information (default = 1521).
static java.util.Random random
          Global random object.
private static java.lang.String SERVER
          String containing server connection information.
private static java.lang.String TMP_DIR
          String containing the location of the temporary dataloader files.
private static java.lang.String USERNAME
          String containing username for database connection.
private static int VERBOSE
          Amount of detailed feedback: 2 = lots, 1 = no warnings (default), 0 = no feedback.
static int WARNING
           
 
Constructor Summary
CrimsonUtils()
           
 
Method Summary
static boolean createTmpDir()
          This will create the temporary directory, if necessary, returning 'true' if successful.
static boolean deleteTmpFile(java.lang.String filename)
          This will delete the specified file, if it exists in TMP_DIR.
static java.lang.String getClassName(java.lang.Object o)
          Get the class name without any package info.
static java.lang.String getDatabase()
          Get the DATABASE flag.
static java.lang.String getDBType()
          Get the DB_TYPE flag.
static int getPort()
          Get the PORT flag.
static java.lang.String getServer()
          Get the SERVER flag.
static java.lang.String getTmpDir()
          Get the TMP_DIR.
static java.lang.String getUsername()
          Get the USERNAME flag.
static int getVerbose()
          Get the VERBOSE flag.
static boolean isEmpty(java.util.Collection collection)
          Returns true if 'collection' is empty or null.
static boolean isEmpty(java.lang.String str)
          Returns true if 'str' is empty (ignores spaces) or null.
static void printError(java.lang.String msg)
          Display the message to either the gui or stderr.
static void printMsg(java.lang.String msg)
          Display the message to either the gui or stderr.
static void printMsg(java.lang.String msg, boolean newline)
          Display the message to either the gui or stderr.
static void printMsg(java.lang.String msg, int type)
          Display the message to either the gui or stderr.
static void printMsg(java.lang.String msg, int type, boolean newline)
          Display the message to either the gui or stderr.
static void printWarning(java.lang.String msg)
          Display the message to either the gui or stderr.
static void resetCrimsonDefaults()
          RE-set Crimson user defaults.
static void setDatabase(java.lang.String database)
          Set the DATABASE flag.
static void setDBType(java.lang.String dbType)
          Set the DB_TYPE flag.
static void setPort(int port)
          Set the PORT flag.
static void setRandomSeed(long seed)
          The seed is initially set to the system time.
static void setServer(java.lang.String server)
          Set the SERVER flag.
static void setTmpDir(java.lang.String tmpDir)
          Set the TMP_DIR variable.
static java.lang.String setToList(java.util.HashSet set)
          This will return the elements of a HashSet as a ':' delimited string.
static void setUsername(java.lang.String username)
          Set the USERNAME flag.
static void setVerbose(int verbose)
          Set the VERBOSE flag.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WARNING

public static final int WARNING
See Also:
Constant Field Values

ERROR

public static final int ERROR
See Also:
Constant Field Values

FEEDBACK

public static final int FEEDBACK
See Also:
Constant Field Values

VERBOSE

private static int VERBOSE
Amount of detailed feedback: 2 = lots, 1 = no warnings (default), 0 = no feedback.


TMP_DIR

private static java.lang.String TMP_DIR
String containing the location of the temporary dataloader files.


USERNAME

private static java.lang.String USERNAME
String containing username for database connection.


SERVER

private static java.lang.String SERVER
String containing server connection information.


PORT

private static int PORT
String containing port connection information (default = 1521).


DB_TYPE

private static java.lang.String DB_TYPE
String containing type of database ("oracle" or "mysql").


DATABASE

private static java.lang.String DATABASE
String containing database name (SID).


random

public static java.util.Random random
Global random object.


guiMessages

public static javax.swing.JTextArea guiMessages
If not null, all error and warning messages will be sent here. This messages panel can be disabled by setting the value to null. When disabled, all messages printed will be sent to stderr, which will effectively display them in the console. If the GUI menu is not visible then messages will be sent to stderr in addition to guiMessages (if it exists).

Constructor Detail

CrimsonUtils

public CrimsonUtils()
Method Detail

setVerbose

public static void setVerbose(int verbose)
Set the VERBOSE flag.


getVerbose

public static int getVerbose()
Get the VERBOSE flag.


setTmpDir

public static void setTmpDir(java.lang.String tmpDir)
Set the TMP_DIR variable.


getTmpDir

public static java.lang.String getTmpDir()
Get the TMP_DIR.


setUsername

public static void setUsername(java.lang.String username)
Set the USERNAME flag.


getUsername

public static java.lang.String getUsername()
Get the USERNAME flag.


setServer

public static void setServer(java.lang.String server)
Set the SERVER flag.


getServer

public static java.lang.String getServer()
Get the SERVER flag.


setPort

public static void setPort(int port)
Set the PORT flag.


getPort

public static int getPort()
Get the PORT flag.


setDBType

public static void setDBType(java.lang.String dbType)
Set the DB_TYPE flag.


getDBType

public static java.lang.String getDBType()
Get the DB_TYPE flag.


setDatabase

public static void setDatabase(java.lang.String database)
Set the DATABASE flag.


getDatabase

public static java.lang.String getDatabase()
Get the DATABASE flag.


setRandomSeed

public static void setRandomSeed(long seed)
The seed is initially set to the system time. This routine can be used to change the seed.


isEmpty

public static boolean isEmpty(java.lang.String str)
Returns true if 'str' is empty (ignores spaces) or null.


isEmpty

public static boolean isEmpty(java.util.Collection collection)
Returns true if 'collection' is empty or null.


resetCrimsonDefaults

public static void resetCrimsonDefaults()
RE-set Crimson user defaults.


createTmpDir

public static boolean createTmpDir()
This will create the temporary directory, if necessary, returning 'true' if successful. Any ancestorial directories that don't already exist will also be created. We don't provide a method to remove the temporary directory. It is advised that the user perform this function manually through the operating system, in order to make sure critical files are not accidentally removed.


deleteTmpFile

public static boolean deleteTmpFile(java.lang.String filename)
This will delete the specified file, if it exists in TMP_DIR. If the file doesn't exist, then this won't do anything.


setToList

public static java.lang.String setToList(java.util.HashSet set)
This will return the elements of a HashSet as a ':' delimited string.


getClassName

public static java.lang.String getClassName(java.lang.Object o)
Get the class name without any package info.


printWarning

public static void printWarning(java.lang.String msg)
Display the message to either the gui or stderr.


printError

public static void printError(java.lang.String msg)
Display the message to either the gui or stderr.


printMsg

public static void printMsg(java.lang.String msg)
Display the message to either the gui or stderr.


printMsg

public static void printMsg(java.lang.String msg,
                            int type)
Display the message to either the gui or stderr.


printMsg

public static void printMsg(java.lang.String msg,
                            boolean newline)
Display the message to either the gui or stderr.


printMsg

public static void printMsg(java.lang.String msg,
                            int type,
                            boolean newline)
Display the message to either the gui or stderr. The message type can be set which will add the appropriate label to the message (1 = warning, 2 = error).




Copyright 2006 Stephen Fisher, Susan Davidson, and Junhyong Kim, University of Pennsylvania.