O2Plib.misc
Class Util

java.lang.Object
  extended by O2Plib.misc.Util

public class Util
extends java.lang.Object

Class Util utilities for Open2Dprot program.

This file is derived from MAExplorer, Flicker and an early version of Seg2Dgel programs.

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. This notice must be included with the code. The Open2Dprot Mozilla and Legal files are available on http://Open2Dprot.sourceforge.net/.

Version:
$Date: 2005/10/21 16:33:51 $ $Revision: 1.29 $
Author:
P. Lemkin, NCI-Frederick, Frederick, MD, 21702

Field Summary
static java.lang.String applicationName
          Name of this application
static long baseStatusTime
          base starting time in epoch msec time for the status reports
static boolean CONSOLE_FLAG
           
static boolean dbugConsoleFlag
          Debug console flag adds additional output to console
static double defaultDouble
           
static float defaultFloat
           
static int defaultInt
           
static java.lang.String fileSeparator
          File separator: Property("file.separator")
(package private) static int MAX_STATUS_TIMES
          Max # of report timer status names
static int maxStatusTimes
          max # of times to track with setReportStatus().
static boolean NEVER
          NEVER and CONSOLE_FLAG - debugging variables - must not be final!
static int nStatusName
          # of Report status names saved when do setReportStatus(name) calls.
static java.lang.String O2PLIB_VERSION
          O2Plib version number
static java.lang.String osName
          name of this operating system: Property("os.name")
static java.awt.Label rptStatusLineLabel
          Report Label will output updateReportStatusLine if not null.
static java.awt.TextField rptStatusLineTextField
          Report text field will output updateReportStatusLine if not null.
static java.awt.TextArea rptTextArea
          Report text area will output appendPRmsg if not null.
static int SHOW_DECIMAL
          Window dump OCTAL data mode
static int SHOW_HEX
          Window dump HEXIDECIMAL data mode
static int SHOW_OCTAL
          Window dump OCTAL data mode
static int SHOW_OD
          Window dump Optical Density data mode
static long startTime
          he start time for use with subsequent call to off_timer() without the start time arg.
static long[] statusMemoryFree
          Report status memory Free.
static long[] statusMemoryTot
          Report status memory Total.
static java.lang.String[] statusName
          Report status names saved when do setReportStatus(name) calls.
static long[] statusStartTime
          Report status starting times entries in epoch msec time Saved when do showReportStatus(name) calls.
static boolean timerSwitch
          timer is enabled
static java.lang.String userDir
          current User directory: getProperty("user.dir")+fileSeparator
static int WRITE_TO_BOTH
          code to write to Both StdOut and the disk
static int WRITE_TO_DISK
          code to write to StdOut
static int WRITE_TO_STDOUT
          code to write to StdOut
 
Constructor Summary
Util(java.lang.String applicationName)
          Util() - constructor
 
Method Summary
static java.lang.String[] addStringToStringList(java.lang.String[] strList, java.lang.String str)
          addStringToStringList() - arg string to string array.
static void appendPRmsg(java.lang.String msg)
          appendPRmsg() - append message to report text area window if it exists.
static boolean arrclr(byte[] data, byte value, int n)
          arrclr() - set all values of the byte array to byte value
static boolean arrclr(char[] data, char value, int n)
          arrclr() - set all values of the char array to char value
static boolean arrclr(float[] data, float value, int n)
          arrclr() - set all values of the float array to float value
static boolean arrclr(int[] data, int value, int n)
          arrclr() - set all values of the int array to int value
static boolean arrclr(long[] data, long value, int n)
          arrclr() - set all values of the long array to long value
static boolean arrclr(short[] data, short value, int n)
          arrclr() - set all values of the short array to short value
static boolean arrclr(java.lang.String[] data, java.lang.String value, int n)
          arrclr() - set all values of the String array to short value
static void badArgExit(java.lang.String badSwitch, java.lang.String errMsg, boolean exitFlag)
          badArgExit() - print switch arg error message and exit with -1 if exitFlag is set.
static java.lang.String calcStatusTimesReport()
          calcStatusTimesReport() - compute the status times and memory usage report if the timer is on.
static int cvByte2Int(byte b)
          cvByte2Int() - convert unsigned byte [0:255] to int in range [0:255]
static java.lang.String cvd2s(double v, int precision)
          cvd2s() - convert double to string with precision # of digits If precision > 0 then limit # of digits in fraction
static java.lang.String cvDeltaTime2str(long deltaTimeMsec, boolean fullCvtFlag)
          cvDeltaTime2str() - convert a delta epoch time msec to a string "00:01:30 (H:M:S) or 90.0 seconds"
static java.lang.String cvf2s(float v, int precision)
          cvf2s() - convert float to string with exact precision # of digits.
static java.lang.String cvf2sVariable(float v, int precision)
          cvf2sVariable() - convert float to string with precision # of digits.
