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.Vector;
020:
021: /**
022: * This refers to a table's attribute.
023: * @author Brautigam Robert
024: * @version Revision: $Revision$
025: */
026: public class ReferenceTerm extends TableTerm {
027: private String columnName;
028: private String columnAlias;
029: private boolean id = false;
030:
031: public boolean isId() {
032: return id;
033: }
034:
035: public void setId() {
036: this .id = true;
037: }
038:
039: public ReferenceTerm(ReferenceTerm source) {
040: super (source);
041: columnName = source.columnName;
042: columnAlias = source.columnAlias;
043: }
044:
045: public ReferenceTerm(TableTerm term, String columnName) {
046: super (term);
047: setColumnName(columnName);
048: }
049:
050: public ReferenceTerm(TableTerm term, String columnName,
051: String columnAlias) {
052: super (term);
053: setColumnName(columnName);
054: setColumnAlias(columnAlias);
055: }
056:
057: public ReferenceTerm(String tableName, String alias,
058: String columnName) {
059: super (tableName, alias);
060: setColumnName(columnName);
061: }
062:
063: public TableTerm deepCopy() {
064: ReferenceTerm result = new ReferenceTerm(this );
065: result.setLeftTableTerms(new Vector(getLeftTableTerms()));
066: return result;
067: }
068:
069: public String getColumnName() {
070: return columnName;
071: }
072:
073: public void setColumnName(String columnName) {
074: this .columnName = columnName;
075: }
076:
077: public String getColumnAlias() {
078: return columnAlias;
079: }
080:
081: public void setColumnAlias(String columnAlias) {
082: this .columnAlias = columnAlias;
083: }
084:
085: public String getColumnFinalName() {
086: if (columnAlias == null)
087: return columnName;
088: else
089: return columnAlias;
090: }
091:
092: public int hashCode() {
093: return super .toString().hashCode();
094: }
095:
096: public String toString() {
097: return super .toString() + "." + columnName + " ("
098: + (columnAlias == null ? "no alias" : columnAlias)
099: + ")";
100: }
101: }
|