001: /**
002: * Copyright (C) 2006 NetMind Consulting Bt.
003: *
004: * This library is free software; you can redistribute it and/or
005: * modify it under the terms of the GNU Lesser General Public
006: * License as published by the Free Software Foundation; either
007: * version 3 of the License, or (at your option) any later version.
008: *
009: * This library is distributed in the hope that it will be useful,
010: * but WITHOUT ANY WARRANTY; without even the implied warranty of
011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012: * Lesser General Public License for more details.
013: *
014: * You should have received a copy of the GNU Lesser General Public
015: * License along with this library; if not, write to the Free Software
016: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
017: */package hu.netmind.persistence.parser;
018:
019: import java.util.List;
020: import java.util.Vector;
021:
022: /**
023: * This class represents a table identifier.
024: * @author Brautigam Robert
025: * @version Revision: $Revision$
026: */
027: public class TableTerm {
028: private String alias;
029: private String tableName;
030: private List leftTableTerms;
031:
032: public TableTerm(TableTerm source) {
033: alias = source.alias;
034: tableName = source.tableName;
035: leftTableTerms = source.leftTableTerms;
036: }
037:
038: public TableTerm(String tableName, String alias) {
039: setLeftTableTerms(new Vector());
040: setTableName(tableName);
041: setAlias(alias);
042: }
043:
044: public TableTerm(String tableName, String alias, List leftTableTerms) {
045: setLeftTableTerms(leftTableTerms);
046: setTableName(tableName);
047: setAlias(alias);
048: }
049:
050: public TableTerm deepCopy() {
051: TableTerm result = new TableTerm(this );
052: result.setLeftTableTerms(new Vector(leftTableTerms));
053: return result;
054: }
055:
056: public String getName() {
057: return (alias == null) ? tableName : alias;
058: }
059:
060: public String getAlias() {
061: return alias;
062: }
063:
064: public void setAlias(String alias) {
065: this .alias = alias;
066: }
067:
068: public String getTableName() {
069: return tableName;
070: }
071:
072: public void setTableName(String tableName) {
073: this .tableName = tableName;
074: }
075:
076: public List getLeftTableTerms() {
077: return leftTableTerms;
078: }
079:
080: public void setLeftTableTerms(List leftTableTerms) {
081: this .leftTableTerms = leftTableTerms;
082: if (this .leftTableTerms == null)
083: this .leftTableTerms = new Vector();
084: }
085:
086: public int hashCode() {
087: return toString().hashCode();
088: }
089:
090: public boolean equals(Object rhs) {
091: if (!(rhs instanceof TableTerm))
092: return false;
093: TableTerm t = (TableTerm) rhs;
094: return (tableName.equals(t.tableName))
095: && (((alias == null) && (t.alias == null)) || ((alias != null) && (alias
096: .equals(t.alias))));
097: }
098:
099: public String toString() {
100: return "[TableTerm: " + tableName + " ("
101: + (alias == null ? "no alias" : ("'" + alias + "'"))
102: + ")]";
103: }
104: }
|