KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > continuent > sequoia > controller > sql > schema > TableColumn


1 /**
2  * Sequoia: Database clustering technology.
3  * Copyright (C) 2002-2004 French National Institute For Research In Computer
4  * Science And Control (INRIA).
5  * Contact: sequoia@continuent.org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  * Initial developer(s): Emmanuel Cecchet.
20  * Contributor(s): Mathieu Peltier.
21  */

22
23 package org.continuent.sequoia.controller.sql.schema;
24
25 /**
26  * A <code>TableColumn</code> is used to carry parsing information and
27  * contains a database table name and one of its column.
28  *
29  * @author <a HREF="mailto:Emmanuel.Cecchet@inria.fr">Emmanuel Cecchet</a>
30  * @author <a HREF="mailto:Mathieu.Peltier@inrialpes.fr">Mathieu Peltier</a>
31  * @version 1.0
32  */

33 public class TableColumn
34 {
35   /** The table name. */
36   private String JavaDoc tableName;
37
38   /** The column name. */
39   private String JavaDoc columnName;
40
41   /**
42    * Creates a new <code>TableColumn</code>.
43    *
44    * @param tableName the table name
45    * @param columnName the column name
46    */

47   public TableColumn(String JavaDoc tableName, String JavaDoc columnName)
48   {
49     if (tableName == null)
50       throw new IllegalArgumentException JavaDoc("Illegal null table name in TableColumn constructor");
51
52     if (columnName == null)
53       throw new IllegalArgumentException JavaDoc("Illegal null column name in TableColumn constructor");
54
55     this.tableName = tableName;
56     this.columnName = columnName;
57   }
58
59   /**
60    * Returns the column name.
61    *
62    * @return the column name.
63    */

64   public String JavaDoc getColumnName()
65   {
66     return columnName;
67   }
68
69   /**
70    * Returns the table name.
71    *
72    * @return the table name.
73    */

74   public String JavaDoc getTableName()
75   {
76     return tableName;
77   }
78
79   /**
80    * Sets the column name.
81    *
82    * @param columnName the column to set
83    */

84   public void setColumnName(String JavaDoc columnName)
85   {
86     this.columnName = columnName;
87   }
88
89   /**
90    * Sets the table name.
91    *
92    * @param tableName the table to set
93    */

94   public void setTableName(String JavaDoc tableName)
95   {
96     this.tableName = tableName;
97   }
98
99   /**
100    * Two <code>TableColumn</code> objects are considered equal if they have
101    * the same name and belong to the same table.
102    *
103    * @param other the object to compare with
104    * @return true if the 2 objects are the same
105    */

106   public boolean equals(Object JavaDoc other)
107   {
108     if ((other == null) || !(other instanceof TableColumn))
109       return false;
110
111     TableColumn c = (TableColumn) other;
112     return columnName.equals(c.getColumnName())
113       && tableName.equals(c.getTableName());
114   }
115 }
116
Popular Tags