static java.lang.String cvi2hexs(int iVal)
          cvi2hexs() - convert integer number to hex string
static java.lang.String cvi2hexs(int iVal, int width)
          cvi2hexs() - convert integer number to hex string
static java.lang.String cvi2os(int iVal)
          cvi2os() - convert integer number to octal string with leading 0.
static java.lang.String cvi2os(int iVal, int width)
          cvi2os() - convert integer number to octal string.
static java.lang.String cvi2s(int iVal)
          cvi2s() - convert integer number to integer string
static java.lang.String cvi2s(int iVal, int width)
          cvi2s() - convert integer number to string with left spaces filled
static java.lang.String cviByRadix(int val, int radix, int fWidth, CalibrateOD cal)
          cviByRadix() - convert int by radix to specific space filled from left
static byte cvInt2Byte(int i)
          cvInt2Byte() - convert unsignged int [0:255] to signed byte [-128:+127]
static java.lang.String[] cvs2Array(java.lang.String str, int maxExpected, java.lang.String delimiterChr)
          cvs2Array() - cvt arg list "1,4,3,6,..." to "," - delim String[].
static double cvs2d(java.lang.String str)
          cvs2d() - convert String to double
static double cvs2d(java.lang.String str, double defaultValue)
          cvs2d() - convert String to double with default value
static float cvs2f(java.lang.String str)
          cvs2f() - convert String to float
static float cvs2f(java.lang.String str, float defaultValue)
          cvs2f() - convert String to float with default value
static float[] cvs2fArray(java.lang.String str, int maxExpected, java.lang.String delimChr)
          cvs2fArray() - convert String arg list "1,4,3,6,..." to int[]
static int cvs2i(java.lang.String str)
          cvs2i() - convert integer String to int
static int cvs2i(java.lang.String str, int defaultValue)
          cvs2i() - convert String to int with default value
static int[] cvs2iArray(java.lang.String str, int maxExpected, java.lang.String delimChr)
          cvs2iArray() - convert String arg list "1,4,3,6,..." to int[]
static int cvs2o(java.lang.String str)
          cvs2o() - convert octal String to int
static int cvs2o(java.lang.String str, int defaultValue)
          cvs2o() - convert octal String to int with default value
static java.lang.String[] cvtNullsToEmptyStrings(java.lang.String[] strData)
          cvtNullsToEmptyStrings() - convert nulls to "" in string array
static java.lang.String[] cvtQuoteNullsToEmptyStrings(java.lang.String[] strData)
          cvtQuoteNullsToEmptyStrings() - convert "null"s to "" in string array
static java.lang.String dateStr()
          dateStr() - return a new Date string of the current day and time
static void fatalExit(java.lang.String errMsg, boolean exitFlag)
          fatalExit() - print error message and exit with -1 if exitFlag set.
static java.lang.String gcAndMemoryStats(java.lang.String msg, boolean statsFlag)
          gcAndMemoryStats() - String garbage collect & print memory statistics.
static java.lang.String getCurDateStr()
          getCurDateStr() - return date string in the format of YYMMDDHHMMSS.
static java.lang.String getFileName(java.lang.String filePath)
          getFileName() - get the file name after last '/' if any
static java.lang.String getFileNameFromPath(java.lang.String path)
          getFileNameFromPath() - extract the filename from the path
static java.lang.String getFullInfo()
          getFullInfo() - get the full file info on the program and exit.
static java.lang.String getNthCommaSeparatedArg(java.lang.String argList, int n)
          getNthCommaSeparatedArg() - get n'th arg in comma separated list.
static java.lang.String getPrettyPrintCurrentDateStr()
          getPrettyPrintCurrentDateStr() - get a printable current date string
static boolean isValInList(float val, float[] valueList)
          isValInList() - test if val is in list of values.
static boolean isValInList(int val, int[] valueList)
          isValInList() - test if val is in list of values.
static java.lang.String leftFillWithSpaces(java.lang.String str, int n)
          leftFillWithSpaces() - left fill the string with spaces to size n.
static int nextPrime(int n)
          nextPrime() - find the next prime # >= n.
static java.lang.String off_timer()
          off_timer() - Compute the time banner String using the previously set startTime.
static java.lang.String off_timer(long startT)
          off_timer() - Compute the time banner String assuming that a on_timer(cpuTime,runTime) was done previously.
static long on_timer()
          on_timer() - Get the current time (in milliseconds)
static void popupAlertMsg(java.lang.String msg, java.awt.Color bgColor)
          popupAlertMsg() - display msg in status and popup up an Alert message
static java.lang.String prettyPrintDateStr(java.lang.String ds)
          prettyPrintDateStr() - pretty-print date string.
static void printCurrentMemoryUsage(java.lang.String msg)
          printCurrentMemoryUsage() - print: %free, total memory usage and time of day to stdout.
