1 19 package org.netbeans.modules.db.sql.visualeditor.querymodel; 20 21 25 28 import java.util.ArrayList ; 29 import java.util.List ; 30 import java.util.Collection ; 31 32 public class WhereNode implements Where { 33 34 36 private Expression _cond; 38 39 41 public WhereNode() { 42 _cond = null; 43 } 44 45 public WhereNode(Expression cond) { 46 _cond = cond; 47 } 52 53 54 56 public void resetExpression() { 57 _cond = null; 58 } 59 60 public void replaceExpression(Expression expression) { 61 _cond = expression; 62 } 63 64 public Expression getExpression () { 65 return _cond; 66 } 67 68 70 public Expression findExpression(String table1, String column1, String table2, String column2) { 71 return _cond.findExpression(table1, column1, table2, column2); 72 } 73 74 void removeTable(String tableSpec) { 77 if (_cond instanceof ExpressionList) { 78 ExpressionList list = (ExpressionList)_cond; 79 list.removeTable(tableSpec); 80 if (list.size() == 0) 81 _cond = null; 82 } 83 else { 84 ArrayList column = new ArrayList (); 85 _cond.getReferencedColumns(column); 86 for (int i = 0; i < column.size(); i++) { 87 Column col = (Column)column.get(i); 88 if (col.matches(tableSpec)) { 89 _cond = null; 90 } 91 } 92 } 93 } 94 95 public void getReferencedColumns (Collection columns) { 97 if (_cond != null) 98 _cond.getReferencedColumns (columns); 99 } 100 101 public void getQueryItems(Collection items) { 102 if (_cond != null) 103 items.add(_cond); 104 } 105 106 public String genText() { 108 if (_cond!=null) 109 return "\nWHERE " + _cond.genText() ; else 111 return ""; } 113 114 public boolean isParameterized() { 116 if (_cond!=null) 117 return _cond.isParameterized(); 118 else 119 return false; 120 } 121 122 123 void renameTableSpec(String oldTableSpec, String corrName) { 124 _cond.renameTableSpec(oldTableSpec, corrName); 125 } 126 } 127 | Popular Tags |