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

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

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

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

説明

A CreateRequest is a SQL request of the following syntax:

  CREATE [TEMPORARY] TABLE table-name [(column-name column-type [,column-name colum-type]* [,table-constraint-definition]*)]
 

作者:
Julie Marguerite

Mathieu Peltier

バージョン:
1.0

CreateRequest.java48 行で定義されています。

Public メソッド

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

Private 変数

transient DatabaseTable table = null
transient ArrayList fromTables = null


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

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

Creates a new CreateRequest instance. The caller must give an SQL request, without any leading or trailing spaces and beginning with 'create table ' (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
CreateRequest.java77 行で定義されています。

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

00080 { 00081 this(sqlQuery, escapeProcessing, timeout, lineSeparator); 00082 parse(schema, granularity, isCaseSensitive); 00083 }

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

Creates a new CreateRequest 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
CreateRequest.java100 行で定義されています。
00102 { 00103 super(sqlQuery, escapeProcessing, timeout, lineSeparator); 00104 cacheable = RequestType.UNCACHEABLE; 00105 isParsed = false; 00106 }


メソッド

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

参照:
AbstractRequest.cloneParsing(AbstractRequest)

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

CreateRequest.java303 行で定義されています。

参照先 org.objectweb.cjdbc.common.sql.AbstractWriteRequest.cloneTableNameAndColumns(), org.objectweb.cjdbc.common.sql.CreateRequest.fromTables, org.objectweb.cjdbc.common.sql.CreateRequest.getDatabaseTable(), org.objectweb.cjdbc.common.sql.CreateRequest.getFromTables(), org.objectweb.cjdbc.common.sql.AbstractRequest.isParsed, と org.objectweb.cjdbc.common.sql.CreateRequest.table.

00304 { 00305 if (!request.isParsed()) 00306 return; 00307 CreateRequest createRequest = (CreateRequest) request; 00308 cloneTableNameAndColumns((AbstractWriteRequest) request); 00309 table = createRequest.getDatabaseTable(); 00310 fromTables = createRequest.getFromTables(); 00311 isParsed = true; 00312 }

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

Displays some debugging information about this request.

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

CreateRequest.java383 行で定義されています。

00384 { 00385 super.debug(); 00386 if (tableName != null) 00387 System.out.println("Created table: " + tableName); 00388 else 00389 System.out.println("No information about created table"); 00390 00391 if (columns != null) 00392 { 00393 System.out.println("Created columns:"); 00394 for (int i = 0; i < columns.size(); i++) 00395 System.out.println(" " 00396 + ((TableColumn) columns.get(i)).getColumnName()); 00397 } 00398 else 00399 System.out.println("No information about created columns"); 00400 00401 System.out.println(); 00402 }

DatabaseTable org.objectweb.cjdbc.common.sql.CreateRequest.getDatabaseTable  ) 
 

Gets the database table created by this statement.

戻り値:
a DatabaseTable value
CreateRequest.java364 行で定義されています。

参照先 org.objectweb.cjdbc.common.sql.CreateRequest.table.

参照元 org.objectweb.cjdbc.common.sql.CreateRequest.cloneParsing().

00365 { 00366 return table; 00367 }

ArrayList org.objectweb.cjdbc.common.sql.CreateRequest.getFromTables  ) 
 

Returns the list of tables used to fill the created table in case of create query containing a select.

戻り値:
and ArrayList
CreateRequest.java375 行で定義されています。

参照先 org.objectweb.cjdbc.common.sql.CreateRequest.fromTables.

参照元 org.objectweb.cjdbc.common.sql.CreateRequest.cloneParsing().

00376 { 00377 return fromTables; 00378 }

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

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

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

CreateRequest.java406 行で定義されています。

00407 { 00408 return false; 00409 }

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

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

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

CreateRequest.java318 行で定義されています。

00319 { 00320 return true; 00321 }

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

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

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

CreateRequest.java345 行で定義されています。

00346 { 00347 return false; 00348 }

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

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

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

CreateRequest.java354 行で定義されています。

00355 { 00356 return false; 00357 }

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

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

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

CreateRequest.java327 行で定義されています。

00328 { 00329 return false; 00330 }

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

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

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

CreateRequest.java336 行で定義されています。

