001: /*
002: * sqlc 1
003: * SQL Compiler
004: * Copyright (C) 2003 Hammurapi Group
005: *
006: * This program is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2 of the License, or (at your option) any later version.
010: *
011: * This program is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
019: *
020: * URL: http://www.hammurapi.biz/products/sqlc/index.html
021: * e-Mail: support@hammurapi.biz
022: */
023: package biz.hammurapi.sql.metadata;
024:
025: import java.io.Serializable;
026:
027: /**
028: * @author Pavel Vlasov
029: * @version $Revision: 1.3 $
030: */
031: public class KeyEntry implements Comparable, Serializable, DbParameter {
032: /**
033: * Comment for <code>serialVersionUID</code>
034: */
035: private static final long serialVersionUID = -1263961813741480088L;
036: private TableDescriptor tableDescriptor;
037:
038: KeyEntry(TableDescriptor tableDescriptor) {
039: this .tableDescriptor = tableDescriptor;
040: }
041:
042: private String columnName;
043: private int columnSequence;
044: private boolean isDescending;
045:
046: public boolean equals(Object arg) {
047: return (arg == this || (arg instanceof KeyEntry && ((KeyEntry) arg)
048: .getColumnSequence() == getColumnSequence()));
049: }
050:
051: public int compareTo(Object arg) {
052: if (arg == this ) {
053: return 0;
054: } else if (arg instanceof KeyEntry) {
055: return getColumnSequence()
056: - ((KeyEntry) arg).getColumnSequence();
057: } else {
058: return 1;
059: }
060: }
061:
062: public String getName() {
063: return getColumnDescriptor().getName();
064: }
065:
066: private ColumnDescriptor getColumnDescriptor() {
067: return (ColumnDescriptor) tableDescriptor.columnDescriptorsMap
068: .get(getColumnName());
069: }
070:
071: public String getType() {
072: return getColumnDescriptor().getType();
073: }
074:
075: public int getDbType() {
076: return ((ColumnDescriptor) tableDescriptor.columnDescriptorsMap
077: .get(getColumnName())).getDbType();
078: }
079:
080: /**
081: * @param columnName The columnName to set.
082: */
083: void setColumnName(String columnName) {
084: this .columnName = columnName;
085: }
086:
087: /**
088: * @return Returns the columnName.
089: */
090: public String getColumnName() {
091: return columnName;
092: }
093:
094: /**
095: * @param columnSequence The columnSequence to set.
096: */
097: void setColumnSequence(int columnSequence) {
098: this .columnSequence = columnSequence;
099: }
100:
101: /**
102: * @return Returns the columnSequence.
103: */
104: int getColumnSequence() {
105: return columnSequence;
106: }
107:
108: /**
109: * @param isDescending The isDescending to set.
110: */
111: void setDescending(boolean isDescending) {
112: this .isDescending = isDescending;
113: }
114:
115: /**
116: * @return Returns the isDescending.
117: */
118: public boolean isDescending() {
119: return isDescending;
120: }
121: }
|