00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 package org.objectweb.cjdbc.common.sql;
00026
00027 import java.io.Serializable;
00028 import java.sql.SQLException;
00029 import java.util.ArrayList;
00030 import java.util.Hashtable;
00031 import java.util.Iterator;
00032 import java.util.StringTokenizer;
00033
00034 import org.objectweb.cjdbc.common.sql.schema.AliasedDatabaseTable;
00035 import org.objectweb.cjdbc.common.sql.schema.DatabaseColumn;
00036 import org.objectweb.cjdbc.common.sql.schema.DatabaseSchema;
00037 import org.objectweb.cjdbc.common.sql.schema.DatabaseTable;
00038 import org.objectweb.cjdbc.common.sql.schema.TableColumn;
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063 public class SelectRequest extends AbstractRequest implements Serializable
00064 {
00065
00066 private transient ArrayList select;
00067
00068
00069 private transient ArrayList from;
00070
00071
00072 private transient ArrayList aliasFrom;
00073
00074
00075 private transient ArrayList where;
00076
00077
00078 private transient ArrayList order;
00079
00080
00081 public static final int NO_FUNCTION = 0;
00082
00083 public static final int MAX_FUNCTION = 1;
00084
00085 public static final int MIN_FUNCTION = 2;
00086
00087 public static final int AVERAGE_FUNCTION = 3;
00088
00089 public static final int COUNT_FUNCTION = 4;
00090
00091 public static final int SUM_FUNCTION = 5;
00092
00093
00094 public transient int funcType = 0;
00095
00096
00097 private transient String pkValue;
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108 private transient Hashtable whereValues;
00109
00110 private String cursorName = null;
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133 public SelectRequest(String sqlQuery, boolean escapeProcessing, int timeout,
00134 String lineSeparator, DatabaseSchema schema, int granularity,
00135 boolean isCaseSensitive) throws SQLException
00136 {
00137 this(sqlQuery, escapeProcessing, timeout, lineSeparator);
00138 parse(schema, granularity, isCaseSensitive);
00139 }
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156 public SelectRequest(String sqlQuery, boolean escapeProcessing, int timeout,
00157 String lineSeparator)
00158 {
00159 super(sqlQuery, escapeProcessing, timeout, lineSeparator);
00160 cacheable = RequestType.CACHEABLE;
00161 isParsed = false;
00162 pkValue = null;
00163 }
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173 public void parse(DatabaseSchema schema, int granularity,
00174 boolean isCaseSensitive) throws SQLException
00175 {
00176 if (granularity == ParsingGranularities.NO_PARSING)
00177 {
00178 cacheable = RequestType.CACHEABLE;
00179 isParsed = true;
00180 return;
00181 }
00182
00183
00184 if (schema == null)
00185 throw new SQLException(
00186 "Unable to parse request with an undefined database schema");
00187
00188 String originalSQL = this.trimCarriageReturn();
00189 String sql = originalSQL.toLowerCase();
00190 if (!isCaseSensitive)
00191 originalSQL = sql;
00192
00193
00194 sql = sql.substring(6).trim();
00195
00196
00197 if (sql.startsWith("distinct"))
00198 sql = sql.substring(8).trim();
00199
00200
00201 int fromIndex = sql.indexOf("from ");
00202 if (fromIndex == -1)
00203 throw new SQLException(
00204 "Unable to find the FROM keyword in this SELECT statement: '" + sql
00205 + "'");
00206
00207
00208
00209 int fshift = originalSQL.length() - sql.length();
00210 String selectClause = (isCaseSensitive) ? originalSQL.substring(fshift,
00211 fshift + fromIndex) : sql.substring(0, fromIndex);
00212
00213
00214 sql = sql.substring(fromIndex + 5).trim();
00215
00216
00217 int whereIndex = 0;
00218 int parenthesis = 0;
00219 int lastParenthesisIdx = 0;
00220 boolean foundWhere = false;
00221 do
00222 {
00223 switch (sql.charAt(whereIndex))
00224 {
00225 case '(' :
00226 parenthesis++;
00227 break;
00228 case ')' :
00229 parenthesis--;
00230 lastParenthesisIdx = whereIndex;
00231 break;
00232 case 'w' :
00233 if (parenthesis == 0)
00234 try
00235 {
00236 foundWhere = (sql.charAt(whereIndex + 1) == 'h')
00237 && (sql.charAt(whereIndex + 2) == 'e')
00238 && (sql.charAt(whereIndex + 3) == 'r')
00239 && (sql.charAt(whereIndex + 4) == 'e');
00240 }
00241 catch (StringIndexOutOfBoundsException ignore)
00242 {
00243 foundWhere = false;
00244 }
00245 default :
00246 break;
00247 }
00248 whereIndex++;
00249 }
00250 while ((!foundWhere) && (whereIndex < sql.length()));
00251 if (foundWhere)
00252 whereIndex--;
00253 else
00254 whereIndex = -1;
00255
00256
00257
00258
00259
00260 int endWhere = sql.indexOf("group by ", lastParenthesisIdx);
00261 if (endWhere == -1)
00262 {
00263 endWhere = sql.indexOf("having ", lastParenthesisIdx);
00264 if (endWhere == -1)
00265 {
00266 endWhere = sql.indexOf("order by ", lastParenthesisIdx);
00267 if (endWhere == -1)
00268 {
00269 endWhere = sql.indexOf("limit ", lastParenthesisIdx);
00270 if (endWhere == -1)
00271 endWhere = sql.length();
00272 }
00273 }
00274 }
00275 int endFrom;
00276 if (whereIndex == -1)
00277 endFrom = endWhere;
00278 else
00279 endFrom = whereIndex;
00280
00281 try
00282 {
00283 switch (granularity)
00284 {
00285 case ParsingGranularities.NO_PARSING :
00286 return;
00287 case ParsingGranularities.TABLE :
00288 int shift = originalSQL.length() - sql.length();
00289 from = getFromTables(originalSQL.substring(shift, shift + endFrom)
00290 .trim(), schema, isCaseSensitive);
00291 break;
00292 case ParsingGranularities.COLUMN :
00293 case ParsingGranularities.COLUMN_UNIQUE :
00294 shift = originalSQL.length() - sql.length();
00295 from = getFromTables(originalSQL.substring(shift, shift + endFrom)
00296 .trim(), schema, isCaseSensitive);
00297
00298 select = getSelectedColumns(selectClause, from, isCaseSensitive);
00299 if (whereIndex > 1)
00300
00301 where = getWhereColumns(originalSQL.substring(
00302 shift + whereIndex + 5, shift + endWhere).trim(), from,
00303 granularity == ParsingGranularities.COLUMN_UNIQUE,
00304 isCaseSensitive);
00305 break;
00306 default :
00307 throw new SQLException("Unsupported parsing granularity: '"
00308 + granularity + "'");
00309 }
00310 }
00311 catch (SQLException e)
00312 {
00313 from = null;
00314 select = null;
00315 where = null;
00316 cacheable = RequestType.UNCACHEABLE;
00317 throw e;
00318 }
00319
00320
00321
00322
00323
00324 aliasFrom = from;
00325
00326 if (from != null)
00327 {
00328
00329
00330 int size = from.size();
00331 ArrayList unaliased = new ArrayList(size);
00332 for (int i = 0; i < size; i++)
00333 unaliased
00334 .add(((AliasedDatabaseTable) from.get(i)).getTable().getName());
00335 from = unaliased;
00336 }
00337
00338 isParsed = true;
00339 }
00340
00341
00342
00343
00344 public void cloneParsing(AbstractRequest request)
00345 {
00346 if (!request.isParsed())
00347 return;
00348 SelectRequest selectRequest = (SelectRequest) request;
00349 select = selectRequest.getSelect();
00350 from = selectRequest.getFrom();
00351 where = selectRequest.getWhere();
00352 cacheable = selectRequest.getCacheAbility();
00353 pkValue = selectRequest.getPkValue();
00354 isParsed = true;
00355 }
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369 private ArrayList getFromTables(String fromClause, DatabaseSchema schema,
00370 boolean isCaseSensitive) throws SQLException
00371 {
00372 ArrayList result = new ArrayList();
00373
00374
00375 try
00376 {
00377 int subSelect = fromClause.toLowerCase().indexOf("select ");
00378 while (subSelect != -1)
00379 {
00380 int subFromIndex = fromClause.indexOf("from", subSelect + 1) + 5;
00381 int bracket = subFromIndex;
00382 int parenthesis = 1;
00383 do
00384 {
00385 char c = fromClause.charAt(bracket);
00386 switch (c)
00387 {
00388 case '(' :
00389 parenthesis++;
00390 break;
00391 case ')' :
00392 parenthesis--;
00393 break;
00394 default :
00395 break;
00396 }
00397 bracket++;
00398 }
00399 while ((parenthesis > 0) && (bracket < fromClause.length()));
00400
00401 SelectRequest subQuery = new SelectRequest(fromClause.substring(
00402 subSelect, bracket - 1).trim(), this.escapeProcessing, 0,
00403 getLineSeparator());
00404 subQuery.parse(schema, ParsingGranularities.TABLE, isCaseSensitive);
00405 for (Iterator iter = subQuery.getFrom().iterator(); iter.hasNext();)
00406 {
00407 result.add(new AliasedDatabaseTable(schema.getTable((String) iter
00408 .next(), isCaseSensitive), null));
00409 }
00410
00411 if (subFromIndex + bracket > fromClause.length())
00412 {
00413 if (subSelect > 0)
00414 {
00415 fromClause = fromClause.substring(0, subSelect - 1).trim();
00416 if ((fromClause.length() > 0)
00417 && (fromClause.charAt(fromClause.length() - 1) == '('))
00418 fromClause = fromClause.substring(0, fromClause.length() - 1)
00419 .trim();
00420 }
00421 else
00422 fromClause = "";
00423 break;
00424 }
00425 fromClause = (subSelect > 0 ? fromClause.substring(0, subSelect - 1)
00426 .trim() : "")
00427 + fromClause.substring(subFromIndex + bracket).trim();
00428 subSelect = fromClause.toLowerCase().indexOf("select");
00429 }
00430 }
00431 catch (RuntimeException e)
00432 {
00433
00434 return schema.getTables();
00435 }
00436
00437
00438
00439 ArrayList tables = schema.getTables();
00440 int size = tables.size();
00441 for (int i = 0; i < size; i++)
00442 {
00443
00444 DatabaseTable t = (DatabaseTable) tables.get(i);
00445 String tableName = t.getName();
00446 if (!isCaseSensitive)
00447 tableName = tableName.toLowerCase();
00448
00449
00450 int index;
00451 int afterTableNameIndex = 0;
00452 boolean left;
00453 boolean right;
00454 do
00455 {
00456 index = fromClause.indexOf(tableName, afterTableNameIndex);
00457 if (index == -1)
00458 break;
00459 afterTableNameIndex = index + tableName.length();
00460 left = (index == 0)
00461 || ((index > 0) && ((fromClause.charAt(index - 1) == ' ')
00462 || (fromClause.charAt(index - 1) == '(')
00463 || (fromClause.charAt(index - 1) == ',') || (fromClause
00464 .charAt(index - 1) == getLineSeparator().charAt(
00465 getLineSeparator().length() - 1))));
00466 right = (afterTableNameIndex >= fromClause.length())
00467 || ((afterTableNameIndex < fromClause.length()) && ((fromClause
00468 .charAt(afterTableNameIndex) == ' ')
00469 || (fromClause.charAt(afterTableNameIndex) == ',')
00470 || (fromClause.charAt(afterTableNameIndex) == ')') || (fromClause
00471 .charAt(afterTableNameIndex) == getLineSeparator().charAt(0))));
00472 }
00473 while (!left || !right);
00474 if (index != -1)
00475 {
00476
00477
00478 String alias = null;
00479 index += tableName.length();
00480 if ((index < fromClause.length()) && (fromClause.charAt(index) == ' '))
00481 {
00482 char c;
00483
00484 do
00485 {
00486 c = fromClause.charAt(index);
00487 index++;
00488 }
00489 while ((index < fromClause.length()) && (c != ' ')
00490 && (c != getLineSeparator().charAt(0)));
00491 if (index < fromClause.length())
00492 {
00493 int start = index;
00494 do
00495 {
00496 c = fromClause.charAt(index);
00497 index++;
00498 }
00499 while ((index < fromClause.length()) && (c != ' ') && (c != ',')
00500 && (c != getLineSeparator().charAt(0)));
00501 alias = fromClause.substring(start, index - 1);
00502 }
00503 }
00504 result.add(new AliasedDatabaseTable(t, alias));
00505 }
00506 }
00507 return result;
00508 }
00509
00510
00511
00512
00513
00514
00515
00516
00517
00518
00519
00520
00521
00522
00523
00524 private ArrayList getSelectedColumns(String selectClause,
00525 ArrayList aliasedFrom, boolean isCaseSensitive)
00526 {
00527 StringTokenizer selectTokens = new StringTokenizer(selectClause, ",");
00528 ArrayList result = new ArrayList();
00529 StringBuffer unresolvedTokens = null;
00530
00531 while (selectTokens.hasMoreTokens())
00532 {
00533 String token = selectTokens.nextToken().trim();
00534
00535 if (isSqlFunction(token))
00536 {
00537
00538
00539
00540
00541 int leftPar = token.indexOf("(");
00542 token = token.substring(leftPar + 1, token.length() - 1);
00543 }
00544
00545 String alias = null;
00546 int aliasIdx = token.indexOf(".");
00547 if (aliasIdx != -1)
00548 {
00549 alias = token.substring(0, aliasIdx);
00550 token = token.substring(aliasIdx + 1);
00551 }
00552
00553
00554 int as = token.indexOf(" as ");
00555 if (as != -1)
00556 token = token.substring(0, as).trim();
00557
00558
00559
00560
00561 if (token.indexOf("*") != -1)
00562 {
00563 if (alias == null)
00564 {
00565
00566
00567 int size = aliasedFrom.size();
00568 for (int i = 0; i < size; i++)
00569 {
00570 DatabaseTable t = ((AliasedDatabaseTable) aliasedFrom.get(i))
00571 .getTable();
00572 ArrayList cols = t.getColumns();
00573 int colSize = cols.size();
00574 for (int j = 0; j < colSize; j++)
00575 result.add(new TableColumn(t.getName(), ((DatabaseColumn) cols
00576 .get(j)).getName()));
00577 }
00578 return result;
00579 }
00580 else
00581 {
00582
00583 int size = aliasedFrom.size();
00584 for (int i = 0; i < size; i++)
00585 {
00586 AliasedDatabaseTable adt = (AliasedDatabaseTable) aliasedFrom
00587 .get(i);
00588
00589
00590 if (alias.equals(adt.getAlias())
00591 || alias.equals(adt.getTable().getName()))
00592 {
00593 DatabaseTable t = adt.getTable();
00594 ArrayList cols = t.getColumns();
00595 int colSize = cols.size();
00596 for (int j = 0; j < colSize; j++)
00597 result.add(new TableColumn(t.getName(), ((DatabaseColumn) cols
00598 .get(i)).getName()));
00599 break;
00600 }
00601 }
00602 }
00603 continue;
00604 }
00605
00606
00607
00608 DatabaseColumn col = null;
00609
00610 if (alias == null)
00611 {
00612 int size = aliasedFrom.size();
00613 for (int i = 0; i < size; i++)
00614 {
00615 DatabaseTable t = ((AliasedDatabaseTable) aliasedFrom.get(i))
00616 .getTable();
00617 col = t.getColumn(token, isCaseSensitive);
00618 if (col != null)
00619 {
00620 result.add(new TableColumn(t.getName(), col.getName()));
00621 break;
00622 }
00623 }
00624 }
00625 else
00626
00627 {
00628 int size = aliasedFrom.size();
00629 for (int i = 0; i < size; i++)
00630 {
00631 AliasedDatabaseTable t = (AliasedDatabaseTable) aliasedFrom.get(i);
00632
00633
00634 if (alias.equals(t.getAlias())
00635 || alias.equals(t.getTable().getName()))
00636 {
00637 col = t.getTable().getColumn(token, isCaseSensitive);
00638 if (col != null)
00639 {
00640 result
00641 .add(new TableColumn(t.getTable().getName(), col.getName()));
00642 break;
00643 }
00644 }
00645 }
00646 }
00647
00648 if (col == null)
00649 {
00650 if (unresolvedTokens == null)
00651 unresolvedTokens = new StringBuffer();
00652 unresolvedTokens.append(token);
00653 unresolvedTokens.append(" ");
00654 }
00655 }
00656
00657 if (unresolvedTokens != null)
00658 {
00659
00660
00661
00662 DatabaseColumn col;
00663
00664 String unresolvedTokensString = unresolvedTokens.toString();
00665 if (!isCaseSensitive)
00666 unresolvedTokensString = unresolvedTokensString.toLowerCase();
00667
00668 int asize = aliasedFrom.size();
00669 for (int i = 0; i < asize; i++)
00670 {
00671 DatabaseTable t = ((AliasedDatabaseTable) aliasedFrom.get(i))
00672 .getTable();
00673 ArrayList cols = t.getColumns();
00674 int size = cols.size();
00675 for (int j = 0; j < size; j++)
00676 {
00677 col = (DatabaseColumn) cols.get(j);
00678 String columnName = col.getName();
00679 if (!isCaseSensitive)
00680 columnName = columnName.toLowerCase();
00681
00682
00683
00684 int matchIdx = unresolvedTokensString.indexOf(columnName);
00685 if (matchIdx != -1)
00686 if ((matchIdx == 0)
00687 || (unresolvedTokens.charAt(matchIdx - 1) == ' ')
00688 || (unresolvedTokens.charAt(matchIdx - 1) == '(')
00689 || (unresolvedTokens.charAt(matchIdx - 1) == '.'))
00690 {
00691 TableColumn c = new TableColumn(t.getName(), col.getName());
00692 if (!result.contains(c))
00693 result.add(c);
00694 }
00695 }
00696 }
00697 }
00698 return result;
00699 }
00700
00701
00702
00703
00704
00705
00706
00707
00708
00709 private boolean isSqlFunction(String str)
00710 {
00711
00712 if (str != null)
00713 {
00714 if (str.startsWith("max(") && str.endsWith(")"))
00715 {
00716 funcType = SelectRequest.MAX_FUNCTION;
00717 return true;
00718 }
00719 else if (str.startsWith("count(") && str.endsWith(")"))
00720 {
00721 funcType = SelectRequest.COUNT_FUNCTION;
00722 return true;
00723 }
00724 else if (str.startsWith("avg(") && str.endsWith(")"))
00725 {
00726 funcType = SelectRequest.AVERAGE_FUNCTION;
00727 return true;
00728 }
00729 else if (str.startsWith("min(") && str.endsWith(")"))
00730 {
00731 funcType = SelectRequest.MIN_FUNCTION;
00732 return true;
00733 }
00734 else if (str.startsWith("sum(") && str.endsWith(")"))
00735 {
00736 funcType = SelectRequest.SUM_FUNCTION;
00737 return true;
00738 }
00739 else
00740 {
00741 funcType = SelectRequest.NO_FUNCTION;
00742 return false;
00743 }
00744 }
00745 else
00746 return false;
00747 }
00748
00749
00750
00751
00752
00753
00754
00755
00756
00757
00758
00759
00760
00761
00762
00763
00764
00765 private ArrayList getWhereColumns(String whereClause, ArrayList aliasedFrom,
00766 boolean setUniqueCacheable, boolean isCaseSensitive)
00767 {
00768 ArrayList result = new ArrayList();
00769
00770
00771 if (!isCaseSensitive)
00772 whereClause = whereClause.toLowerCase();
00773
00774
00775
00776 DatabaseColumn col;
00777 for (int i = 0; i < aliasedFrom.size(); i++)
00778 {
00779 DatabaseTable t = ((AliasedDatabaseTable) aliasedFrom.get(i)).getTable();
00780 ArrayList cols = t.getColumns();
00781 int size = cols.size();
00782 for (int j = 0; j < size; j++)
00783 {
00784 col = (DatabaseColumn) cols.get(j);
00785
00786
00787 String columnName = col.getName();
00788 if (!isCaseSensitive)
00789 columnName = columnName.toLowerCase();
00790
00791 int matchIdx = whereClause.indexOf(columnName);
00792 while (matchIdx > 0)
00793 {
00794
00795
00796 char beforePattern = whereClause.charAt(matchIdx - 1);
00797 if (((beforePattern >= 'a') && (beforePattern <= 'z'))
00798 || ((beforePattern >= 'A') && (beforePattern <= 'Z'))
00799 || (beforePattern == '_'))
00800 matchIdx = whereClause.indexOf(columnName, matchIdx + 1);
00801 else
00802 {
00803 char afterPattern;
00804 try
00805 {
00806 afterPattern = whereClause.charAt(matchIdx + columnName.length());
00807 if (((afterPattern >= 'a') && (afterPattern <= 'z'))
00808 || ((afterPattern >= 'A') && (afterPattern <= 'Z'))
00809 || (afterPattern == '_'))
00810 {
00811
00812
00813
00814 matchIdx = whereClause.indexOf(columnName, matchIdx + 1);
00815 }
00816 else
00817 break;
00818 }
00819 catch (IndexOutOfBoundsException e)
00820 {
00821 break;
00822 }
00823 }
00824 }
00825 if (matchIdx == -1)
00826 continue;
00827 result.add(new TableColumn(t.getName(), col.getName()));
00828
00829 if (setUniqueCacheable)
00830 {
00831
00832 if (!col.isUnique())
00833 {
00834
00835
00836 setUniqueCacheable = false;
00837 continue;
00838 }
00839
00840
00841
00842
00843
00844
00845
00846 int lookingForEqual = matchIdx + columnName.length();
00847 boolean searchReverse = false;
00848 try
00849 {
00850 while (whereClause.charAt(lookingForEqual) == ' ')
00851 lookingForEqual++;
00852 }
00853 catch (Exception e)
00854 {
00855 searchReverse = true;
00856 }
00857
00858 String rightSide;
00859
00860 if (searchReverse || (whereClause.charAt(lookingForEqual) != '='))
00861 {
00862 try
00863 {
00864
00865 StringBuffer sb = new StringBuffer(whereClause.substring(0,
00866 lookingForEqual));
00867 String reverse = sb.reverse().toString();
00868 reverse = reverse.substring(reverse.indexOf('=') + 1);
00869 sb = new StringBuffer(reverse);
00870
00871 sb = sb.reverse();
00872 rightSide = sb.toString();
00873 }
00874 catch (Exception e)
00875 {
00876
00877 setUniqueCacheable = false;
00878 continue;
00879 }
00880 }
00881 else
00882 {
00883
00884 int nextSpace = lookingForEqual + 1;
00885 try
00886 {
00887 while (whereClause.charAt(nextSpace) == ' ')
00888 nextSpace++;
00889 }
00890 catch (Exception e1)
00891 {
00892
00893
00894 setUniqueCacheable = false;
00895 continue;
00896 }
00897
00898 rightSide = whereClause.substring(nextSpace);
00899 }
00900 char firstChar = rightSide.charAt(0);
00901 if ((firstChar == '\'') || (firstChar == '"')
00902 || ((firstChar >= '0') && (firstChar <= '9'))
00903 || (firstChar == '?'))
00904 {
00905
00906
00907
00908
00909
00910 pkValue = rightSide;
00911 }
00912 else
00913 {
00914 setUniqueCacheable = false;
00915 continue;
00916 }
00917 }
00918 }
00919 }
00920
00921 if (setUniqueCacheable && !result.isEmpty())
00922 cacheable = RequestType.UNIQUE_CACHEABLE;
00923
00924 return result;
00925 }
00926
00927
00928
00929
00930
00931
00932
00933
00934 public ArrayList getSelect()
00935 {
00936 return select;
00937 }
00938
00939
00940
00941
00942
00943
00944
00945
00946 public ArrayList getFrom()
00947 {
00948 return from;
00949 }
00950
00951
00952
00953
00954
00955
00956
00957
00958 public ArrayList getAliasedFrom()
00959 {
00960 return aliasFrom;
00961 }
00962
00963
00964
00965
00966
00967
00968
00969
00970 public ArrayList getWhere()
00971 {
00972 return where;
00973 }
00974
00975
00976
00977
00978
00979
00980
00981
00982 public ArrayList getOrderBy()
00983 {
00984 return order;
00985 }
00986
00987
00988
00989
00990
00991
00992
00993
00994 public Hashtable getWhereValues()
00995 {
00996 return whereValues;
00997 }
00998
00999
01000
01001
01002
01003 public boolean isReadRequest()
01004 {
01005 return true;
01006 }
01007
01008
01009
01010
01011
01012 public boolean isWriteRequest()
01013 {
01014 return false;
01015 }
01016
01017
01018
01019
01020
01021 public boolean isUnknownRequest()
01022 {
01023 return false;
01024 }
01025
01026
01027
01028
01029 public String getPkValue()
01030 {
01031 return pkValue;
01032 }
01033
01034
01035
01036
01037 public void setPkValue(String pkValue)
01038 {
01039 this.pkValue = pkValue;
01040 }
01041
01042
01043
01044
01045
01046
01047 public String getCursorName()
01048 {
01049 return cursorName;
01050 }
01051
01052
01053
01054
01055
01056
01057 public void setCursorName(String cursorName)
01058 {
01059 this.cursorName = cursorName;
01060 }
01061
01062
01063
01064
01065 public void debug()
01066 {
01067 super.debug();
01068 if (select != null)
01069 {
01070 System.out.println("Selected columns:");
01071 for (int i = 0; i < select.size(); i++)
01072 System.out
01073 .println(" " + ((TableColumn) select.get(i)).getColumnName());
01074 }
01075 else
01076 System.out.println("No information on selected columns");
01077
01078 if (select != null)
01079 {
01080 System.out.println("");
01081 System.out.println("From tables:");
01082 for (int i = 0; i < from.size(); i++)
01083 System.out.println(" " + from.get(i));
01084 }
01085 else
01086 System.out.println("No information on from tables");
01087
01088 System.out.println("");
01089 System.out.println("Where columns:");
01090 if (where == null)
01091 System.out.println(" No Where clause");
01092 else
01093 for (int i = 0; i < where.size(); i++)
01094 System.out.print(" " + ((TableColumn) where.get(i)).getColumnName());
01095
01096 System.out.println("");
01097 System.out.println("PK value: " + pkValue);
01098 }
01099
01100 }