static java.lang.String replaceNthCommaSeparatedArg(java.lang.String argList, int n, java.lang.String sVal)
          replaceNthCommaSeparatedArg() - replace n'th arg in comma separated argList with sVal
static java.lang.String rightFillWithSpaces(java.lang.String str, int n)
          rightFillWithSpaces() - right fill the string with spaces to size n.
static char[] rightSize(char[] data, int nSize)
          rightSize() - right-size the size of the char[] array to nSize
static double[] rightSize(double[] data, int nSize)
          rightSize() - right-size the size of the double[] array to nSize
static float[] rightSize(float[] data, int nSize)
          rightSize() - right-size the size of the float[] array to nSize
static int[] rightSize(int[] data, int nSize)
          rightSize() - right-size the size of the int[] array to nSize
static java.lang.String[] rightSize(java.lang.String[] data)
          rightSize() - right-size the size of the String[] array to the size determined by the first null entry.
static java.lang.String[] rightSize(java.lang.String[] data, int nSize)
          rightSize() - right-size the size of the String[] array to nSize
static java.lang.String rmvFileExtension(java.lang.String fileName)
          rmvFileExtension() - remove ".tif", ".jpg", ".gif", ".ppx", ".j2k" from file name and ignore the case.
static java.lang.String rmvRtnChars(java.lang.String str)
          rmvRtnChars() - remove return chars.
static java.lang.String rmvSpecifiedChar(java.lang.String str, char rmvChar)
          rmvSpecifiedChar() - remove specified chararcter
static void setApplicationName(java.lang.String anApplicationName)
           
static void setDebugConsoleFlag(boolean flag)
          setDebugConsoleFlag() - set debugConsoleFlag to send all appendPRmsg() output to console.
static void setMaxNbrStatusTimes(int maxNbrStatusTimes)
          setMaxNbrStatusTimes() - setup the status times in maxStatusTimes
static void setReportStatus(java.lang.String opr)
          setReportStatus() - setup the status times
static void setReportStatusLineLabel(java.awt.Label rptStatusLineLbl)
          setReportStatusLineLabel() - assign report status line label in popup report window.
static void setReportStatusLineTextField(java.awt.TextField rptStatusLineTxtField)
          setReportStatusLineTextField() - assign report status line text field in popup report window.
static void setReportTextArea(java.awt.TextArea rptTxtArea)
          setReportTextArea() - assign report text area in popup report window
static void setStartTime(long startT)
          setStartTime() - set the start time for use with subsequent call to off_timer() without the start time arg.
static void showFullInfo(boolean exitFlag)
          showFullInfo() - print full info on the program and exit if exitFlag is set.
static void showMsg(java.lang.String msg)
          showMsg() - display the msg in message window
static void showReportStatus(java.lang.String opr)
          showReportStatus() - display the msg in popup report line display And update the timer for the opr
static void showStatus(java.lang.String msg)
          showStatus() - display the msg in status
static void sleepMsec(int mSec)
          sleepMsec() - sleep for mSec.
static java.lang.String trimDelimChars(java.lang.String s, java.lang.String delimChar)
          trimDelimChars() - trim enclosing delimiter charaters if present.
static void updateReportStatusLine(java.lang.String msg)
          updateReportStatusLine() - set status line message if text field and/or Label was assigned.
static void usage(java.lang.String msg, boolean exitFlag)
          usage() - print command usage.
static void usageFile(java.lang.String msg, boolean exitFlag)
          usageFile() - print command usage.
static java.lang.String useFileSeparatorChar(java.lang.String str, java.lang.String newSeparatorStr)
          useFileSeparatorChar() - use specified file separator chararcter Eg.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

O2PLIB_VERSION

public static java.lang.String O2PLIB_VERSION
O2Plib version number


NEVER

public static boolean NEVER
NEVER and CONSOLE_FLAG - debugging variables - must not be final!


CONSOLE_FLAG

public static boolean CONSOLE_FLAG

WRITE_TO_STDOUT

public static final int WRITE_TO_STDOUT
code to write to StdOut

See Also:
Constant Field Values

WRITE_TO_BOTH

public static final int WRITE_TO_BOTH
code to write to Both StdOut and the disk

See Also:
Constant Field Values

WRITE_TO_DISK

public static final int WRITE_TO_DISK
code to write to StdOut

See Also:
Constant Field Values

SHOW_DECIMAL

public static final int SHOW_DECIMAL
Window dump OCTAL data mode

See Also:
Constant Field Values

SHOW_OCTAL

public static final int SHOW_OCTAL
Window dump OCTAL data mode

See Also:
Constant Field Values

SHOW_HEX

public static final int SHOW_HEX
Window dump HEXIDECIMAL data mode

See Also:
Constant Field Values

SHOW_OD

public static final int SHOW_OD
Window dump Optical Density data mode

See Also:
Constant Field Values

osName

public static java.lang.String osName
name of this operating system: Property("os.name")


fileSeparator

public static java.lang.String fileSeparator
File separator: Property("file.separator")


