1 21 package oracle.toplink.essentials.internal.expressions; 23 24 import java.io.*; 25 import java.util.*; 26 import oracle.toplink.essentials.internal.helper.*; 27 import oracle.toplink.essentials.expressions.*; 28 29 public class TableExpression extends DataExpression { 30 protected DatabaseTable table; 31 32 35 public TableExpression() { 36 super(); 37 } 38 39 42 public TableExpression(DatabaseTable aTable) { 43 super(); 44 table = aTable; 45 } 46 47 51 public String descriptionOfNodeType() { 52 return "Table"; 53 } 54 55 60 public Expression getField(String fieldName) { 61 DatabaseField field = new DatabaseField(fieldName); 63 if (!field.hasTableName()) { 64 field.setTable(getTable()); 65 } 66 return getField(field); 67 } 68 69 72 public Vector getOwnedTables() { 73 Vector result = new Vector(1); 74 result.addElement(getTable()); 75 return result; 76 } 77 78 public DatabaseTable getTable() { 79 return table; 80 } 81 82 public boolean isTableExpression() { 83 return true; 84 } 85 86 91 public Expression normalize(ExpressionNormalizer normalizer) { 92 if (getTable().getTableQualifier().length() == 0 && (normalizer.getSession().getDatasourceLogin().getTableQualifier().length() != 0)) { 95 getTable().setTableQualifier(normalizer.getSession().getDatasourceLogin().getTableQualifier()); 96 } 97 return super.normalize(normalizer); 98 } 99 100 105 public Expression rebuildOn(Expression newBase) { 106 Expression newLocalBase = getBaseExpression().rebuildOn(newBase); 107 return newLocalBase.getTable(getTable()); 108 109 } 110 111 115 public void setTable(DatabaseTable table) { 116 this.table = table; 117 } 118 119 126 public Expression twistedForBaseAndContext(Expression newBase, Expression context) { 127 Expression twistedBase = getBaseExpression().twistedForBaseAndContext(newBase, context); 128 return twistedBase.getTable(getTable()); 129 130 } 131 132 136 public void writeDescriptionOn(BufferedWriter writer) throws IOException { 137 writer.write(getTable().toString()); 138 writer.write(tableAliasesDescription()); 139 } 140 } 141 | Popular Tags |