クラス org.objectweb.cjdbc.common.sql.DeleteRequest

org.objectweb.cjdbc.common.sql.DeleteRequestに対する継承グラフ

Inheritance graph
[凡例]
org.objectweb.cjdbc.common.sql.DeleteRequestのコラボレーション図

Collaboration graph
[凡例]
すべてのメンバ一覧

説明

An DeleteRequest is an SQL request with the following syntax:

DELETE [table1,table2,...] FROM table1,table2,table3,... WHERE search-condition
 

作者:
Emmanuel Cecchet

Julie Marguerite

Mathieu Peltier

Sara Bouchenak

バージョン:
1.0

DeleteRequest.java50 行で定義されています。

Public メソッド

 DeleteRequest (String sqlQuery, boolean escapeProcessing, int timeout, String lineSeparator, DatabaseSchema schema, int granularity, boolean isCaseSensitive) throws SQLException
 DeleteRequest (String sqlQuery, boolean escapeProcessing, int timeout, String lineSeparator)
void parse (DatabaseSchema schema, int granularity, boolean isCaseSensitive) throws SQLException
void cloneParsing (AbstractRequest request)
ArrayList getValues ()
boolean isUnique ()
boolean isInsert ()
boolean isUpdate ()
boolean isDelete ()
boolean isCreate ()
boolean isDrop ()
void debug ()
boolean isAlter ()

Protected 変数

ArrayList whereValues

Private メソッド

ArrayList getFromTables (String fromClause, DatabaseSchema dbs) throws SQLException
ArrayList getWhereColumns (String whereClause, ArrayList aliasedFrom)

Private 変数

transient boolean isUnique
transient ArrayList from


コンストラクタとデストラクタ

org.objectweb.cjdbc.common.sql.DeleteRequest.DeleteRequest String  sqlQuery,
boolean  escapeProcessing,
int  timeout,
String  lineSeparator,
DatabaseSchema  schema,
int  granularity,
boolean  isCaseSensitive
throws SQLException
 

Creates a new DeleteRequest instance. The caller must give an SQL request, without any leading or trailing spaces and beginning with 'delete from ' (it will not be checked).

If the syntax is incorrect an exception is thrown.

引数:
sqlQuery the SQL request
escapeProcessing should the driver to escape processing before sending to the database ?
timeout an int value
lineSeparator the line separator used in the query
schema a DatabaseSchema value
granularity parsing granularity as defined in ParsingGranularities
isCaseSensitive true if parsing is case sensitive
例外:
SQLException if an error occurs
DeleteRequest.java91 行で定義されています。

参照先 org.objectweb.cjdbc.common.sql.DeleteRequest.parse().

00094 { 00095 this(sqlQuery, escapeProcessing, timeout, lineSeparator); 00096 parse(schema, granularity, isCaseSensitive); 00097 }

org.objectweb.cjdbc.common.sql.DeleteRequest.DeleteRequest String  sqlQuery,
boolean  escapeProcessing,
int  timeout,
String  lineSeparator
 

Creates a new DeleteRequest instance. The caller must give an SQL request, without any leading or trailing spaces and beginning with 'create table ' (it will not be checked).

The request is not parsed but it can be done later by a call to parse(DatabaseSchema, int, boolean).

引数:
sqlQuery the SQL request
escapeProcessing should the driver to escape processing before sending to the database ?
timeout an int value
lineSeparator the line separator used in the query
参照:
parse
DeleteRequest.java114 行で定義されています。

参照先 org.objectweb.cjdbc.common.sql.DeleteRequest.isUnique.

00116 { 00117 super(sqlQuery, escapeProcessing, timeout, lineSeparator); 00118 cacheable = RequestType.UNCACHEABLE; 00119 isParsed = false; 00120 isUnique = false; 00121 }


メソッド

void org.objectweb.cjdbc.common.sql.DeleteRequest.cloneParsing AbstractRequest  request  )  [virtual]
 

