|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.ObjectO2Plib.misc.Switches
public class Switches
Class Switches parses and manipulates command line switch lists.
This code was derived and refactored from the Open2Dprot Seg2Dgel program.
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/.
| Field Summary | |
|---|---|
static java.lang.String[] |
dbugBitName
Debug bits name from the parsed Open2Dprot.dbug file |
static int[] |
dbugBitValues
Debug bits values from the parsed Open2Dprot.dbug file |
static int |
nSwitches
the number of Command line switches |
static java.lang.String[] |
sw
Command line + Open2Dprot.properties state switches |
| Constructor Summary | |
|---|---|
Switches()
Switches() - Constructor |
|
| Method Summary | |
|---|---|
static java.lang.String[] |
addSwitch(java.lang.String[] swList,
java.lang.String newSW)
addSwitch() - add switch to the sw[]list, by extending the list and then appending the new switch. |
static java.lang.String[] |
changeArgVswitchData(java.lang.String[] argsV,
java.lang.String switchName,
java.lang.String newData,
boolean switchOnFlag)
changeArgVswitchData() change the switch data to the new switch. |
static java.lang.String |
cvtCSDformatCodeToStr(int fmtCode)
cvtCSDformatCodeToStr() - convert CSD.CSD_DBTYPE_xxxx to letter code |
static int |
cvtCSDformatCodeToStr(java.lang.String fmtCodeStr)
cvtCSDformatCodeToStr() - convert letter code to CSD.CSD_DBTYPE_xxxx value |
static java.lang.String |
cvtFormatCodeToStr(int fmtCode)
cvtFormatCodeToStr() -convert IO_FORMAT_xxxx to letter code |
static int |
cvtFormatCodeToStr(java.lang.String fmtCodeStr)
cvtFormatStrToCode() - convert letter code to IO_FORMAT_xxxx value |
static java.lang.String |
cvtSwitchListToStr(java.lang.String[] swList)
cvtSwitchListToStr() - convert switch list to a string <= 60 cols/line. |
static java.lang.String |
getdBugBitsHelpStr()
getdBugBitsHelpStr() - make a help string from the parsed debug bits |
static java.lang.String[] |
getDefaultSwitches(java.lang.String[] argv,
java.lang.String propFile)
getDefaultSwitches() - get the default swtich list from the properties file if any. |
static java.lang.String |
getSwitchOptionsTableStr(java.lang.String msg,
java.lang.String[] swOptData,
boolean[] swOptCBvalue,
java.lang.String[] swOptValue)
getSwitchOptionsTableStr() - get list ALL switch options listing on/off status, name and value if any |
static java.lang.String |
getUsageStr(java.lang.String applicationName,
java.lang.String[] swOptData)
getUsageStr() - get usage message string of command line switches |
static void |
init(int argc)
init() - reset the switches database |
static java.lang.String[] |
mergeSwitches(java.lang.String[] origSW,
java.lang.String[] newSW,
java.lang.String omitSwitch)
mergeSwitches() - merge switches where new switches overide old switches. |
static boolean |
parsedBugBitsFile(java.lang.String dbugBitsFile)
parsedBugBitsFile() - parse the debug bits values from the parsed Open2Dprot.dbug file. |
static boolean |
parsedBugBitsHelpStr(java.lang.String dbugBitsHelpStr)
parsedBugBitsHelpStr() - parse the debug bits values from the parsed debug bits help string. |
static java.lang.String[] |
replaceFileInArgList(java.lang.String[] argList,
java.lang.String newFile)
replaceFileInArgList() - replace the file in the arg list. |
static java.lang.String[] |
replaceSwitchInArgList(java.lang.String[] argList,
java.lang.String newSwitch)
replaceSwitchInArgList() - replace the switch in the arg list. |
static boolean |
rmvSwitch(java.lang.String newSW)
rmvSwitch() - remove switch from the sw[]list by shrinking the list |
static boolean |
savePropertiesFile(java.lang.String propertyFile,
java.lang.String[] swOptData,
java.lang.String[] swOptValue,
boolean[] swOptCBvalue)
savePropertiesFile() - save the switches in propertyFile - typically "{application}.properties". |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static java.lang.String[] sw
public static int nSwitches
public static int[] dbugBitValues
public static java.lang.String[] dbugBitName
| Constructor Detail |
|---|
public Switches()
| Method Detail |
|---|
public static void init(int argc)
argc - is the number of switches to be parsed.
public static java.lang.String[] getDefaultSwitches(java.lang.String[] argv,
java.lang.String propFile)
argv - is the command line arg list that we scan for
"-propertiesFile:newPropFile"propertiesFile - is file to lookup for default switches
public static boolean savePropertiesFile(java.lang.String propertyFile,
java.lang.String[] swOptData,
java.lang.String[] swOptValue,
boolean[] swOptCBvalue)
propertiesFile - - file name to writeswOptData - is list of names of switchesswOptValue - is list of current valuesswOptCBvalue - is list of checkbox switch values (for -no prefix)
public static java.lang.String[] addSwitch(java.lang.String[] swList,
java.lang.String newSW)
newSW - - switch to add
public static boolean rmvSwitch(java.lang.String newSW)
newSW - - switch to remove
public static java.lang.String[] changeArgVswitchData(java.lang.String[] argsV,
java.lang.String switchName,
java.lang.String newData,
boolean switchOnFlag)
switchName - name of switch e.g. "-thrSP"newData - (if not null) for the switch parameters
"-thrSP:1,100"switchOnFlag - status of the switch.
E.g., "-secondaryPairing" or "-nosecondaryPairing"
public static java.lang.String[] replaceFileInArgList(java.lang.String[] argList,
java.lang.String newFile)
argList - is the array to scannewFile - is file to replace the old file name
public static java.lang.String[] replaceSwitchInArgList(java.lang.String[] argList,
java.lang.String newSwitch)
argList - is the array to scannewSwitch - is switch to replace the
public static java.lang.String[] mergeSwitches(java.lang.String[] origSW,
java.lang.String[] newSW,
java.lang.String omitSwitch)
1. Create mergeSW[] that is a copy of newSW[] omitting omitSwitch
if found.
2. For each sw in origSW[] and sw is NOT in mergeSW[],
then add sw to mergeSW[] omitting omitSwitch if found.
3. Make the size of mergeSW[] the exact size.
oldSW - - list of old switchesnewSW - - list of new switchesomitSwitch - is an optional switch to omit if found,
ignore it null (test if -noXXX or -XXX).
public static boolean parsedBugBitsFile(java.lang.String dbugBitsFile)
dbugBitsFile - is debug bits file to parse.
public static boolean parsedBugBitsHelpStr(java.lang.String dbugBitsHelpStr)
dbugBitsHelpStr - is debug bits help string to parse.
public static java.lang.String getdBugBitsHelpStr()
dbugBitName - is list of debug bit namesdbugBitValues - is list of debug bit values
public static java.lang.String getUsageStr(java.lang.String applicationName,
java.lang.String[] swOptData)
applicationName - is the applciation program nameswOptData[0:(2*nData)-1] - is used by the PopupOptions.
It contains pairs of (prompt, helpStr) data. If the prompt
data has a "-", then make a CheckBox (switchOptCBvalue),
else it is a Label with the prompt data. If the user data is
not null, then make a TextField with this user (switchOptValue)
data on the right else make an empty Label.
public static java.lang.String getSwitchOptionsTableStr(java.lang.String msg,
java.lang.String[] swOptData,
boolean[] swOptCBvalue,
java.lang.String[] swOptValue)
msg - optional message to put in front of string if not null.swOptData[0:(3*nData)-1] - is used by the PopupOptions.
It contains pairs of (prompt, helpStr) data. If the prompt
data has a "-", then make a CheckBox (switchOptCBvalue),
else it is a Label with the prompt data. If the user data is
not null, then make a TextField with this user (switchOptValue)
data on the right else make an empty Label.swOptcCBvalue[0:nData-1] - is used by the PopupOptions.
It contains boolean values of switch data use for Checkboxes.swOptValue[0:nData-1] - is used by the PopupOptions.
It contains String values of associated switch data.
public static java.lang.String cvtSwitchListToStr(java.lang.String[] swList)
swList - - list to convert
public static java.lang.String cvtFormatCodeToStr(int fmtCode)
fmtCode - to convert IO_FORMAT_xxxx
public static int cvtFormatCodeToStr(java.lang.String fmtCodeStr)
fmtCodeStr - string code "X", "T", "F", or "G"
public static java.lang.String cvtCSDformatCodeToStr(int fmtCode)
fmtCode - to convert CSD.CSD_DBTYPE_xxxx
public static int cvtCSDformatCodeToStr(java.lang.String fmtCodeStr)
fmtCodeStr - string code "C", "R", or "X". "T" is special case.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||