userDir

public static java.lang.String userDir
current User directory: getProperty("user.dir")+fileSeparator


applicationName

public static java.lang.String applicationName
Name of this application


dbugConsoleFlag

public static boolean dbugConsoleFlag
Debug console flag adds additional output to console


rptTextArea

public static java.awt.TextArea rptTextArea
Report text area will output appendPRmsg if not null. This is set with setReportTextArea().


rptStatusLineTextField

public static java.awt.TextField rptStatusLineTextField
Report text field will output updateReportStatusLine if not null. This is set with setReportStatusLineTextField().


rptStatusLineLabel

public static java.awt.Label rptStatusLineLabel
Report Label will output updateReportStatusLine if not null. This is set with setReportStatusLineLabel().


MAX_STATUS_TIMES

static final int MAX_STATUS_TIMES
Max # of report timer status names

See Also:
Constant Field Values

startTime

public static long startTime
he start time for use with subsequent call to off_timer() without the start time arg.


maxStatusTimes

public static int maxStatusTimes
max # of times to track with setReportStatus().


statusStartTime

public static long[] statusStartTime
Report status starting times entries in epoch msec time Saved when do showReportStatus(name) calls. Ignore "Line# ..." names. Size [0:maxStatusTimes-1]


statusMemoryTot

public static long[] statusMemoryTot
Report status memory Total. Saved when do setReportStatus(name) calls. Ignore "Line# ..." names. Size [0:maxStatusTimes-1]


statusMemoryFree

public static long[] statusMemoryFree
Report status memory Free. Saved when do setReportStatus(name) calls. Ignore "Line# ..." names. Size [0:maxStatusTimes-1]


statusName

public static java.lang.String[] statusName
Report status names saved when do setReportStatus(name) calls. Ignore "Line# ..." names. Size [0:maxStatusTimes-1]


nStatusName

public static int nStatusName
# of Report status names saved when do setReportStatus(name) calls. Ignore "Line# ..." names.


baseStatusTime

public static long baseStatusTime
base starting time in epoch msec time for the status reports


timerSwitch

public static boolean timerSwitch
timer is enabled


defaultDouble

public static double defaultDouble

defaultFloat

public static float defaultFloat

defaultInt

public static int defaultInt
Constructor Detail

Util

public Util(java.lang.String applicationName)
Util() - constructor

Method Detail

setApplicationName

public static void setApplicationName(java.lang.String anApplicationName)

showStatus

public static void showStatus(java.lang.String msg)
showStatus() - display the msg in status

Parameters:
msg - to display

showMsg

public static void showMsg(java.lang.String msg)
showMsg() - display the msg in message window

Parameters:
msg - to display

setReportTextArea

public static void setReportTextArea(java.awt.TextArea rptTxtArea)
setReportTextArea() - assign report text area in popup report window

Parameters:
rptTxtArea - is text area to write appendPRmsg() calls if this is null, then it will not append output to this text area but rather send it to stdout.

setReportStatusLineTextField

public static void setReportStatusLineTextField(java.awt.TextField rptStatusLineTxtField)
setReportStatusLineTextField() - assign report status line text field in popup report window.

Parameters:
rptStatusLineTxtField - is text field to write updateReportStatusLine() calls if this is null, then it will not output this text field but rather send it to stdout.

setReportStatusLineLabel

public static void setReportStatusLineLabel(java.awt.Label rptStatusLineLbl)
setReportStatusLineLabel() - assign report status line label in popup report window.

Parameters:
rptStatusLineLabel - is label to write updateReportStatusLine() calls if this is null, then it will not output this text field but rather send it to stdout.

setDebugConsoleFlag

public static void setDebugConsoleFlag(boolean flag)
setDebugConsoleFlag() - set debugConsoleFlag to send all appendPRmsg() output to console.

Parameters:
flag - to send output to the console

appendPRmsg

public static void appendPRmsg(java.lang.String msg)
appendPRmsg() - append message to report text area window if it exists. Otherwise it send it to stdout. If the dbugConsoleFlag is set, it also sends it to stdout.

Parameters:
msg - to display

popupAlertMsg

public static void popupAlertMsg(java.lang.String msg,
                                 java.awt.Color bgColor)
popupAlertMsg() - display msg in status and popup up an Alert message

Parameters:
msg - to display
bgColor - is the background color to use

badArgExit

public static void badArgExit(java.lang.String badSwitch,
                              java.lang.String errMsg,
                              boolean exitFlag)
badArgExit() - print switch arg error message and exit with -1 if exitFlag is set.

Parameters:
badSwitch - is the unpacked switch string that is bad
errMsg - to print
exitFlag - to exit after the message

fatalExit

public static void fatalExit(java.lang.String errMsg,
                             boolean exitFlag)
fatalExit() - print error message and exit with -1 if exitFlag set.

Parameters:
errMsg - to print
exitFlag - to exit after the message