参照:
AbstractRequest.cloneParsing(AbstractRequest)

org.objectweb.cjdbc.common.sql.AbstractRequestを実装しています.

DeleteRequest.java248 行で定義されています。

参照先 org.objectweb.cjdbc.common.sql.AbstractWriteRequest.cloneTableNameAndColumns(), と org.objectweb.cjdbc.common.sql.AbstractRequest.isParsed.

00249 { 00250 if (!request.isParsed()) 00251 return; 00252 cloneTableNameAndColumns((AbstractWriteRequest) request); 00253 isParsed = true; 00254 }

void org.objectweb.cjdbc.common.sql.DeleteRequest.debug  ) 
 

Displays some debugging information about this request.

org.objectweb.cjdbc.common.sql.AbstractRequestを再定義しています。

DeleteRequest.java420 行で定義されています。

参照先 org.objectweb.cjdbc.common.sql.DeleteRequest.isUnique.

00421 { 00422 super.debug(); 00423 System.out.println("Is unique: " + isUnique); 00424 if (tableName != null) 00425 System.out.println("Deleted table: " + tableName); 00426 else 00427 System.out.println("No information about deleted table"); 00428 00429 if (columns != null) 00430 { 00431 System.out.println("Columns columns:"); 00432 for (int i = 0; i < columns.size(); i++) 00433 System.out.println(" " 00434 + ((TableColumn) columns.get(i)).getColumnName()); 00435 } 00436 else 00437 System.out.println("No information about updated columns"); 00438 00439 System.out.println(); 00440 }

ArrayList org.objectweb.cjdbc.common.sql.DeleteRequest.getFromTables String  fromClause,
DatabaseSchema  dbs
throws SQLException [private]
 

Extracts the tables from the given FROM clause and retrieves their alias if any.

引数:
fromClause the FROM clause of the request (without the FROM keyword)
dbs the DatabaseSchema this request refers to
戻り値:
an ArrayList of AliasedDatabaseTable objects
例外:
an SQLException if an error occurs
DeleteRequest.java267 行で定義されています。

参照元 org.objectweb.cjdbc.common.sql.DeleteRequest.parse().

