Class UtilCM

java.lang.Object
  |
  +--UtilCM

public class UtilCM
extends java.lang.Object

Collection of utility functions used by various other classes.

This work was produced by Peter Lemkin of the National Cancer Institute, an agency of the United States Government. As a work of the United States Government there is no associated copyright. It is offered as open source software under the Mozilla Public License (version 1.1) subject to the limitations noted in the accompanying LEGAL file.

Version:
$Date: 2002/10/14 19:22:31 $ $Revision: 1.6 $
Author:
P. Lemkin (NCI), G. Thornwall (SAIC), B. Stephens(SAIC), NCI-Frederick, Frederick, MD
See Also:
MAExplorer Home

Field Summary
static boolean dbugFlag
          Local debugging flag.
 TextFrame err
          error msg text frame
 TextFrame out
          output and error text frames
 java.awt.TextField status2Text
           
 java.awt.TextField status3Text
           
 java.awt.TextField statusText
          Contents of last status messages
 
Constructor Summary
UtilCM(boolean dbugFlag)
          UtilCM() - constructor for setup utility pkg
 
Method Summary
 boolean copyFile(java.lang.String srcName, java.lang.String dstName, java.lang.String optUpdateMsg, int optEstInputFileLth)
          copyFile() - binary copy of one file or URL toa local file
static java.lang.String cvb2s(boolean b)
          cvb2s() - convert boolean String
static boolean cvs2b(java.lang.String str, boolean defaultBool)
          cvs2b() - convert String to boolean
static float cvs2f(java.lang.String str, float defaultFloat)
          cvs2f() - convert String to float
static int cvs2i(java.lang.String str, int defaultInt)
          cvs2i() - convert String to int
static long cvs2l(java.lang.String str, long defaultLong)
          cvs2l() - convert String to long
static java.lang.String dateStr()
          dateStr() - return a new Date string of the current day and time
 boolean deleteLocalFile(java.lang.String fileName)
          deleteLocalFile() - delete local file.
 boolean delFile(java.lang.String fullFileName)
          delFile() - Delete specifile file specified with full path.
 void logMsg(java.lang.String msg)
          logMsg() - log the message in statusText and log file window drawing it in Color.black.
 void logMsg(java.lang.String msg, boolean isVisibleFlag, java.awt.Color color)
          logMsg() - log the message in statusText and log file window
 void logMsg(java.lang.String msg, java.awt.Color color)
          logMsg() - log the message in statusText and log file window
 void logMsg2(java.lang.String msg, boolean isVisibleFlag, java.awt.Color color)
          logMsg2() - log the message in status2Text and log file window
 void logMsg2(java.lang.String msg, java.awt.Color color)
          logMsg2() - log the message in status2Text and log file window
 void logMsg3(java.lang.String msg, boolean isVisibleFlag, java.awt.Color color)
          logMsg3() - log the message in status3Text and log file window
 void logMsg3(java.lang.String msg, java.awt.Color color)
          logMsg3() - log the message in status3Text and log file window
static java.lang.String mapComma2Tab(java.lang.String s)
          mapComma2Tab() - map "," to "\t" in the string
(package private) static java.lang.String mapIllegalChars(java.lang.String str)
          mapIllegalChars() - map characters to '_' i.e.
static java.lang.String mapSpaceToMinus(java.lang.String str)
          mapSpaceToMinus() - map " " to "-"
static java.lang.String removeQuotes(java.lang.String line)
          removeQuotes() - remove '\"' characters from line
 void setOutErrTextFrames(TextFrame out, TextFrame err)
          setOutErrTextFrames() - set out and err text frames
 void setStatusTextFrames(java.awt.TextField statusText, java.awt.TextField status2Text, java.awt.TextField status3Text)
          setStatusTextFrames() - set status text frames
static java.lang.String timeStr()
          timeStr() - return a new daytime HH:MM:SS string of the current time
(package private)  boolean updateCvt2MaeJarFile()
          updateCvt2MaeJarFile() - update MAExplorer.jar into program install area.
(package private)  boolean updateCvt2MaeProgram()
          updateCvt2MaeProgram() - verify that want to update the Cvt2Mae.jar file from the maexplorer.sourceforge.net server.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

statusText

public java.awt.TextField statusText
Contents of last status messages

status2Text

public java.awt.TextField status2Text

status3Text

public java.awt.TextField status3Text

out

public TextFrame out
output and error text frames

err

public TextFrame err
error msg text frame

dbugFlag

public static boolean dbugFlag
Local debugging flag. If set, then logMsg() output is also printed to System.out
Constructor Detail

UtilCM

public UtilCM(boolean dbugFlag)
UtilCM() - constructor for setup utility pkg
Parameters:
dbugFlag -  
Method Detail

setStatusTextFrames

public void setStatusTextFrames(java.awt.TextField statusText,
                                java.awt.TextField status2Text,
                                java.awt.TextField status3Text)
setStatusTextFrames() - set status text frames
Parameters:
statusText - is text field 1
statusText - is text field 2
statusText - is text field 3

setOutErrTextFrames

public void setOutErrTextFrames(TextFrame out,
                                TextFrame err)
setOutErrTextFrames() - set out and err text frames
Parameters:
out - is text output field
err - is text error output field

logMsg

public void logMsg(java.lang.String msg,
                   java.awt.Color color)
logMsg() - log the message in statusText and log file window
Parameters:
msg - is message to log
color - to draw the message

logMsg

public void logMsg(java.lang.String msg)
logMsg() - log the message in statusText and log file window drawing it in Color.black.
Parameters:
msg - is message to log

logMsg