00337 { 00338 return false; 00339 }

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

参照:
org.objectweb.cjdbc.common.sql.AbstractRequest.parse(org.objectweb.cjdbc.common.sql.schema.DatabaseSchema, int, boolean)

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

CreateRequest.java112 行で定義されています。

参照先 org.objectweb.cjdbc.common.sql.CreateRequest.fromTables, org.objectweb.cjdbc.common.sql.SelectRequest.getFrom(), org.objectweb.cjdbc.common.sql.AbstractRequest.getLineSeparator(), org.objectweb.cjdbc.common.sql.SelectRequest.getSelect(), org.objectweb.cjdbc.common.sql.SelectRequest.parse(), org.objectweb.cjdbc.common.sql.schema.DatabaseColumn.setIsUnique(), と org.objectweb.cjdbc.common.sql.CreateRequest.table.

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

00114 { 00115 if (granularity == ParsingGranularities.NO_PARSING) 00116 { 00117 isParsed = true; 00118 return; 00119 } 00120 00121 String originalSQL = this.trimCarriageReturn(); 00122 String sql = originalSQL.toLowerCase(); 00123 00124 // Strip 'create [temporary] table ' 00125 int tableIdx = sql.indexOf("table"); 00126 sql = sql.substring(tableIdx + 5).trim(); 00127 00128 // Does the query contain a select? 00129 int selectIdx = sql.indexOf("select"); 00130 00131 if (isCaseSensitive) // Reverse to the original case 00132 sql = originalSQL.substring(originalSQL.length() - sql.length()); 00133 00134 if (selectIdx != -1) 00135 { 00136 // Get the table on which CREATE occurs 00137 int nextSpaceIdx = sql.indexOf(" "); 00138 tableName = sql.substring(0, nextSpaceIdx).trim(); 00139 table = new DatabaseTable(tableName); 00140 // Parse the select 00141 sql = sql.substring(selectIdx).trim(); 00142 SelectRequest select = new SelectRequest(sql, false, 60, 00143 getLineSeparator()); 00144 select.parse(schema, granularity, isCaseSensitive); 00145 fromTables = select.getFrom(); 00146 if (granularity > ParsingGranularities.TABLE) 00147 { 00148 columns = select.getSelect(); 00149 } 00150 00151 } 00152 else 00153 { 00154 // Get the table on which CREATE occurs 00155 // Look for the parenthesis 00156 int openParenthesisIdx = sql.indexOf("("); 00157 int closeParenthesisIdx = sql.lastIndexOf(")"); 00158 if ((openParenthesisIdx == -1) && (closeParenthesisIdx == -1)) 00159 { 00160 // no parenthesis found 00161 table = new DatabaseTable(sql.trim()); 00162 if (granularity > ParsingGranularities.TABLE) 00163 { 00164 columns = new ArrayList(); 00165 } 00166 return; 00167 } 00168 else if ((openParenthesisIdx == -1) || (closeParenthesisIdx == -1) 00169 || (openParenthesisIdx > closeParenthesisIdx)) 00170 { 00171 throw new SQLException("Syntax error in this CREATE statement: '" 00172 + sqlQuery + "'"); 00173 } 00174 else 00175 { 00176 tableName = sql.substring(0, openParenthesisIdx).trim(); 00177 } 00178 table = new DatabaseTable(tableName); 00179 00180 // Get the column names 00181 if (granularity > ParsingGranularities.TABLE) 00182 { 00183 columns = new ArrayList(); 00184 sql = sql.substring(openParenthesisIdx + 1, closeParenthesisIdx).trim(); 00185 StringTokenizer columnTokens = new StringTokenizer(sql, ","); 00186 String word; 00187 String lowercaseWord; 00188 StringTokenizer wordTokens = null; 00189 String token; 00190 DatabaseColumn col = null; 00191 00192 while (columnTokens.hasMoreTokens()) 00193 { 00194 token = columnTokens.nextToken().trim(); 00195 00196 // work around to prevent bug: if the request contains for example: 00197 // INDEX foo (col1,col2) 00198 // we have to merge the 2 tokens: 'INDEX foo (col1' and 'col2)' 00199 if ((token.indexOf("(") != -1) && (token.indexOf(")") == -1)) 00200 { 00201 if (columnTokens.hasMoreTokens()) 00202 token = token + "," + columnTokens.nextToken().trim(); 00203 else 00204 { 00205 tableName = null; 00206 columns = null; 00207 throw new SQLException("Syntax error in this CREATE statement: '" 00208 + sqlQuery + "'"); 00209 } 00210 } 00211 00212 // First word of the line: either a column name or 00213 // a table constraint definition 00214 wordTokens = new StringTokenizer(token, " "); 00215 word = wordTokens.nextToken().trim(); 00216 lowercaseWord = word.toLowerCase(); 00217 00218 // If it's a constraint, index or check keyword do not do anything 00219 // else parse the line 00220 if (!lowercaseWord.equals("constraint") 00221 && !lowercaseWord.equals("index") 00222 && !lowercaseWord.equals("check")) 00223 { 00224 String columnName; 00225 boolean isUnique = false; 00226 // Check for primary key or unique constraint 00227 if (lowercaseWord.equals("primary") 00228 || lowercaseWord.startsWith("unique")) 00229 { 00230 00231 // Get the name of the column 00232 openParenthesisIdx = token.indexOf("("); 00233 closeParenthesisIdx = token.indexOf(")"); 00234 if ((openParenthesisIdx == -1) || (closeParenthesisIdx == -1) 00235 || (openParenthesisIdx > closeParenthesisIdx)) 00236 { 00237 tableName = null; 00238 columns = null; 00239 throw new SQLException( 00240 "Syntax error in this CREATE statement: '" + sqlQuery + "'"); 00241 } 00242 00243 columnName = token.substring(openParenthesisIdx + 1, 00244 closeParenthesisIdx).trim(); 00245 00246 // Set this column to unique 00247 col = table.getColumn(columnName); 00248 // Test first if dbTable contains this column. This can fail with 00249 // some invalid request, for example: 00250 // CREATE TABLE categories(id INT4, name TEXT, PRIMARY KEY((id)) 00251 if (col == null) 00252 { 00253 tableName = null; 00254 columns = null; 00255 throw new SQLException( 00256 "Syntax error in this CREATE statement: '" + sqlQuery + "'"); 00257 } 00258 else 00259 col.setIsUnique(true); 00260 } 00261 else 00262 { 00263 // It's a column name 00264 columnName = word; 00265 00266 if (!wordTokens.hasMoreTokens()) 00267 { 00268 // at least type declaration is required 00269 tableName = null; 00270 columns = null; 00271 throw new SQLException( 00272 "Syntax error in this CREATE statement: '" + sqlQuery + "'"); 00273 } 00274 00275 // Check for primary key or unique constraints 00276 do 00277 { 00278 word = wordTokens.nextToken().trim().toLowerCase(); 00279 if (word.equals("primary") || word.startsWith("unique")) 00280 { 00281 // Create the column as unique 00282 isUnique = true; 00283 break; 00284 } 00285 } 00286 while (wordTokens.hasMoreTokens()); 00287 00288 // Add the column to the parsed columns list and 00289 // to the create DatabaseTable 00290 columns.add(new TableColumn(tableName, columnName)); 00291 table.addColumn(new DatabaseColumn(columnName, isUnique)); 00292 } 00293 } 00294 } 00295 } 00296 } 00297 isParsed = true; 00298 }


変数

transient ArrayList org.objectweb.cjdbc.common.sql.CreateRequest.fromTables = null [private]
 

List of tables used to fill the created table in case of create query containing a select. CreateRequest.java57 行で定義されています。

参照元 org.objectweb.cjdbc.common.sql.CreateRequest.cloneParsing(), org.objectweb.cjdbc.common.sql.CreateRequest.getFromTables(), と org.objectweb.cjdbc.common.sql.CreateRequest.parse().

transient DatabaseTable org.objectweb.cjdbc.common.sql.CreateRequest.table = null [private]
 

The table to create. CreateRequest.java51 行で定義されています。

参照元 org.objectweb.cjdbc.common.sql.CreateRequest.cloneParsing(), org.objectweb.cjdbc.common.sql.CreateRequest.getDatabaseTable(), と org.objectweb.cjdbc.common.sql.CreateRequest.parse().


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