01: /*
02:
03: Derby - Class org.apache.derby.impl.sql.catalog.TableKey
04:
05: Licensed to the Apache Software Foundation (ASF) under one or more
06: contributor license agreements. See the NOTICE file distributed with
07: this work for additional information regarding copyright ownership.
08: The ASF licenses this file to you under the Apache License, Version 2.0
09: (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: private final String tableName;
35: private final UUID schemaId;
36:
37: /**
38: * Constructor for when you have both the table and schema names.
39: *
40: * @param schemaUUID The UUID of the schema being referecned
41: * @param tableName The name of the table being referenced
42: */
43: TableKey(UUID schemaUUID, String tableName) {
44: this .tableName = tableName;
45: this .schemaId = schemaUUID;
46: }
47:
48: /**
49: * Get the table name (without the schema name).
50: *
51: * @return Table name as a String
52: */
53:
54: String getTableName() {
55: return tableName;
56: }
57:
58: /**
59: * Get the schema id.
60: *
61: * @return Schema id as a String
62: */
63:
64: UUID getSchemaId() {
65: return schemaId;
66: }
67:
68: /**
69: * 2 TableKeys are equal if their both their schemaIds and tableNames are
70: * equal.
71: *
72: * @param otherTableKey The other TableKey, as Object.
73: *
74: * @return boolean Whether or not the 2 TableKey are equal.
75: */
76: public boolean equals(Object otherTableKey) {
77: if (otherTableKey instanceof TableKey) {
78:
79: TableKey otk = (TableKey) otherTableKey;
80: if (tableName.equals(otk.tableName)
81: && schemaId.equals(otk.schemaId))
82: return true;
83: }
84: return false;
85: }
86:
87: public int hashCode() {
88: return tableName.hashCode();
89: }
90:
91: }
|