|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgov.sandia.ccaffeine.cmd.CmdParse
public class CmdParse
The Cmd classes implement a simple Vector driven parser for command line applications. by Ben Allan, Sandia National Laboratories, May 1999. This code is based on the ASCEND IV command-line interpreter by Tom Epperly. It should be released to the public domain (or preferably the GNU License domain) as soon as possible. CmdContext is an abstract class for application specific data that will be defined in more detail by the application programmer. CmdAction is an interface class used in defining individual command objects. An interpreter is a collection of such objects sharing a common assumption about the subclass of CmdContext they are called in. CmdParse defines the interpreter which provides argument marshaling and checking services, supports command abbreviations, and provides help functionality. The overall scheme is that the application defines a bunch of CmdAction objects and hands them to the interpreter. This is not a highly intelligent scheme. It does keep a "hand-coded" interactive command-line manageable as each major command gets a separate class and implementation, and the control loop logic is abstracted. Unlike lex/yacc, it scales easily to multiple developers.
Constructor Summary | |
---|---|
CmdParse(CmdContext icc)
Actions in the constructed parser will be called with icc as their context. |
Method Summary | |
---|---|
void |
addAction(CmdAction c)
Adds a command to the parser. |
CmdAction |
getAction(java.lang.String s)
Returns the nearest match (by leading characters) of commands stored in the list. |
void |
parse(BuilderClientMonitor monitor)
Main command-line processing loop. |
void |
parse(java.lang.String read)
Parse one line of text. |
void |
setContextVerbose(boolean noisyHelp)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CmdParse(CmdContext icc)
Method Detail |
---|
public void addAction(CmdAction c)
public CmdAction getAction(java.lang.String s)
public void setContextVerbose(boolean noisyHelp)
public void parse(BuilderClientMonitor monitor) throws java.io.IOException
java.io.IOException
public void parse(java.lang.String read) throws EndOfFileException, java.io.IOException
read
- one line of text that is to be parsed.
EndOfFileException
- Thrown when we enounter
the end-of-file.
java.io.IOException
- Thrown if an io error occurs.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |