src/org/objectweb/cjdbc/common/sql/AbstractRequest.java

説明を見る。
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 00040 public abstract class AbstractRequest implements Serializable 00041 { 00043 protected transient long id; 00044 00046 protected String sqlQuery; 00047 00049 protected String sqlSkeleton = null; 00050 00055 protected String login; 00056 00058 protected int cacheable; 00059 00061 protected boolean isParsed; 00062 00068 protected int maxRows; 00069 00070 private int fetchSize = 0; 00071 00072 // 00073 // Connection related parameters 00074 // 00075 00077 protected boolean isReadOnly = false; 00078 00083 protected boolean isAutoCommit; 00084 00089 protected long transactionId; 00090 00095 protected int timeout; 00096 00101 protected boolean escapeProcessing = true; 00102 00107 private String lineSeparator = null; 00108 00114 private boolean driverProcessed = true; 00115 00125 public AbstractRequest(String sqlQuery, boolean escapeProcessing, 00126 int timeout, String lineSeparator) 00127 { 00128 this.sqlQuery = sqlQuery; 00129 this.escapeProcessing = escapeProcessing; 00130 this.timeout = timeout; 00131 this.lineSeparator = lineSeparator; 00132 } 00133 00140 public abstract boolean isReadRequest(); 00141 00148 public abstract boolean isWriteRequest(); 00149 00156 public abstract boolean isUnknownRequest(); 00157 00164 public boolean isParsed() 00165 { 00166 return isParsed; 00167 } 00168 00174 public boolean isReadOnly() 00175 { 00176 return isReadOnly; 00177 } 00178 00184 public void setIsReadOnly(boolean isReadOnly) 00185 { 00186 this.isReadOnly = isReadOnly; 00187 } 00188 00197 public int getCacheAbility() 00198 { 00199 return cacheable; 00200 } 00201 00210 public void setCacheAbility(int cacheAbility) 00211 { 00212 this.cacheable = cacheAbility; 00213 } 00214 00221 public boolean getEscapeProcessing() 00222 { 00223 return escapeProcessing; 00224 } 00225 00231 public long getId() 00232 { 00233 return id; 00234 } 00235 00241 public void setId(long id) 00242 { 00243 this.id = id; 00244 } 00245 00252 public boolean isAutoCommit() 00253 { 00254 return isAutoCommit; 00255 } 00256 00263 public void setIsAutoCommit(boolean isAutoCommit) 00264 { 00265 this.isAutoCommit = isAutoCommit; 00266 } 00267 00273 public String getLogin() 00274 { 00275 return login; 00276 } 00277 00283 public String getLineSeparator() 00284 { 00285 return lineSeparator; 00286 } 00287 00293 public void setLineSeparator(String lineSeparator) 00294 { 00295 this.lineSeparator = lineSeparator; 00296 } 00297 00303 public void setLogin(String login) 00304 { 00305 this.login = login; 00306 } 00307 00313 public String getSQL() 00314 { 00315 return sqlQuery; 00316 } 00317 00325 public String getSQLShortForm(int nbOfCharacters) 00326 { 00327 if ((nbOfCharacters == 0) || (sqlQuery.length() < nbOfCharacters)) 00328 return sqlQuery; 00329 else 00330 return sqlQuery.substring(0, nbOfCharacters) + "..."; 00331 } 00332 00339 public int getMaxRows() 00340 { 00341 return maxRows; 00342 } 00343 00350 public void setMaxRows(int rows) 00351 { 00352 maxRows = rows; 00353 } 00354 00362 public void setSQL(String sql) 00363 { 00364 this.sqlQuery = sql; 00365 } 00366 00372 public int getTimeout() 00373 { 00374 return timeout; 00375 } 00376 00382 public void setTimeout(int timeout) 00383 { 00384 this.timeout = timeout; 00385 } 00386 00393 public long getTransactionId() 00394 { 00395 return transactionId; 00396 } 00397 00403 public void setTransactionId(long id) 00404 { 00405 transactionId = id; 00406 } 00407 00414 public boolean equals(Object other) 00415 { 00416 if (!(other instanceof AbstractRequest)) 00417 return false; 00418 00419 AbstractRequest r = (AbstractRequest) other; 00420 return sqlQuery.equals(r.getSQL()) 00421 && (transactionId == r.getTransactionId()); 00422 } 00423 00439 public abstract void parse(DatabaseSchema schema, int granularity, 00440 boolean isCaseSensitive) throws SQLException; 00441 00447 public abstract void cloneParsing(AbstractRequest request); 00448 00456 public String trimCarriageReturn() 00457 { 00458 if (sqlSkeleton != null) 00459 return trimCarriageReturn(sqlSkeleton); 00460 else 00461 return trimCarriageReturn(sqlQuery); 00462 } 00463 00470 private String trimCarriageReturn(String s) 00471 { 00472 int lineSeparatorLength = lineSeparator.length(); 00473 int idx = s.indexOf(lineSeparator); 00474 if (idx == -1) 00475 return s; 00476 else 00477 { 00478 if (idx == 0) // carriage is the first character 00479 return trimCarriageReturn(s.substring(lineSeparatorLength)); 00480 else if (idx == (s.length() - lineSeparatorLength)) // is the last 00481 // character 00482 return s.substring(0, s.length() - lineSeparatorLength); 00483 else 00484 // is somewhere in the string 00485 return s.substring(0, idx) + " " 00486 + trimCarriageReturn(s.substring(idx + lineSeparatorLength)); 00487 } 00488 } 00489 00493 public String getSqlSkeleton() 00494 { 00495 return sqlSkeleton; 00496 } 00497 00502 public void setSqlSkeleton(String skel) 00503 { 00504 sqlSkeleton = skel; 00505 } 00506 00512 public boolean isDriverProcessed() 00513 { 00514 return driverProcessed; 00515 } 00516 00522 public void setDriverProcessed(boolean driverProcessed) 00523 { 00524 this.driverProcessed = driverProcessed; 00525 } 00526 00532 public void setFetchSize(int fetchSize) 00533 { 00534 this.fetchSize = fetchSize; 00535 } 00536 00542 public int getFetchSize() 00543 { 00544 return fetchSize; 00545 } 00546 00550 public void debug() 00551 { 00552 System.out.println("Request: " + sqlQuery); 00553 System.out.print("Cacheable status: "); 00554 System.out.println(RequestType.getInformation(cacheable)); 00555 } 00556 00557 }

CJDBCversion1.0.4に対してTue Oct 12 15:15:57 2004に生成されました。 doxygen 1.3.8