00269 { 00270 StringTokenizer tables = new StringTokenizer(fromClause, ","); 00271 ArrayList result = new ArrayList(tables.countTokens()); 00272 while (tables.hasMoreTokens()) 00273 { 00274 String tableName = tables.nextToken().trim(); 00275 // Check if the table has an alias 00276 // Example: SELECT x.price FROM item x 00277 String alias = null; 00278 int aliasIdx = tableName.indexOf(' '); 00279 if (aliasIdx != -1) 00280 { 00281 alias = tableName.substring(aliasIdx); 00282 tableName = tableName.substring(0, aliasIdx); 00283 } 00284 00285 DatabaseTable table = dbs.getTable(tableName); 00286 if (table == null) 00287 throw new SQLException("Unknown table '" + tableName 00288 + "' in FROM clause of this DELETE statement: '" + sqlQuery + "'"); 00289 result.add(new AliasedDatabaseTable(table, alias)); 00290 } 00291 00292 return result; 00293 }

ArrayList org.objectweb.cjdbc.common.sql.DeleteRequest.getValues  ) 
 

Returns an ArrayList of String objects representing the values associated with the unique columns involved in this request.

戻り値:
an ArrayList value
DeleteRequest.java357 行で定義されています。

参照先 org.objectweb.cjdbc.common.sql.DeleteRequest.whereValues.

00358 { 00359 return whereValues; 00360 }

ArrayList org.objectweb.cjdbc.common.sql.DeleteRequest.getWhereColumns String  whereClause,
ArrayList  aliasedFrom
[private]
 

Gets all the columns involved in the given WHERE clause.

The selected columns or tables must be found in the given ArrayList of AliasedDatabaseTable representing the FROM clause of the same request.

引数:
whereClause WHERE clause of the request (without the WHERE keyword)
aliasedFrom an ArrayList of AliasedDatabaseTable
戻り値:
an ArrayList of TableColumn
DeleteRequest.java308 行で定義されています。

参照先 org.objectweb.cjdbc.common.sql.schema.DatabaseTable.getColumns(), org.objectweb.cjdbc.common.sql.schema.DatabaseTable.getName(), org.objectweb.cjdbc.common.sql.schema.DatabaseColumn.getName(), と org.objectweb.cjdbc.common.sql.schema.DatabaseColumn.isUnique.

参照元 org.objectweb.cjdbc.common.sql.DeleteRequest.parse().

00309 { 00310 ArrayList result = new ArrayList(); // TableColumn objects 00311 ArrayList dbColumns = new ArrayList(); // DatabaseColumn objects 00312 00313 // Instead of parsing the clause, we use a brutal force technique 00314 // and we try to directly identify every column name of each table. 00315 DatabaseColumn col; 00316 for (int i = 0; i < aliasedFrom.size(); i++) 00317 { 00318 DatabaseTable t = ((AliasedDatabaseTable) aliasedFrom.get(i)).getTable(); 00319 ArrayList cols = t.getColumns(); 00320 int size = cols.size(); 00321 for (int j = 0; j < size; j++) 00322 { 00323 col = (DatabaseColumn) cols.get(j); 00324 // if pattern found and column not already in result, it's a dependency 00325 // ! 00326 int matchIdx = whereClause.indexOf(col.getName()); 00327 while (matchIdx > 0) 00328 { 00329 // Try to check that we got the full pattern and not a sub-pattern 00330 char beforePattern = whereClause.charAt(matchIdx - 1); 00331 // Everything should be lowercase here 00332 if (((beforePattern >= 'a') && (beforePattern <= 'z')) // Everything 00333 || (beforePattern == '_')) 00334 matchIdx = whereClause.indexOf(col.getName(), matchIdx + 1); 00335 else 00336 break; 00337 } 00338 if (matchIdx == -1) 00339 continue; 00340 result.add(new TableColumn(t.getName(), col.getName())); 00341 if (col.isUnique()) 00342 pkValue = col.getName(); 00343 dbColumns.add(col); 00344 } 00345 } 00346 00347 return result; 00348 }

boolean org.objectweb.cjdbc.common.sql.DeleteRequest.isAlter  )  [virtual]
 

参照:
org.objectweb.cjdbc.common.sql.AbstractWriteRequest.isAlter()

org.objectweb.cjdbc.common.sql.AbstractWriteRequestを実装しています.

DeleteRequest.java445 行で定義されています。

00446 { 00447 return false; 00448 }

boolean org.objectweb.cjdbc.common.sql.DeleteRequest.isCreate  )  [virtual]
 

戻り値:
false
参照:
org.objectweb.cjdbc.common.sql.AbstractWriteRequest.isCreate()

org.objectweb.cjdbc.common.sql.AbstractWriteRequestを実装しています.

DeleteRequest.java403 行で定義されています。

00404 { 00405 return false; 00406 }

boolean org.objectweb.cjdbc.common.sql.DeleteRequest.isDelete  )  [virtual]
 

戻り値:
true
参照:
org.objectweb.cjdbc.common.sql.AbstractWriteRequest.isDelete()

org.objectweb.cjdbc.common.sql.AbstractWriteRequestを実装しています.

DeleteRequest.java394 行で定義されています。

00395 { 00396 return true; 00397 }

boolean org.objectweb.cjdbc.common.sql.DeleteRequest.isDrop  )  [virtual]
 

戻り値:
false
参照:
org.objectweb.cjdbc.common.sql.AbstractWriteRequest.isDrop()

org.objectweb.cjdbc.common.sql.AbstractWriteRequestを実装しています.

