1 17 package org.apache.ws.jaxme.sqls.impl; 18 19 import java.util.ArrayList ; 20 import java.util.List ; 21 22 import org.apache.ws.jaxme.sqls.Column; 23 import org.apache.ws.jaxme.sqls.ColumnReference; 24 import org.apache.ws.jaxme.sqls.Statement; 25 import org.apache.ws.jaxme.sqls.Table; 26 import org.apache.ws.jaxme.sqls.TableReference; 27 28 29 33 public class TableReferenceImpl implements TableReference { 34 private Statement statement; 35 private Table table; 36 private Table.Name alias; 37 private List columnReferences = new ArrayList (); 38 39 41 TableReferenceImpl(Statement pStatement, Table pTable) { 42 statement = pStatement; 43 table = pTable; 44 } 45 46 public Statement getStatement() { 47 return statement; 48 } 49 50 public Table getTable() { 51 return table; 52 } 53 54 public Table.Name getAlias() { 55 return alias; 56 } 57 58 public void setAlias(Table.Name pName) { 59 alias = pName; 60 } 61 62 public void setAlias(String pName) { 63 setAlias(new TableImpl.NameImpl(pName)); 64 } 65 66 public ColumnReference newColumnReference(String pName) { 67 return newColumnReference(new ColumnImpl.NameImpl(pName)); 68 } 69 70 public ColumnReference newColumnReference(Column.Name pName) { 71 Column column = getTable().getColumn(pName); 72 if (column == null) { 73 throw new NullPointerException ("Unknown column name in table " + getTable().getName() + 74 ": " + pName); 75 } 76 return newColumnReference(column); 77 } 78 79 public ColumnReference newColumnReference(Column pColumn) { 80 ColumnReference columnReference = getStatement().getSQLFactory().getObjectFactory().newColumnReference(this, pColumn); 81 columnReferences.add(columnReference); 82 return columnReference; 83 } 84 85 public boolean equals(Object o) { 86 if (o == null || !(o instanceof TableReference)) { 87 return false; 88 } 89 TableReference ref = (TableReference) o; 90 return ref.getStatement().equals(getStatement()) && 91 ref.getTable().equals(getTable()); 92 } 93 94 public int hashCode() { 95 return getStatement().hashCode() + getTable().hashCode(); 96 } 97 } 98 | Popular Tags |