KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > impl > sql > catalog > TableKey


1 /*
2
3    Derby - Class org.apache.derby.impl.sql.catalog.TableKey
4
5    Licensed to the Apache Software Foundation (ASF) under one or more
6    contributor license agreements. See the NOTICE file distributed with
7    this work for additional information regarding copyright ownership.
8    The ASF licenses this file to you under the Apache License, Version 2.0
9    (the "License"); you may not use this file except in compliance with
10    the License. You may obtain a copy of the License at
11
12       http://www.apache.org/licenses/LICENSE-2.0
13
14    Unless required by applicable law or agreed to in writing, software
15    distributed under the License is distributed on an "AS IS" BASIS,
16    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17    See the License for the specific language governing permissions and
18    limitations under the License.
19
20  */

21
22 package org.apache.derby.impl.sql.catalog;
23
24 import org.apache.derby.catalog.UUID;
25
26 /**
27  * A TableKey represents a immutable unique identifier for a SQL object.
28  * It has a schemaid and a name .
29  *
30  * @author Jamie -- lifed from Comp/TableName
31  */

32
33 final class TableKey
34 {
35     private final String JavaDoc tableName;
36     private final UUID schemaId;
37
38
39     /**
40      * Constructor for when you have both the table and schema names.
41      *
42      * @param schemaUUID The UUID of the schema being referecned
43      * @param tableName The name of the table being referenced
44      */

45     TableKey(UUID schemaUUID, String JavaDoc tableName)
46     {
47         this.tableName = tableName;
48         this.schemaId = schemaUUID;
49     }
50
51     /**
52      * Get the table name (without the schema name).
53      *
54      * @return Table name as a String
55      */

56
57     String JavaDoc getTableName()
58     {
59         return tableName;
60     }
61
62     /**
63      * Get the schema id.
64      *
65      * @return Schema id as a String
66      */

67
68     UUID getSchemaId()
69     {
70         return schemaId;
71     }
72
73     /**
74      * 2 TableKeys are equal if their both their schemaIds and tableNames are
75      * equal.
76      *
77      * @param otherTableKey The other TableKey, as Object.
78      *
79      * @return boolean Whether or not the 2 TableKey are equal.
80      */

81     public boolean equals(Object JavaDoc otherTableKey)
82     {
83         if (otherTableKey instanceof TableKey) {
84
85             TableKey otk = (TableKey) otherTableKey;
86             if (tableName.equals(otk.tableName) && schemaId.equals(otk.schemaId))
87                 return true;
88         }
89         return false;
90     }
91
92     public int hashCode()
93     {
94         return tableName.hashCode();
95     }
96
97 }
98
Popular Tags