usage

public static void usage(java.lang.String msg,
                         boolean exitFlag)
usage() - print command usage. and exit. If an arg and exitFlag set, take error exit -1 instead of 0.

Parameters:
msg - optional message to print at the end of the usage
exitFlag - to exit after the message

usageFile

public static void usageFile(java.lang.String msg,
                             boolean exitFlag)
usageFile() - print command usage. and exit. If an arg and exitFlag set, take error exit -1 instead of 0.

Parameters:
msg - optional message to print at the end of the usage
exitFlag - to exit after the message

showFullInfo

public static void showFullInfo(boolean exitFlag)
showFullInfo() - print full info on the program and exit if exitFlag is set.

Parameters:
exitFlag - to exit after the message

getFullInfo

public static java.lang.String getFullInfo()
getFullInfo() - get the full file info on the program and exit.


updateReportStatusLine

public static void updateReportStatusLine(java.lang.String msg)
updateReportStatusLine() - set status line message if text field and/or Label was assigned.

Parameters:
msg - to display
See Also:
setReportStatusLineTextField(java.awt.TextField), setReportStatusLineLabel(java.awt.Label)

showReportStatus

public static void showReportStatus(java.lang.String opr)
showReportStatus() - display the msg in popup report line display And update the timer for the opr

Parameters:
opr - to display
See Also:
setReportStatusLineTextField(java.awt.TextField), setReportStatus(java.lang.String)

setMaxNbrStatusTimes

public static void setMaxNbrStatusTimes(int maxNbrStatusTimes)
setMaxNbrStatusTimes() - setup the status times in maxStatusTimes

Parameters:
maxNbrStatusTimes - to track. This overides MAX_STATUS_TIMES

setReportStatus

public static void setReportStatus(java.lang.String opr)
setReportStatus() - setup the status times

Parameters:
opr - to reset if to display. It will reset the data if it has never been used or opr is "Reset". It will not save the status times if opr starts with "Line#".

calcStatusTimesReport

public static java.lang.String calcStatusTimesReport()
calcStatusTimesReport() - compute the status times and memory usage report if the timer is on. This will be called if the timer was enabled.

Returns:
status times and memory usage report if timer is on, else return ""

arrclr

public static boolean arrclr(byte[] data,
                             byte value,
                             int n)
arrclr() - set all values of the byte array to byte value

Parameters:
data - array to set [0:n-1]
value - to be used to set
n - is # of values to set. Note array may be larger than n.

arrclr

public static boolean arrclr(char[] data,
                             char value,
                             int n)
arrclr() - set all values of the char array to char value

Parameters:
data - array to set [0:n-1]
value - to be used to set
n - is # of values to set. Note array may be larger than n.

arrclr

public static boolean arrclr(short[] data,
                             short value,
                             int n)
arrclr() - set all values of the short array to short value

Parameters:
data - array to set [0:n-1]
value - to be used to set
n - is # of values to set. Note array may be larger than n.

arrclr

public static boolean arrclr(int[] data,
                             int value,
                             int n)
arrclr() - set all values of the int array to int value

Parameters:
data - array to set [0:n-1]
value - to be used to set
n - is # of values to set. Note array may be larger than n.

arrclr

public static boolean arrclr(long[] data,
                             long value,
                             int n)
arrclr() - set all values of the long array to long value

Parameters:
data - array to set [0:n-1]
value - to be used to set
n - is # of values to set. Note array may be larger than n.

arrclr

public static boolean arrclr(float[] data,
                             float value,
                             int n)
arrclr() - set all values of the float array to float value

Parameters:
data - array to set [0:n-1]
value - to be used to set
n - is # of values to set. Note array may be larger than n.

arrclr

public static boolean arrclr(java.lang.String[] data,
                             java.lang.String value,
                             int n)
arrclr() - set all values of the String array to short value

Parameters:
data - array to set [0:n-1]
value - to be used to set
n - is # of values to set. Note array may be larger than n.

nextPrime

public static int nextPrime(int n)
nextPrime() - find the next prime # >= n. This uses a brute-force search that should not be much of a problem for reasonably small numbers. The numbers used in the program are for relatively small hash tables and these are reused so they will not be regenerated constantly.

Parameters:
n - lowest number to start looking for prime #
Returns:
next prime number

dateStr

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

Returns:
a new Date string of the current day and time

getPrettyPrintCurrentDateStr

public static java.lang.String getPrettyPrintCurrentDateStr()
getPrettyPrintCurrentDateStr() - get a printable current date string

Returns:
pretty print current string

getCurDateStr

public static java.lang.String getCurDateStr()
getCurDateStr() - return date string in the format of YYMMDDHHMMSS. This date string is sortable by date. Note: Adds "0" to first single digit if value is 1-9.


prettyPrintDateStr

public static java.lang.String prettyPrintDateStr(java.lang.String ds)
prettyPrintDateStr() - pretty-print date string.

