00001
00025
package org.objectweb.cjdbc.common.sql;
00026
00027
import java.io.Serializable;
00028
import java.sql.SQLException;
00029
00030
import org.objectweb.cjdbc.common.sql.schema.DatabaseSchema;
00031
import org.objectweb.cjdbc.common.sql.schema.DatabaseTable;
00032
00044 public class DropRequest extends AbstractWriteRequest implements Serializable
00045 {
00046
00065 public DropRequest(String sqlQuery,
boolean escapeProcessing,
int timeout,
00066 String lineSeparator,
DatabaseSchema schema,
int granularity,
00067
boolean isCaseSensitive)
throws SQLException
00068 {
00069
this(sqlQuery, escapeProcessing, timeout, lineSeparator);
00070
parse(schema, granularity, isCaseSensitive);
00071 }
00072
00088 public DropRequest(String sqlQuery,
boolean escapeProcessing,
int timeout,
00089 String lineSeparator)
00090 {
00091 super(sqlQuery, escapeProcessing, timeout, lineSeparator);
00092 cacheable =
RequestType.UNCACHEABLE;
00093 isParsed =
false;
00094 }
00095
00100 public void parse(
DatabaseSchema schema,
int granularity,
00101
boolean isCaseSensitive)
throws SQLException
00102 {
00103
if (granularity ==
ParsingGranularities.NO_PARSING)
00104 {
00105 isParsed =
true;
00106
return;
00107 }
00108
00109 String originalSQL =
this.trimCarriageReturn();
00110 String dropTable = originalSQL.toLowerCase();
00111
00112
00113
int tableIdx = dropTable.indexOf(
"table");
00114
if (isCaseSensitive)
00115 dropTable = originalSQL.substring(tableIdx + 5).trim();
00116
else
00117 dropTable = dropTable.substring(tableIdx + 5).trim();
00118
00119
if (schema == null)
00120 tableName = dropTable;
00121
else
00122 {
00123
00124
DatabaseTable t = schema.getTable(dropTable, isCaseSensitive);
00125
if (t == null)
00126
throw new SQLException(
"Unknown table '" + dropTable
00127 +
"' in this DROP statement '" + sqlQuery +
"'");
00128
else
00129 tableName = t.
getName();
00130 }
00131 isParsed =
true;
00132 }
00133
00137 public void cloneParsing(
AbstractRequest request)
00138 {
00139
if (!request.
isParsed())
00140
return;
00141
cloneTableNameAndColumns((
AbstractWriteRequest) request);
00142 isParsed =
true;
00143 }
00144
00149 public boolean isInsert()
00150 {
00151
return false;
00152 }
00153
00158 public boolean isUpdate()
00159 {
00160
return false;
00161 }
00162
00167 public boolean isDelete()
00168 {
00169
return false;
00170 }
00171
00176 public boolean isCreate()
00177 {
00178
return false;
00179 }
00180
00185 public boolean isDrop()
00186 {
00187
return true;
00188 }
00189
00193 public void debug()
00194 {
00195 super.debug();
00196
if (tableName != null)
00197 System.out.println(
"Dropped table '" + tableName +
"'");
00198
else
00199 System.out.println(
"No information about dropped table");
00200
00201 System.out.println();
00202 }
00206 public boolean isAlter()
00207 {
00208
return false;
00209 }
00210 }