Class CommandParser
java.lang.Object
java.lang.Thread
edu.uky.cs.nil.tt.CommandParser
- All Implemented Interfaces:
Runnable
A command parser listens (on
standard input) for and
executes simple text commands, like modifying the server's database and
shutting the server down.- Author:
- Stephen G. Ware
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA command is a type of operation that can be parsed by acommand parserand executed on a server.static interfaceAn operation represents a single command that can be executed on a server based on a series of arguments that define how it behaves.Nested classes/interfaces inherited from class Thread
Thread.Builder, Thread.State, Thread.UncaughtExceptionHandler -
Field Summary
Fields inherited from class Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(CommandParser.Command command) Adds a new command to the list of command this parser can recognize.Returns a list of all of the command this parser can recognize.getUsage()Returns a documentation string showing how to use the commands this parser can recognize.voidAttempts to parse and execute a command from a string, typically one typed intostandard input.voidrun()Methods inherited from class Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, isVirtual, join, join, join, join, ofPlatform, ofVirtual, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, sleep, start, startVirtualThread, stop, suspend, threadId, toString, yield
-
Constructor Details
-
CommandParser
Constructs a new command parser for a server.- Parameters:
server- the server on which commands will be executed
-
-
Method Details
-
run
-
getCommands
Returns a list of all of the command this parser can recognize.- Returns:
- a list of commands this parser can recognize
-
getUsage
Returns a documentation string showing how to use the commands this parser can recognize.- Returns:
- a documentation string
-
add
Adds a new command to the list of command this parser can recognize.- Parameters:
command- the new command that will be recognized
-
parse
Attempts to parse and execute a command from a string, typically one typed intostandard input.- Parameters:
command- the string to attempt to parse as a command- Throws:
Exception- if the command cannot be parsed or if a problem occurs when executing the command
-