DeleteRequest.java412 行で定義されています。

00413 { 00414 return false; 00415 }

boolean org.objectweb.cjdbc.common.sql.DeleteRequest.isInsert  )  [virtual]
 

戻り値:
false
参照:
org.objectweb.cjdbc.common.sql.AbstractWriteRequest.isInsert()

org.objectweb.cjdbc.common.sql.AbstractWriteRequestを実装しています.

DeleteRequest.java376 行で定義されています。

00377 { 00378 return false; 00379 }

boolean org.objectweb.cjdbc.common.sql.DeleteRequest.isUnique  ) 
 

Returns true if this query only deletes a single row.

戻り値:
a boolean value
DeleteRequest.java367 行で定義されています。

参照先 org.objectweb.cjdbc.common.sql.DeleteRequest.isUnique.

00368 { 00369 return isUnique; 00370 }

boolean org.objectweb.cjdbc.common.sql.DeleteRequest.isUpdate  )  [virtual]
 

戻り値:
false
参照:
org.objectweb.cjdbc.common.sql.AbstractWriteRequest.isUpdate()

org.objectweb.cjdbc.common.sql.AbstractWriteRequestを実装しています.

DeleteRequest.java385 行で定義されています。

00386 { 00387 return false; 00388 }

void org.objectweb.cjdbc.common.sql.DeleteRequest.parse DatabaseSchema  schema,
int  granularity,
boolean  isCaseSensitive
throws SQLException [virtual]
 

Parses the SQL request and extracts the selected columns and tables given the DatabaseSchema of the database targeted by this request.

An exception is thrown when the parsing fails. Warning, this method does not check the validity of the request. In particular, invalid request could be parsed without throwing an exception. However, valid SQL request should never throw an exception.

引数:
schema a DatabaseSchema value
granularity parsing granularity as defined in ParsingGranularities
isCaseSensitive if parsing must be case sensitive
例外:
SQLException if the parsing fails

org.objectweb.cjdbc.common.sql.AbstractRequestを実装しています.

DeleteRequest.java138 行で定義されています。

参照先 org.objectweb.cjdbc.common.sql.DeleteRequest.from, org.objectweb.cjdbc.common.sql.DeleteRequest.getFromTables(), org.objectweb.cjdbc.common.sql.DeleteRequest.getWhereColumns(), と org.objectweb.cjdbc.common.sql.DeleteRequest.whereValues.

参照元 org.objectweb.cjdbc.common.sql.DeleteRequest.DeleteRequest().