public void logMsg(java.lang.String msg,
                   boolean isVisibleFlag,
                   java.awt.Color color)
logMsg() - log the message in statusText and log file window
Parameters:
msg - is message to log
isVisibleFlag - to make log popup visible/invisible
color - to draw the message
See Also:
TextFrame.appendLog(java.lang.String)

logMsg2

public void logMsg2(java.lang.String msg,
                    java.awt.Color color)
logMsg2() - log the message in status2Text and log file window
Parameters:
msg - is message to log
color - to draw the message

logMsg2

public void logMsg2(java.lang.String msg,
                    boolean isVisibleFlag,
                    java.awt.Color color)
logMsg2() - log the message in status2Text and log file window
Parameters:
msg - is message to log
isVisibleFlag - to make log popup visible/invisible
color - to draw the message
See Also:
TextFrame.appendLog(java.lang.String)

logMsg3

public void logMsg3(java.lang.String msg,
                    java.awt.Color color)
logMsg3() - log the message in status3Text and log file window
Parameters:
msg - is message to log
color - to draw the message

logMsg3

public void logMsg3(java.lang.String msg,
                    boolean isVisibleFlag,
                    java.awt.Color color)
logMsg3() - log the message in status3Text and log file window
Parameters:
msg - is message to log
isVisibleFlag - to make log popup visible/invisible
color - to draw the message
See Also:
TextFrame.appendLog(java.lang.String)

dateStr

public static java.lang.String dateStr()
dateStr() - return a new Date string of the current day and time
Returns:
date string

timeStr

public static java.lang.String timeStr()
timeStr() - return a new daytime HH:MM:SS string of the current time
Returns:
time of day string

mapComma2Tab

public static java.lang.String mapComma2Tab(java.lang.String s)
mapComma2Tab() - map "," to "\t" in the string
Parameters:
s - input string to map
Returns:
mapped string

cvb2s

public static java.lang.String cvb2s(boolean b)
cvb2s() - convert boolean String
Parameters:
b - is boolean input to convert
Returns:
output string as either "true" or "false"

cvs2f

public static float cvs2f(java.lang.String str,
                          float defaultFloat)
cvs2f() - convert String to float
Parameters:
str - containing floating point number to convert to float
Returns:
converted number else defaultFloat if illegal number.

cvs2l

public static long cvs2l(java.lang.String str,
                         long defaultLong)
cvs2l() - convert String to long
Parameters:
str - containing integer to convert to long
Returns:
converted number else defaultLong if illegal number.

cvs2i

public static int cvs2i(java.lang.String str,
                        int defaultInt)
cvs2i() - convert String to int
Parameters:
str - containing integer to convert to int
Returns:
converted number else defaultInt if illegal number.

cvs2b

public static boolean cvs2b(java.lang.String str,
                            boolean defaultBool)
cvs2b() - convert String to boolean
Parameters:
str - containing either "true" or "false"
Returns:
converted boolean else false if illegal boolean name.

mapIllegalChars

static java.lang.String mapIllegalChars(java.lang.String str)
mapIllegalChars() - map characters to '_' i.e. ' ', '\t', ':', ';', '\"', ',', '\'' '@', '*', '=' to '_'
Parameters:
str - to map
Returns:
String mapped

mapSpaceToMinus

public static java.lang.String mapSpaceToMinus(java.lang.String str)
mapSpaceToMinus() - map " " to "-"
Parameters:
str - to map
Returns:
mapped string

delFile

public boolean delFile(java.lang.String fullFileName)
delFile() - Delete specifile file specified with full path.
Parameters:
fullFileName - of file to delete

removeQuotes

public static java.lang.String removeQuotes(java.lang.String line)
removeQuotes() - remove '\"' characters from line
Parameters:
line - to check and edit out quotes

copyFile

public boolean copyFile(java.lang.String srcName,
                        java.lang.String dstName,
                        java.lang.String optUpdateMsg,
                        int optEstInputFileLth)
copyFile() - binary copy of one file or URL toa local file
Parameters:
srcName - is either a full path local file name or a http:// prefixed URL string of the source file.
dstName - is the full path of the local destination file name
optUpdateMsg - (opt) will display message in showMsg() and increasing ... in showMsg2(). One '.' for every 10K bytes read. This only is used when reading a URL. Set to null if not used.
optEstInputFileLth - is the estimate size of the in;ut file if known else 0. Used in progress bar.
Returns:
true if succeed.

deleteLocalFile

public boolean deleteLocalFile(java.lang.String fileName)
deleteLocalFile() - delete local file.
Returns:
false if failed.

updateCvt2MaeJarFile

final boolean updateCvt2MaeJarFile()
updateCvt2MaeJarFile() - update MAExplorer.jar into program install area.
 [1] Define directory for MAExplorer.jar path and other file and URL names.
 [2] Backup the old MAExplorer.jar as MAExplorer.jar.bkup
 [3] Open the url: from maeJarURL. This is hardwired to be
         "http://maexplorer.sourceforge.net/MAExplorer/MAExplorer.jar"
     and read the file from the Web into local file "MAExplorer.jar.tmp"
 [4] Move the "MAExplorer.jar.tmp" file into "MAExplorer.jar" in the program directory

 Since changing the MAExplorer.jar file is a potential security risk,
 we make this procedure final and hardwire the maeJarURL!
Returns:
true if succeed
See Also:
copyFile(java.lang.String, java.lang.String, java.lang.String, int), deleteLocalFile(java.lang.String)

updateCvt2MaeProgram

boolean updateCvt2MaeProgram()
updateCvt2MaeProgram() - verify that want to update the Cvt2Mae.jar file from the maexplorer.sourceforge.net server.