|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object jpl.mipl.mdms.FileService.komodo.client.UtilCmdParser
public class UtilCmdParser
Purpose: Parsing utility for the UtilClient command-line arguments.
This class takes an array of Strings and parses according to a set of general
and specific rules.
Some operations utilize options files which specify a set of arguments per
line. To allow iteration through these separate invocations, clients can call
iterations()
,hasNext()
and
advance()
methods.
Copyright 2005, California Institute of Technology. ALL RIGHTS RESERVED. U.S. Government Sponsorship acknowledge. 2005.
============================================================================ Modification History : ---------------------- Date Who What ---------------------------------------------------------------------------- 12/16/2004 Nick Initial Release 05/26/2005 Nick Added push,pull options 09/16/2005 Nick Added push,pull to notify 03/09/2006 Nick Added 'format' to add, checkfiles, get, list, notify, replace, subscribe. 11/10/2006 Nick Added invokeasync option and checks ============================================================================
Field Summary | |
---|---|
protected int |
_actionId
Numeric id representing the action/operation |
protected boolean |
_actionIsAuto
Flag that is true iff actionId is of type notify/subscription |
protected String |
_actionName
String name representing the action/operation |
protected Hashtable |
_actionTable
Table containing mapping from actionId to allowable keywords |
protected String[] |
_args
Reference to the command line argument array |
protected List |
_argumentList
List of arguments from options file. |
protected Hashtable |
_cmdLineArguments
Command line arguments |
protected Hashtable |
_currentArguments
Interval reference to the current argument hash |
protected int |
_currentIndex
|
protected boolean |
_error
Flag indicating error occurred during parsing |
protected Matcher |
_matcher
|
protected String |
_optionsFile
Name of the options file, null if none specified |
protected String[][] |
_optionsFileArgs
Contains argument array for each line entry of options file |
protected Pattern |
_printablePattern
|
protected String |
_printableRegex
|
protected boolean |
_printHelp
Flag indicating whether or not help should be printed |
protected boolean |
_using
Flag indicating usage of options file |
static int |
CODE_MISSING_ARGUMENTS
|
protected static String |
ERR_MSG_MISSING_ARGS
|
protected static String |
ERROR_TAG
|
static String |
KEYWORD_FILES
Keyword used for files lookup |
protected static int |
MAX_FILENAME_LENGTH
|
Constructor Summary | |
---|---|
UtilCmdParser()
Constructor. |
Method Summary | |
---|---|
void |
advance()
Advances to the next argument set. |
protected String[] |
buildArgs(String line)
Method to parse a line read in from the option file to create a tokenized array of strings. |
protected void |
checkAllowableArguments()
|
protected void |
checkConsistency(Hashtable arguments,
boolean fromFile)
This method checks an option set for known conflicting options. |
protected void |
generalParse()
This method performs a general parse of the command line arguments, performs a consistency check, then applies more specific parsing according to the action id. |
Map |
getCurrentArguments()
Returns reference to the current argument map. |
static Date |
getDate(String time,
boolean pm)
Translates from string representation of time to Date object. |
String |
getOptionsFilename()
Returns the filename of the options file if specified at the command line argument set. |
Object |
getValue(String keyword)
Returns value associated with keyword from current argument set. |
boolean |
hasNext()
Returns true iff there are more iterations of operation invocations that have yet to be processed. |
boolean |
hasValue(String keyword)
Returns true if value associated with keyword from current argument set is defined and non-null. |
protected void |
init()
Initializes internal lookup table. |
boolean |
isSet(String keyword)
Returns true if keyword was set in the current argument set. |
int |
iterations()
Returns the number of invocations of the operation. |
protected void |
mergeArguments()
Adds command line arguments to options file arguments, as a way of overriding and supplementing arguments. |
protected void |
parse()
Given a command id and argument array, parses the arguments according to the command throwing Exception if (1) unrecognized argument (2) missing value (3) missing required argument (4) ... |
void |
parse(int actionId,
String[] args)
Performs the parsing of the arguments. |
protected void |
parseAccept()
Parsing for fei5accept fei5accept <filetype> for <add|replace|get|delete> {[output <path>] [crc] [restart] [saferead] [autodelete] [replace|version]} |
protected void |
parseAdd()
Parsing for fei5add fei5add [ <server group>:] <file type> <file name expression>... |
protected boolean |
parseArgs(String[] args,
Hashtable argTable)
Parse the command line arguments. |
protected void |
parseCheck()
Parsing for fei5check fei5check |
protected void |
parseCheckfiles()
Parsing for fei5checkfiles fei5checkfiles [ <server group>:] <file type> ["<file name expression>"] {[before|after <date-time>] | [between <date-time1>and <date-time2>] [long | verylong] [help]} fei5checkfiles using <option file> Option File Format (per line): [ <server group>:] <file type> " <file name expression>" {[before|after <date-time>] | [between <date-time1>and <date-time2>] [long | verylong]} |
protected void |
parseComment()
Parsing for fei5comment fei5comment [ <server group>:] <file type> <file name> comment " <comment text>" [help] |
protected void |
parseCrc()
Parsing for fei5crc fei5crc <file name expression> |
protected void |
parseDelete()
Parsing for fei5delete fei5delete [ <server group>:] <file type> " <file name expression>" [help] fei5delete using <option file> Option File Format (per line): [ <server group>:] <file type> <file name> |
protected void |
parseDisplay()
Parsing for fei5display fei5display [ <server group>:] <file type> <file name> [help] |
protected void |
parseGet()
Parsing for fei5get fei5get [ <server group>:] <file type> [" <file name expression>"] {[output <path>] [before|after <datetime>] | [between <datetime1>and <datetime2>] [crc] [saferead] [receipt] [replace|version] [help]} fei5get using <option file> Option File Format (per line): [ <server group>:] <file type> [" <file name expression>"] {[output <path>] [before|after <date-time>] | [between <date-time1>and <date-time2>] [crc] [saferead] [receipt] [replace|version]} |
protected void |
parseKdestroy()
Parsing for fei5kdestroy fei5kdestroy |
protected void |
parseKinit()
Parsing for fei5kinit fei5kinit |
protected void |
parseKlist()
Parsing for fei5klist fei5klist |
protected void |
parseList()
Parsing for fei5list fei5list [ <server group>:] <file type> [" <file name expression>"] {[before|after <date-time>] | [between <date-time1>and <date-time2>] [long | verylong] [help]} |
protected void |
parseMakeclean()
Parsing for fei5makeclean fei5makeclean [ <server group>:] <file type> "<file name expression>" [help] |
protected void |
parseMakeClean()
|
protected void |
parseNotify()
Parsing for fei5notify fei5notify [ <server group:] <file type> {[output <path>] [restart] [using <option file>]} Option File Format: invoke <command> invokeExitOnError invokeAsync logFile <file name> mailMessageFrom <email address> mailMessageTo <email address, email address, ...> mailReportAt <hh:mm am|pm, hh:mm am|pm, ...> mailReportTo <email address, email address, ...> mailSMTPHost <host name> |
protected void |
parseOptionsFile(String optionsFilename)
Parses entries from an options file and populates the fileArguments list. |
protected void |
parseReference()
Parsing for fei5reference fei5reference [ <server group>:] <file type> <file name> vft <VFT name> reference <ref name> [help] |
protected void |
parseRegister()
Parsing for fei5register: fei5register [ <server group>:] <file type> <file name expression>... |
protected void |
parseRename()
Parsing for fei5rename fei5rename [ <server group>:] <file type> <old file name> <new file name> [help] fei5rename using <option file> Option File Format (per line): [ <server group>:] <file type> <old file name> <new file name> |
protected void |
parseReplace()
Parsing for fei5replace fei5replace [ <server group>:] <file type> <file name expression>... |
protected void |
parseShowtypes()
Parsing for fei5showtypes |
protected void |
parseSpecific()
Wrapper method that dispatches specific parse checking based on action id. |
protected void |
parseSubscribe()
Parsing for fei5subscribe fei5subscribe [ <server group:] <file type> {[output <path>] [restart] [using <option file>]} Option File Format: crc invoke <command>invokeExitOnError logFile <file name> mailMessageFrom <email address> mailMessageTo <email address, email address, ...> mailReportAt <hh:mm am|pm, hh:mm am|pm, ...> mailReportTo <email address, email address, ...> mailSMTPHost <host name> receipt replace saferead version |
static Date[] |
parseTimeList(String timelist)
Returns an array of Date objects created from the timelist parameter. |
protected void |
parseUnregister()
Parsing for fei5unregister: fei5unregister [ <server group>:] <file type> " <file name expression>" [help] fei5unregister using <option file> Option File Format (per line): [ <server group>:] <file type> <file name> |
boolean |
printHelp()
Returns true iff help should be printed for the operation, either if help keyword was found or parse error occurred. |
void |
reset()
Resets to beginning of arguments list. |
protected int |
setError(int lineNumber)
Helper method that sets the error flag and returns parameter value back. |
protected boolean |
shouldPrintHelp()
Protected method that determines if help should be printed based on a set of known-criteria such as error conditions. |
String |
toString()
Override of toString method. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String KEYWORD_FILES
protected static final String ERROR_TAG
protected static final String ERR_MSG_MISSING_ARGS
public static final int CODE_MISSING_ARGUMENTS
protected static final int MAX_FILENAME_LENGTH
protected Hashtable _cmdLineArguments
protected List _argumentList
protected String _actionName
protected int _actionId
protected String[] _args
protected Hashtable _actionTable
protected boolean _actionIsAuto
protected Hashtable _currentArguments
protected int _currentIndex
protected boolean _using
protected String _optionsFile
protected boolean _printHelp
protected boolean _error
protected String[][] _optionsFileArgs
protected final String _printableRegex
protected Pattern _printablePattern
protected Matcher _matcher
Constructor Detail |
---|
public UtilCmdParser()
Method Detail |
---|
protected void init()
public void parse(int actionId, String[] args) throws ParseException
actionId
- Numeric id associated with the operation to be performed.args[]
- String array of arguments
ParseException
- if parsing cannot complete successfullyprotected void parse() throws ParseException
ParseException
- if error occurs druring parsingpublic boolean isSet(String keyword)
hasValue()
to check value of keyword.
keyword
- Keyword of the value to be checked
public boolean hasValue(String keyword)
keyword
- Keyword of the value to be checked
public Object getValue(String keyword)
keyword
- Keyword of the value to be returned
public boolean hasNext()
public void advance()
public void reset()
public Map getCurrentArguments()
public int iterations()
public String getOptionsFilename()
public boolean printHelp()
protected void checkConsistency(Hashtable arguments, boolean fromFile) throws ParseException
args
- Current hashtable of arguments being checked
ParseException
protected void generalParse() throws ParseException
ParseException
protected void checkAllowableArguments() throws ParseException
ParseException
protected void mergeArguments()
protected boolean shouldPrintHelp()
protected void parseSpecific() throws ParseException
ParseException
protected void parseAccept() throws ParseException
ParseException
protected void parseAdd() throws ParseException
ParseException
protected void parseCheck() throws ParseException
ParseException
protected void parseCheckfiles() throws ParseException
ParseException
protected void parseComment() throws ParseException
ParseException
protected void parseCrc() throws ParseException
ParseException
protected void parseDelete() throws ParseException
ParseException
protected void parseMakeClean() throws ParseException
ParseException
protected void parseDisplay() throws ParseException
ParseException
protected void parseGet() throws ParseException
ParseException
protected void parseKdestroy() throws ParseException
ParseException
protected void parseKinit() throws ParseException
ParseException
protected void parseKlist() throws ParseException
ParseException
protected void parseList() throws ParseException
ParseException
protected void parseMakeclean() throws ParseException
ParseException
protected void parseReference() throws ParseException
ParseException
protected void parseRegister() throws ParseException
ParseException
protected void parseUnregister() throws ParseException
ParseException
protected void parseRename() throws ParseException
ParseException
protected void parseReplace() throws ParseException
ParseException
protected void parseShowtypes() throws ParseException
ParseException
protected void parseNotify() throws ParseException
ParseException
protected void parseSubscribe() throws ParseException
ParseException
protected boolean parseArgs(String[] args, Hashtable argTable) throws ParseException
args
- The command line argumentsargTable
- the argument lookup hashtable
ParseException
- when parsing failsprotected void parseOptionsFile(String optionsFilename) throws ParseException
optionsFilename
- Path of the options file to be parsed
ParseException
- if a parse-related error occursprotected String[] buildArgs(String line) throws ParseException
line
- the input line string
ParseException
- when invalid syntax is encounteredpublic static Date getDate(String time, boolean pm)
time
- Time as string, format hh:mmpm
- flag indicating time is in PM
public static Date[] parseTimeList(String timelist)
timelist
- String of date list delimited by comma (,), where each
entry is of the form 'hh:mm [ap]m'
public String toString()
toString
in class Object
protected int setError(int lineNumber)
lineNumber
- Line number associated with error
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |