Package edu.caltech.nanodb.commands
Class Command
- java.lang.Object
-
- edu.caltech.nanodb.commands.Command
-
- Direct Known Subclasses:
AnalyzeCommand
,BeginTransactionCommand
,CommitTransactionCommand
,CrashCommand
,CreateIndexCommand
,CreateTableCommand
,CreateViewCommand
,DropIndexCommand
,DropTableCommand
,DumpCommand
,ExitCommand
,ExplainCommand
,FlushCommand
,OptimizeCommand
,QueryCommand
,RollbackTransactionCommand
,SetPropertyCommand
,ShowPropertiesCommand
,ShowSystemStatsCommand
,ShowTablesCommand
,ShowTableStatsCommand
,VerifyCommand
public abstract class Command extends java.lang.Object
Abstract base-class for all commands that NanoDB supports. Command classes contain both the arguments and configuration details for the command being executed, as well as the code for actually performing the command. Databases tend to have large switch statements controlling how various commands are handled, and this really isn't a very pretty way to do things. So, NanoDB uses a class-hierarchy for command representation and execution.The command class is subclassed into various command categories that relate to various operations in the database. For example, the
QueryCommand
class represents all SELECT, INSERT, UPDATE, and DELETE operations.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Command.Type
Commands are either Data-Definition Language (DDL), Data-Manipulation Language (DML), or utility commands.
-
Field Summary
Fields Modifier and Type Field Description private Command.Type
cmdType
The type of this command.protected java.io.PrintStream
out
This is the output stream for the current session, so that command output goes to the appropriate client.
-
Constructor Summary
Constructors Modifier Constructor Description protected
Command(Command.Type cmdType)
Create a new command instance, of the specified command-type.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract void
execute(NanoDBServer server)
Actually performs the command.Command.Type
getCommandType()
Returns the general type or category of this command.
-
-
-
Field Detail
-
cmdType
private Command.Type cmdType
The type of this command.
-
out
protected java.io.PrintStream out
This is the output stream for the current session, so that command output goes to the appropriate client.
-
-
Constructor Detail
-
Command
protected Command(Command.Type cmdType)
Create a new command instance, of the specified command-type. The constructor is protected, but that is redundant with the fact that the class is abstract anyways, so this class cannot be constructed directly.- Parameters:
cmdType
- the general category of command
-
-
Method Detail
-
getCommandType
public Command.Type getCommandType()
Returns the general type or category of this command.
-
execute
public abstract void execute(NanoDBServer server) throws ExecutionException
Actually performs the command.- Throws:
ExecutionException
- if an issue occurs during command execution
-
-