|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||
java.lang.Object | +--CommandLine
This class can be used by any object (that implements CommandLineable) to
be manipulated by a command line interface. Here's a snippet:
The CommandLine will parse commands in its own thread, sending a
CommandLineable client = new YourObject();
CommandLine cl = new CommandLine(client);
cl.prompt(); // bootstraps the process
doCommand() message when anything interesting happens.
If doCommand() returns a null, then the CommandLine ceases.
Otherwise, the return from doCommand() (a String) is displayed
and the command line waits for a new command.
Run java com.fooware.util.CommandLine for a taste.
| Inner Class Summary | |
private class |
CommandLine.PromptThread
|
| Field Summary | |
private CommandLineable |
m_client
The client who is receiving the command from this command line. |
private java.io.BufferedReader |
m_in
The input stream from which to get commands. |
private java.io.PrintWriter |
m_out
The output stream to which to send messages and prompts. |
private java.lang.String |
m_prompt
The prompt to be displayed at the command line. |
private java.lang.String |
promptString
|
| Constructor Summary | |
CommandLine(CommandLineable client)
Create a new CommandLine for the client. |
|
| Method Summary | |
java.lang.String |
getPromptString()
Get the prompt displayed at the command line. |
void |
prompt(java.lang.String message)
The message will be sent to the current output stream. |
void |
setInputStream(java.io.InputStream istr)
Set the input stream. |
void |
setOutputStream(java.io.OutputStream ostr)
Set the output stream. |
void |
setPromptString(java.lang.String prompt)
Set the prompt to be displayed at the command line. |
void |
start()
|
| Methods inherited from class java.lang.Object |
|
| Field Detail |
private CommandLineable m_client
private java.lang.String m_prompt
private java.io.BufferedReader m_in
private java.io.PrintWriter m_out
private java.lang.String promptString
| Constructor Detail |
public CommandLine(CommandLineable client)
| Method Detail |
public void setPromptString(java.lang.String prompt)
public java.lang.String getPromptString()
public void prompt(java.lang.String message)
throws java.io.IOException
doCommand() message.fesco.util.CommandLineablepublic void start()
public void setInputStream(java.io.InputStream istr)
System.in. This is
the input stream from which commands are received.public void setOutputStream(java.io.OutputStream ostr)
System.out. This
is the output stream to which command output is written.
|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||