KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > cjdbc > common > sql > schema > TableColumn


1 /**
2  * C-JDBC: Clustered JDBC.
3  * Copyright (C) 2002-2004 French National Institute For Research In Computer
4  * Science And Control (INRIA).
5  * Contact: c-jdbc@objectweb.org
6  *
7  * This library is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU Lesser General Public License as published by the
9  * Free Software Foundation; either version 2.1 of the License, or any later
10  * version.
11  *
12  * This library is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
15  * for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with this library; if not, write to the Free Software Foundation,
19  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
20  *
21  * Initial developer(s): Emmanuel Cecchet.
22  * Contributor(s): Mathieu Peltier.
23  */

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

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

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

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

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

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

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

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