|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbb.util.CommandLineInterface
public final class CommandLineInterface
Illustrates one way to quickly implement a simple command line interface (CLI).
The CLI supported by this class consists of the following:
System.out
)System.in
).
Valid input is either the number or name of a command, followed by hitting the Enter
key.
What makes this class interesting is that it allows the programmer to add new commands extremely quickly:
all you need to do is write a Java method (see CommandLineInterface.Commands
for details).
This class is multithread safe: it is stateless.
Nested Class Summary | |
---|---|
private static class |
CommandLineInterface.Commands
Whenever you wish to add a command to the CommandLineInterface class, all that you need to do is add it as a method of this class. |
private static class |
CommandLineInterface.StdinReader
|
Constructor Summary | |
---|---|
private |
CommandLineInterface()
This sole private constructor ensures non-instantiability outside of this class. |
Method Summary | |
---|---|
static void |
main(String[] args)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
private CommandLineInterface()
Method Detail |
---|
public static void main(String[] args)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |