Class Switches

java.lang.Object
  extended by Switches

public class Switches
extends java.lang.Object

File Switches class used to parse the switches from the command line args passed as argsV[]. The parsed switches are stored in the Globals variables through the main class HTMLtools cvt instance. Until we [REFACTOR] the JTV (Java TreeView) converter to a separate application, the variables reside here.

 List of Methods
 parseSwitches() - parse the command line args and set Global variables.
 getCleanArgList() - Remove # prefaced and "" lines and resize argsV.
 parseGBSswitches() - parse curSW switch to see if it is a GBS option.
 parseTIswitches() - parse curSW switch to see if it is a TI option
 parseJTVswitches() - parse JTV command line args and set Global variables.
 createHeaderNameMapTable() - create header name map table and lists, flags.
 

This code is available at the HTMLtools project on SourceForge at http://htmltools.sourceforge.org/ under the "Common Public License Version 1.0" http://www.opensource.org/licenses/cpl1.0.php.

It was derived and refactored from the open source MAExplorer (http://maexplorer.sourceforge.org/), and Open2Dprot (http://Open2Dprot.sourceforge.net/) Table modules.

$Date: 2009/11/14 11:45:56 $ $Revision: 1.36 $
Copyright 2008, 2009 by Peter Lemkin E-Mail: lemkin@users.sourceforge.net http://lemkingroup.com/


Field Summary
 HTMLtools cvt
           
 FileTable fio
          Global fileTable instance
 
Constructor Summary
Switches(HTMLtools cvt)
          Switches() - Constructor.
 
Method Summary
private  boolean createHeaderNameMapTable(java.lang.String mapNameFile, int fromHdrNbr, int toHdrNbr)
          createHeaderNameMapTable() - create header name map table and lists, flags.
private  boolean createHeaderNameMapTable(java.lang.String mapNameFile, java.lang.String fromHdrName, java.lang.String toHdrName)
          createHeaderNameMapTable() - create header name map table and lists, flags.
private  boolean createHeaderNameMapTable(java.lang.String mapNameFile, java.lang.String fromHdrName, java.lang.String toHdrName, int fromHdrNbr, int toHdrNbr, boolean useL2Sflag)
          createHeaderNameMapTable() - create header name map table and lists, flags.
 java.lang.String[] getCleanArgList(java.lang.String[] argsV)
          getCleanArgList() - Remove # prefaced comments and "" lines and make argsV the exact size.
private  int parseGBSswitches(java.lang.String curSW)
          parseGBSswitches() - parse curSW switch to see if it is a GBS option where GSB is GenBatchScripts.
private  int parseJTVswitches(java.lang.String curSW)
          parseJTVswitches() - parse curSW switch to see if it is a JTV option.
 boolean parseSwitches(java.lang.String[] argsV)
          parseSwitches() - parse the arg list and set global switches and variables.
private  int parseTIswitches(java.lang.String curSW)
          parseTIswitches() - parse curSW switch to see if it is a TI option where TI is Tests-Intersections command.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cvt

public HTMLtools cvt

fio

public FileTable fio
Global fileTable instance

Constructor Detail

Switches

public Switches(HTMLtools cvt)
Switches() - Constructor. Note: should only be called after set up fio in cvt.

Method Detail

parseSwitches

public boolean parseSwitches(java.lang.String[] argsV)
parseSwitches() - parse the arg list and set global switches and variables. Note some of the switches may have multiple instances including: -files, -hrefData, -hrefHeaderRow -dropColumn, -keepColumn, -reorderColumn, -sortTableByColumn, -mapQuestionmarks. You only need to enter the minimum part of the switch described in the HelpMsgs#COMMAND_MSG documentation. See documentation in HelpMsgs.java for details. Note: the switches are case sensitive.

Parameters:
argsV - is list of command line switches
Returns:
true if succeed, false if fail or just need to go on to the next param set to process
See Also:
FileIO.readFileAsString(java.lang.String), UtilCM.cvs2Array(java.lang.String, java.lang.String), UtilCM.cvs2i(java.lang.String), UtilCM.cvs2f(java.lang.String), UtilCM.setLogMsgs(boolean), UtilCM.getLogMsgs(), UtilCM#logMsgs, FileTable#readFileAsTable, FileTable.setHasTableHeaderFlag(boolean), FileTable.setRmvTrailingBlankLinesFlag(boolean), FileTable.setRmvTrailingEmptyColumnsFlag(boolean)

getCleanArgList

public java.lang.String[] getCleanArgList(java.lang.String[] argsV)
getCleanArgList() - Remove # prefaced comments and "" lines and make argsV the exact size.

Parameters:
argsV - - the command line or batch arg list
Returns:
cleanArgsV[] if succeed, else null.

parseGBSswitches

private int parseGBSswitches(java.lang.String curSW)
parseGBSswitches() - parse curSW switch to see if it is a GBS option where GSB is GenBatchScripts. [REFACTOR] to separate GenBatchScripts program.

Parameters:
curSW - - switch to parse for GBS options.
Returns:
-1 if no switches found, 0 if bad parse, 1 if parsed ok.

parseTIswitches

private int parseTIswitches(java.lang.String curSW)
parseTIswitches() - parse curSW switch to see if it is a TI option where TI is Tests-Intersections command. [REFACTOR] to separate GenBatchScripts program.

Parameters:
curSW - - switch to parse for GBS options.
Returns:
-1 if no switches found, 0 if bad parse, 1 if parsed ok.

parseJTVswitches

private int parseJTVswitches(java.lang.String curSW)
parseJTVswitches() - parse curSW switch to see if it is a JTV option. [REFACTOR] to separate JTVconverter program.

Parameters:
curSW - - switch to parse for JTV options.
Returns:
-1 if no switches found, 0 if bad parse, 1 if parsed ok.

createHeaderNameMapTable

private boolean createHeaderNameMapTable(java.lang.String mapNameFile,
                                         int fromHdrNbr,
                                         int toHdrNbr)
createHeaderNameMapTable() - create header name map table and lists, flags. This reads the mapNameFile Table into cvt.ftL2S. It must contain the fromHdrName and toHdrName fields. It then creates cvt.fromLongHdrNamesMap[cvt.nLong2ShortHdrNamesMap] and cvt.toShortHdrNamesMap[cvt.nLong2ShortHdrNamesMap] lists that can be used for mapping during file conversion.

Parameters:
mapNameFile - is mapping table containing required fields
fromHdrNbr - contains the 'from' header column
toHdrNbr - contains the 'to' header column
Returns:
true if succeed and setup the above arrays and also set the cvt.mapLongToShortHdrNamesFlag.

createHeaderNameMapTable

private boolean createHeaderNameMapTable(java.lang.String mapNameFile,
                                         java.lang.String fromHdrName,
                                         java.lang.String toHdrName)
createHeaderNameMapTable() - create header name map table and lists, flags. This reads the mapNameFile Table into cvt.ftL2S. It must contain the fromHdrName and toHdrName fields. It then creates cvt.fromLongHdrNamesMap[cvt.nLong2ShortHdrNamesMap] and cvt.toShortHdrNamesMap[cvt.nLong2ShortHdrNamesMap] lists that can be used for mapping during file conversion.

Parameters:
mapNameFile - is mapping table containing required fields
fromHdrName - contains the 'from' header column name
toHdrName - contains the 'to' header column name
Returns:
true if succeed and setup the above arrays and also set the cvt.mapLongToShortHdrNamesFlag.

createHeaderNameMapTable

private boolean createHeaderNameMapTable(java.lang.String mapNameFile,
                                         java.lang.String fromHdrName,
                                         java.lang.String toHdrName,
                                         int fromHdrNbr,
                                         int toHdrNbr,
                                         boolean useL2Sflag)
createHeaderNameMapTable() - create header name map table and lists, flags. This reads the mapNameFile Table into cvt.ftL2S. It must contain the fromHdrName and toHdrName fields. It then creates cvt.fromLongHdrNamesMap[cvt.nLong2ShortHdrNamesMap] and cvt.toShortHdrNamesMap[cvt.nLong2ShortHdrNamesMap] lists that can be used for mapping during file conversion.

Parameters:
mapNameFile - is mapping table relative file containing mapping fields
fromHdrName - contains from name header
toHdrName - contains the to name header
fromHdrNbr - contains the 'from' header column if useL2Sflag
toHdrNbr - contains the 'to' header column useL2Sflag
useL2Sflag - - set to true if default fromHdrName as column 1.
Returns:
true if succeed and setup the above arrays and also set the cvt.mapLongToShortHdrNamesFlag.