Parameters:
ds - is the date string in the format of YYMMDDHHMMSS.
Returns:
pretty print string DD/MM/YY HH:MM:SS

cvDeltaTime2str

public static java.lang.String cvDeltaTime2str(long deltaTimeMsec,
                                               boolean fullCvtFlag)
cvDeltaTime2str() - convert a delta epoch time msec to a string "00:01:30 (H:M:S) or 90.0 seconds"

Parameters:
deltaTimeMsec - is the runtime (end-start) in msec.
fullCvtFlag - to generate a full conversion with H:M:S "00:01:30 (H:M:S) or 90.0 seconds" else generate "90.0 seconds"

setStartTime

public static void setStartTime(long startT)
setStartTime() - set the start time for use with subsequent call to off_timer() without the start time arg.

Parameters:
startT - is the starting times runtime

off_timer

public static java.lang.String off_timer()
off_timer() - Compute the time banner String using the previously set startTime. EXAMPLE: "00:01:30 (H:M:S) or 90.0 seconds"

See Also:
setStartTime(long)

off_timer

public static java.lang.String off_timer(long startT)
off_timer() - Compute the time banner String assuming that a on_timer(cpuTime,runTime) was done previously. EXAMPLE: "00:01:30 (H:M:S) or 90.0 seconds"

Parameters:
startT - is the starting times runtime

on_timer

public static long on_timer()
on_timer() - Get the current time (in milliseconds)

Returns:
runtime

sleepMsec

public static void sleepMsec(int mSec)
sleepMsec() - sleep for mSec.


cvByte2Int

public static final int cvByte2Int(byte b)
cvByte2Int() - convert unsigned byte [0:255] to int in range [0:255]

Parameters:
b - is byte to convert
Returns:
int value

cviByRadix

public static final java.lang.String cviByRadix(int val,
                                                int radix,
                                                int fWidth,
                                                CalibrateOD cal)
cviByRadix() - convert int by radix to specific space filled from left

Parameters:
val - to convert
radix - to use SHOW_xxxx (DECIMAL, OCTAL, HEX, OD)
fWidth - to display data
Returns:
string value

cvInt2Byte

public static final byte cvInt2Byte(int i)
cvInt2Byte() - convert unsignged int [0:255] to signed byte [-128:+127]

Parameters:
i - is int to convert
Returns:

cvi2s

public static final java.lang.String cvi2s(int iVal)
cvi2s() - convert integer number to integer string

Parameters:
iVal - to convert
Returns:
octal string [TODO]

cvi2s

public static final java.lang.String cvi2s(int iVal,
                                           int width)
cvi2s() - convert integer number to string with left spaces filled

Parameters:
iVal - to convert
width - to force leading spaces
Returns:
octal string [TODO]

cvi2os

public static final java.lang.String cvi2os(int iVal,
                                            int width)
cvi2os() - convert integer number to octal string. It will force at LEAST 1 leading 0.

Parameters:
iVal - to convert
width - to force leading space with 0's
Returns:
octal string

cvi2os

public static final java.lang.String cvi2os(int iVal)
cvi2os() - convert integer number to octal string with leading 0.

Parameters:
iVal - to convert
Returns:
octal string [TODO]

cvi2hexs

public static final java.lang.String cvi2hexs(int iVal,
                                              int width)
cvi2hexs() - convert integer number to hex string

Parameters:
iVal - to convert
width - to force leading space with spaces
Returns:
hex string

cvi2hexs

public static final java.lang.String cvi2hexs(int iVal)
cvi2hexs() - convert integer number to hex string

Parameters:
iVal - to convert
Returns:
hex string [TODO]

cvf2s

public static final java.lang.String cvf2s(float v,
                                           int precision)
cvf2s() - convert float to string with exact precision # of digits. If precision > 0 then limit # of digits in fraction

Parameters:
v - is value to convert
precision - is the # of digits precision in the mantissa
Returns:
string approximating "%0.pd" If abs(v) < pow(10.0,-p) then return "+0" or "-0"

cvf2sVariable

public static final java.lang.String cvf2sVariable(float v,
                                                   int precision)
cvf2sVariable() - convert float to string with precision # of digits. If precision > 0 then limit # of digits in fraction

Parameters:
v - is value to convert
precision - is the # of digits precision in the mantissa
Returns:
string approximating "%0.pd" If abs(v) < pow(10.0,-p) then return "+0" or "-0"

cvd2s

public static final java.lang.String cvd2s(double v,
                                           int precision)
cvd2s() - convert double to string with precision # of digits If precision > 0 then limit # of digits in fraction

Parameters:
v - is value to convert
precision - is the # of digits precision in the mantissa
Returns:
string approximating "%0.pd" If abs(v) < pow(10.0,-p) then return "+0" or "-0"

cvs2d

public static final double cvs2d(java.lang.String str)
cvs2d() - convert String to double