00140 { 00141 if (granularity == ParsingGranularities.NO_PARSING) 00142 { 00143 isParsed = true; 00144 return; 00145 } 00146 00147 // Sanity check 00148 if (schema == null) 00149 throw new SQLException( 00150 "Unable to parse request with an undefined database schema"); 00151 00152 String originalSQL = this.trimCarriageReturn(); 00153 String sql = originalSQL.toLowerCase(); 00154 00155 int fromIdx = sql.indexOf("from "); 00156 if (fromIdx == -1) 00157 { 00158 // For queries like: DELETE t WHERE ... used by Oracle 00159 fromIdx = 6; // 6 = "delete".length() 00160 } 00161 else 00162 { 00163 fromIdx += 5; // 5 = "from".length() 00164 } 00165 00166 // Syntax is usually DELETE FROM t WHERE ... but it can be 00167 // DELETE t1,t2,... FROM t1,t2,.... WHERE ... 00168 // Let's ignore everything between DELETE and FROM, and suppose that we 00169 // delete from all tables (will just have a wider invalidation impact on the 00170 // cache). 00171 sql = sql.substring(fromIdx).trim(); 00172 00173 // Look for the WHERE clause 00174 int whereIdx = sql.indexOf("where "); 00175 00176 if (isCaseSensitive) 00177 sql = originalSQL.substring(originalSQL.length() - sql.length()); 00178 if (whereIdx == -1) 00179 tableName = sql; 00180 else 00181 tableName = sql.substring(0, whereIdx).trim(); 00182 00183 // Get the table on which DELETE occurs 00184 DatabaseTable t = schema.getTable(tableName, isCaseSensitive); 00185 if (t == null) 00186 throw new SQLException("Unknown table '" + tableName 00187 + "' in this DELETE statement: " + sqlQuery + "'"); 00188 00189 try 00190 { 00191 switch (granularity) 00192 { 00193 case ParsingGranularities.NO_PARSING : 00194 return; 00195 case ParsingGranularities.TABLE : 00196 break; 00197 case ParsingGranularities.COLUMN : 00198 from = getFromTables(tableName, schema); 00199 columns = getWhereColumns(sql.substring(whereIdx + 6).trim(), from); 00200 00201 if (from != null) 00202 { 00203 // Convert 'from' to an ArrayList of String objects instead of 00204 // AliasedTables objects 00205 int size = from.size(); 00206 ArrayList unaliased = new ArrayList(size); 00207 for (int i = 0; i < size; i++) 00208 unaliased.add(((AliasedDatabaseTable) from.get(i)).getTable() 00209 .getName()); 00210 from = unaliased; 00211 } 00212 break; 00213 case ParsingGranularities.COLUMN_UNIQUE : 00214 from = getFromTables(tableName, schema); 00215 columns = getWhereColumns(sql.substring(whereIdx + 6).trim(), from); 00216 00217 if (from != null) 00218 { 00219 // Convert 'from' to an ArrayList of String objects instead of 00220 // AliasedTables objects 00221 int size = from.size(); 00222 ArrayList unaliased = new ArrayList(size); 00223 for (int i = 0; i < size; i++) 00224 unaliased.add(((AliasedDatabaseTable) from.get(i)).getTable() 00225 .getName()); 00226 from = unaliased; 00227 } 00228 break; 00229 default : 00230 throw new SQLException("Unsupported parsing granularity: '" 00231 + granularity + "'"); 00232 } 00233 } 00234 catch (SQLException e) 00235 { 00236 from = null; 00237 columns = null; 00238 whereValues = null; 00239 throw e; 00240 } 00241 00242 isParsed = true; 00243 }


変数

transient ArrayList org.objectweb.cjdbc.common.sql.DeleteRequest.from [private]
 

ArrayList of String objects DeleteRequest.java56 行で定義されています。

参照元 org.objectweb.cjdbc.common.sql.DeleteRequest.parse().

transient boolean org.objectweb.cjdbc.common.sql.DeleteRequest.isUnique [private]
 

true if this query only deletes a single row. DeleteRequest.java53 行で定義されています。

参照元 org.objectweb.cjdbc.common.sql.DeleteRequest.debug(), org.objectweb.cjdbc.common.sql.DeleteRequest.DeleteRequest(), と org.objectweb.cjdbc.common.sql.DeleteRequest.isUnique().

ArrayList org.objectweb.cjdbc.common.sql.DeleteRequest.whereValues [protected]
 

ArrayList of values String associated with the unique columns involved in this delete query.

The values instance variable is only used when a COLUMN_UNIQUE_DELETE granularity is applied. Here, the DELETE request is UNIQUE: all columns of the WHERE clause are UNIQUE and used in the left part of an equality. When such a granularity is used, the columns instance variable contains only UNIQUE columns.

参照:
org.objectweb.cjdbc.controller.cache.result.CachingGranularities
DeleteRequest.java71 行で定義されています。

参照元 org.objectweb.cjdbc.common.sql.DeleteRequest.getValues(), と org.objectweb.cjdbc.common.sql.DeleteRequest.parse().


このクラスの説明は次のファイルから生成されました:
CJDBCversion1.0.4に対してTue Oct 12 15:16:17 2004に生成されました。 doxygen 1.3.8