Package edu.caltech.nanodb.commands
Class DropTableCommand
- java.lang.Object
-
- edu.caltech.nanodb.commands.Command
-
- edu.caltech.nanodb.commands.DropTableCommand
-
public class DropTableCommand extends Command
This Command class represents the DROP TABLE SQL command.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class edu.caltech.nanodb.commands.Command
Command.Type
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
ifExists
This flag controls whether the drop-table command will fail if the table already doesn't exist when the removal is attempted.private static org.apache.logging.log4j.Logger
logger
A logging object for reporting anything interesting that happens.private java.lang.String
tableName
The name of the table to drop from the database.
-
Constructor Summary
Constructors Constructor Description DropTableCommand(java.lang.String tableName, boolean ifExists)
Construct a drop-table command for the named table.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
execute(NanoDBServer server)
This method executes the DROP TABLE command by calling theTableManager.dropTable(java.lang.String)
method with the specified table name.boolean
getIfExists()
Returns the value of the "if exists" flag; true indicates that it is not an error if the table doesn't exist when this command is issued.java.lang.String
getTableName()
Get the name of the table to be dropped.java.lang.String
toString()
-
Methods inherited from class edu.caltech.nanodb.commands.Command
getCommandType
-
-
-
-
Field Detail
-
logger
private static org.apache.logging.log4j.Logger logger
A logging object for reporting anything interesting that happens.
-
tableName
private java.lang.String tableName
The name of the table to drop from the database.
-
ifExists
private boolean ifExists
This flag controls whether the drop-table command will fail if the table already doesn't exist when the removal is attempted.
-
-
Constructor Detail
-
DropTableCommand
public DropTableCommand(java.lang.String tableName, boolean ifExists)
Construct a drop-table command for the named table.- Parameters:
tableName
- the name of the table to drop.ifExists
- a flag controlling whether the command should complain if the table already doesn't exist when the removal is attempted.
-
-
Method Detail
-
getTableName
public java.lang.String getTableName()
Get the name of the table to be dropped.- Returns:
- the name of the table to drop
-
getIfExists
public boolean getIfExists()
Returns the value of the "if exists" flag; true indicates that it is not an error if the table doesn't exist when this command is issued.- Returns:
- the value of the "if exists" flag
-
execute
public void execute(NanoDBServer server) throws ExecutionException
This method executes the DROP TABLE command by calling theTableManager.dropTable(java.lang.String)
method with the specified table name.- Specified by:
execute
in classCommand
- Throws:
ExecutionException
- if the table doesn't actually exist, or if the table cannot be deleted for some reason.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-