Parameters:
str - to convert
Returns:
numeric value, else defaultFloat if bad string

cvs2d

public static final double cvs2d(java.lang.String str,
                                 double defaultValue)
cvs2d() - convert String to double with default value

Parameters:
str - to convert
defaultValue - if bad numeric string
Returns:
numeric value

cvs2f

public static final float cvs2f(java.lang.String str)
cvs2f() - convert String to float

Parameters:
str - to convert
Returns:
numeric value, else defaultFloat if bad string

cvs2f

public static final float cvs2f(java.lang.String str,
                                float defaultValue)
cvs2f() - convert String to float with default value

Parameters:
str - to convert
defaultValue - if bad numeric string
Returns:
numeric value

cvs2o

public static final int cvs2o(java.lang.String str)
cvs2o() - convert octal String to int

Parameters:
str - to convert
Returns:
numeric value, else defaultInt if bad string

cvs2o

public static final int cvs2o(java.lang.String str,
                              int defaultValue)
cvs2o() - convert octal String to int with default value

Parameters:
str - to convert
defaultValue - if bad numeric string
Returns:
numeric value

cvs2i

public static final int cvs2i(java.lang.String str)
cvs2i() - convert integer String to int

Parameters:
str - to convert
Returns:
numeric value, else defaultInt if bad string

cvs2i

public static final int cvs2i(java.lang.String str,
                              int defaultValue)
cvs2i() - convert String to int with default value

Parameters:
str - to convert
defaultValue - if bad numeric string
Returns:
numeric value

getFileName

public static java.lang.String getFileName(java.lang.String filePath)
getFileName() - get the file name after last '/' if any

Parameters:
filePath - containing a '/' full path
Returns:
file name if found, else the original string

getFileNameFromPath

public static java.lang.String getFileNameFromPath(java.lang.String path)
getFileNameFromPath() - extract the filename from the path

Parameters:
filePath - containing a fileSeparator separated full path
Returns:
file name if found, else the original string

rmvFileExtension

public static final java.lang.String rmvFileExtension(java.lang.String fileName)
rmvFileExtension() - remove ".tif", ".jpg", ".gif", ".ppx", ".j2k" from file name and ignore the case.

Parameters:
fileName - containing a file which may have one of the allowed file extensions.
Returns:
filename without file extension if found, else the original string.

cvs2iArray

public static final int[] cvs2iArray(java.lang.String str,
                                     int maxExpected,
                                     java.lang.String delimChr)
cvs2iArray() - convert String arg list "1,4,3,6,..." to int[]

Parameters:
str - string containt a list of Strings
maxExpected - # of numbers to be parsed
delimChr - delimiter to be used
Returns:
array of ints else null if problem

cvs2fArray

public static final float[] cvs2fArray(java.lang.String str,
                                       int maxExpected,
                                       java.lang.String delimChr)
cvs2fArray() - convert String arg list "1,4,3,6,..." to int[]

Parameters:
str - string containt a list of Strings
maxExpected - # of numbers to be parsed
delimChr - delimiter to be used
Returns:
array of ints else null if problem

cvs2Array

public static final java.lang.String[] cvs2Array(java.lang.String str,
                                                 int maxExpected,
                                                 java.lang.String delimiterChr)
cvs2Array() - cvt arg list "1,4,3,6,..." to "," - delim String[]. If there are more than maxExpected number of args in string, ignore them and just return what has been parsed so far. Also, if the delimiter is not "\r" remove all "\r"s, and if the delimiter is not "\n" remove all "\n"s.

Parameters:
str - string containt a list of Strings
maxExpected - # of numbers to be parsed [DEPRICATED and ignored]
delimChr - delimiter to be used
Returns:
array of Strings else null if problem

addStringToStringList

public static final java.lang.String[] addStringToStringList(java.lang.String[] strList,
                                                             java.lang.String str)
addStringToStringList() - arg string to string array.

Parameters:
strList - is initial string array
str - to add to the end of the list
Returns:
new string array, null if an error

leftFillWithSpaces

public static final java.lang.String leftFillWithSpaces(java.lang.String str,
                                                        int n)
leftFillWithSpaces() - left fill the string with spaces to size n. If n < str.length(), then just return str.

Parameters:
str - to fill
n - max width
Returns:
adjusted string

rightFillWithSpaces

public static final java.lang.String rightFillWithSpaces(java.lang.String str,
                                                         int n)
rightFillWithSpaces() - right fill the string with spaces to size n. If n < str.length(), then just return str.

Parameters:
str - to fill
n - max width
Returns:
adjusted string

replaceNthCommaSeparatedArg

public static final java.lang.String replaceNthCommaSeparatedArg(java.lang.String argList,
                                                                 int n,
                                                                 java.lang.String sVal)
replaceNthCommaSeparatedArg() - replace n'th arg in comma separated argList with sVal

