Public Member Functions | |
AlterRequest (String sqlQuery, boolean escapeProcessing, int timeout, String lineSeparator) | |
AlterRequest (String sqlQuery, boolean escapeProcessing, int timeout, String lineSeparator, DatabaseSchema schema, int granularity, boolean isCaseSensitive) throws SQLException | |
boolean | isReadRequest () |
boolean | isWriteRequest () |
boolean | isUnknownRequest () |
void | parse (DatabaseSchema schema, int granularity, boolean isCaseSensitive) throws SQLException |
void | cloneParsing (AbstractRequest request) |
boolean | isAlter () |
boolean | isCreate () |
boolean | isDelete () |
boolean | isDrop () |
boolean | isInsert () |
boolean | isUpdate () |
DatabaseTable | getDatabaseTable () |
DatabaseColumn | getColumn () |
boolean | isAdd () |
Definition at line 41 of file AlterRequest.java.
|
Creates a new The request is not parsed but it can be done later by a call to parse(DatabaseSchema, int, boolean).
Definition at line 68 of file AlterRequest.java. 00070 { 00071 super(sqlQuery, escapeProcessing, timeout, lineSeparator); 00072 }
|
|
Creates a new If the syntax is incorrect an exception is thrown.
Definition at line 92 of file AlterRequest.java. References org.objectweb.cjdbc.common.sql.AlterRequest.parse(). 00095 { 00096 this(sqlQuery, escapeProcessing, timeout, lineSeparator); 00097 parse(schema, granularity, isCaseSensitive); 00098 }
|
|
Implements org.objectweb.cjdbc.common.sql.AbstractRequest. Definition at line 218 of file AlterRequest.java. References org.objectweb.cjdbc.common.sql.AbstractWriteRequest.cloneTableNameAndColumns(), org.objectweb.cjdbc.common.sql.AlterRequest.getColumn(), org.objectweb.cjdbc.common.sql.AlterRequest.getDatabaseTable(), and org.objectweb.cjdbc.common.sql.AbstractRequest.isParsed. 00219 { 00220 if (!request.isParsed()) 00221 return; 00222 AlterRequest alterRequest = (AlterRequest) request; 00223 cloneTableNameAndColumns((AbstractWriteRequest) request); 00224 table = alterRequest.getDatabaseTable(); 00225 column = alterRequest.getColumn(); 00226 isParsed = true; 00227 }
|
|
Returns the column value.
Definition at line 291 of file AlterRequest.java. Referenced by org.objectweb.cjdbc.common.sql.AlterRequest.cloneParsing(). 00292 {
00293 return column;
00294 }
|
|
Returns the table value.
Definition at line 282 of file AlterRequest.java. Referenced by org.objectweb.cjdbc.common.sql.AlterRequest.cloneParsing(). 00283 {
00284 return table;
00285 }
|
|
Returns the isAdd value.
Definition at line 300 of file AlterRequest.java. 00301 {
00302 return isAdd;
00303 }
|
|
Implements org.objectweb.cjdbc.common.sql.AbstractWriteRequest. Definition at line 232 of file AlterRequest.java. 00233 { 00234 return true; 00235 }
|
|
Implements org.objectweb.cjdbc.common.sql.AbstractWriteRequest. Definition at line 240 of file AlterRequest.java. 00241 { 00242 return false; 00243 }
|
|
Implements org.objectweb.cjdbc.common.sql.AbstractWriteRequest. Definition at line 248 of file AlterRequest.java. 00249 { 00250 return false; 00251 }
|
|
Implements org.objectweb.cjdbc.common.sql.AbstractWriteRequest. Definition at line 256 of file AlterRequest.java. 00257 { 00258 return false; 00259 }
|
|
Implements org.objectweb.cjdbc.common.sql.AbstractWriteRequest. Definition at line 264 of file AlterRequest.java. 00265 { 00266 return false; 00267 }
|
|
Reimplemented from org.objectweb.cjdbc.common.sql.AbstractWriteRequest. Definition at line 103 of file AlterRequest.java. 00104 { 00105 return false; 00106 }
|
|
Reimplemented from org.objectweb.cjdbc.common.sql.AbstractWriteRequest. Definition at line 119 of file AlterRequest.java. 00120 { 00121 return false; 00122 }
|
|
Implements org.objectweb.cjdbc.common.sql.AbstractWriteRequest. Definition at line 272 of file AlterRequest.java. 00273 { 00274 return false; 00275 }
|
|
Reimplemented from org.objectweb.cjdbc.common.sql.AbstractWriteRequest. Definition at line 111 of file AlterRequest.java. 00112 { 00113 return true; 00114 }
|
|
Implements org.objectweb.cjdbc.common.sql.AbstractRequest. Definition at line 128 of file AlterRequest.java. Referenced by org.objectweb.cjdbc.common.sql.AlterRequest.AlterRequest(). 00130 { 00131 /* 00132 * Example Alter statement: ALTER TABLE table_name ADD column_name datatype 00133 * ALTER TABLE table_name DROP COLUMN column_name 00134 */ 00135 00136 if (granularity == ParsingGranularities.NO_PARSING) 00137 { 00138 isParsed = true; 00139 return; 00140 } 00141 00142 String originalSQL = this.trimCarriageReturn(); 00143 String sql = originalSQL.toLowerCase(); 00144 00145 // Strip 'alter table ' 00146 int tableIdx = sql.indexOf("table"); 00147 if (tableIdx == -1) 00148 throw new SQLException( 00149 "Malformed Alter Request. Should start with [ALTER TABLE]"); 00150 sql = sql.substring(tableIdx + 5).trim(); 00151 00152 // Does the query contain a add? 00153 int addIdx = sql.indexOf(" add "); 00154 00155 // Does the query contain a drop? 00156 int dropIdx = sql.indexOf(" drop "); 00157 00158 if (addIdx != -1) 00159 isAdd = true; 00160 if (dropIdx != -1) 00161 isDrop = true; 00162 00163 if (!isAdd && !isDrop) 00164 throw new SQLException( 00165 "Malformed Alter Request. No drop or add condition"); 00166 00167 if (isCaseSensitive) // Reverse to the original case 00168 sql = originalSQL.substring(originalSQL.length() - sql.length()); 00169 00170 int index = (isAdd) ? addIdx : dropIdx; 00171 00172 tableName = sql.substring(0, index).trim(); 00173 table = new DatabaseTable(tableName); 00174 00175 00176 if (granularity > ParsingGranularities.TABLE) 00177 { 00178 00179 00180 int subsIndex = index + 6 + 2; // index + 00181 // column.length() 00182 // + space 00183 if (isAdd) 00184 subsIndex += 3; 00185 else 00186 // Drop 00187 subsIndex += 4; 00188 00189 columns = new ArrayList(); 00190 sql = sql.substring(subsIndex).trim(); 00191 00192 if (isAdd) 00193 { 00194 int colIndex = sql.indexOf(' '); 00195 String colName = sql.substring(0, colIndex); 00196 00197 int uniqueIndex = sql.toLowerCase().indexOf("unique"); 00198 int primary = sql.toLowerCase().indexOf("primary"); 00199 if (uniqueIndex != -1 || primary != -1) 00200 column = new DatabaseColumn(colName, true); 00201 else 00202 column = new DatabaseColumn(colName, false); 00203 columns.add(new TableColumn(tableName, colName)); 00204 } 00205 else if (isDrop) 00206 { 00207 String colName = sql.trim(); 00208 column = schema.getTable(tableName).getColumn(colName); 00209 columns.add(new TableColumn(tableName, colName)); 00210 } 00211 } 00212 isParsed = true; 00213 }
|