Parameters:
argList - is comma separated list "a1,a2,a3,..."
n - is the arg to replace starting at 1 (actually arg 0)
sVal - new value

getNthCommaSeparatedArg

public static final java.lang.String getNthCommaSeparatedArg(java.lang.String argList,
                                                             int n)
getNthCommaSeparatedArg() - get n'th arg in comma separated list.

Parameters:
argList - is comma separated list "a1,a2,a3,..."
n - is the arg to get starting at n==1 (actually arg 0)
Returns:
the nth ai in the list.

rmvRtnChars

public static final java.lang.String rmvRtnChars(java.lang.String str)
rmvRtnChars() - remove return chars. Map '\r' or "\r\n" to '\n' chars.

Parameters:
String - str to process
Returns:
String with '\r' removed.

rmvSpecifiedChar

public static final java.lang.String rmvSpecifiedChar(java.lang.String str,
                                                      char rmvChar)
rmvSpecifiedChar() - remove specified chararcter

Parameters:
str - to process
rmvChar - to remove
Returns:
String with all instances of the specified charater removed.

useFileSeparatorChar

public static final java.lang.String useFileSeparatorChar(java.lang.String str,
                                                          java.lang.String newSeparatorStr)
useFileSeparatorChar() - use specified file separator chararcter Eg. if it is '\' then switch '/' to '\', Eg. if it is '/' then switch '\' to '/',

Parameters:
str - to process
newSeparatorStr - to use
Returns:
String with all instances of the specified character changed.

printCurrentMemoryUsage

public static void printCurrentMemoryUsage(java.lang.String msg)
printCurrentMemoryUsage() - print: %free, total memory usage and time of day to stdout. A sample value is
   **** Memory[ BCF:setBrCt() end]:
   28% free, tot=24.36Mb [9:30:0] ****
,/PRE>

Parameters:
msg - to display with this memory snapshot
See Also:
FileIO#logMsgln, cvd2s(double, int), #timeStr

gcAndMemoryStats

public static java.lang.String gcAndMemoryStats(java.lang.String msg,
                                                boolean statsFlag)
gcAndMemoryStats() - String garbage collect & print memory statistics. Note that the free memory number is only an estimate. It may be more accurate if you run the garbage collector before calling 'freeMemory()'. Note: freeMemory is not always accurate. Print the accompanying message.

Parameters:
msg - to return
statsFlag - to add memory GC stats to msg.
Returns:
full message after G.C.

cvtNullsToEmptyStrings

public static final java.lang.String[] cvtNullsToEmptyStrings(java.lang.String[] strData)
cvtNullsToEmptyStrings() - convert nulls to "" in string array

Parameters:
strData - is array of possibly null strings
Returns:
corrected string array

cvtQuoteNullsToEmptyStrings

public static final java.lang.String[] cvtQuoteNullsToEmptyStrings(java.lang.String[] strData)
cvtQuoteNullsToEmptyStrings() - convert "null"s to "" in string array

Parameters:
strData - is array of possibly null strings
Returns:
corrected string array

isValInList

public static final boolean isValInList(int val,
                                        int[] valueList)
isValInList() - test if val is in list of values.

Parameters:
val - to test
valueList - is list of values to test
Returns:
true if spotNbr is in the valueList

isValInList

public static final boolean isValInList(float val,
                                        float[] valueList)
isValInList() - test if val is in list of values.

Parameters:
val - to test
valueList - is list of values to test
Returns:
true if spotNbr is in the valueList

trimDelimChars

public static final java.lang.String trimDelimChars(java.lang.String s,
                                                    java.lang.String delimChar)
trimDelimChars() - trim enclosing delimiter charaters if present.

Parameters:
s - string to trim
delimChar - delimiter character e.g., ' or " etc.
Returns:
original string if no quotes, else new string with quotes removed.

rightSize

public static int[] rightSize(int[] data,
                              int nSize)
rightSize() - right-size the size of the int[] array to nSize

Returns:
right-sized array or original array if it is already the right size

rightSize

public static float[] rightSize(float[] data,
                                int nSize)
rightSize() - right-size the size of the float[] array to nSize

Returns:
right-sized array or original array if it is already the right size

rightSize

public static double[] rightSize(double[] data,
                                 int nSize)
rightSize() - right-size the size of the double[] array to nSize

Returns:
right-sized array or original array if it is already the right size

rightSize

public static char[] rightSize(char[] data,
                               int nSize)
rightSize() - right-size the size of the char[] array to nSize

Returns:
right-sized array or original array if it is already the right size

rightSize

public static java.lang.String[] rightSize(java.lang.String[] data,
                                           int nSize)
rightSize() - right-size the size of the String[] array to nSize

Returns:
right-sized array or original array if it is already the right size

rightSize

public static java.lang.String[] rightSize(java.lang.String[] data)
rightSize() - right-size the size of the String[] array to the size determined by the first null entry.

Returns:
right-sized array or original array if it is already the right size