01: /**
02: * Sequoia: Database clustering technology.
03: * Copyright (C) 2002-2004 French National Institute For Research In Computer
04: * Science And Control (INRIA).
05: * Contact: sequoia@continuent.org
06: *
07: * Licensed under the Apache License, Version 2.0 (the "License");
08: * you may not use this file except in compliance with the License.
09: * 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): _________________________.
21: */package org.continuent.sequoia.controller.scheduler.schema;
22:
23: import org.continuent.sequoia.common.sql.schema.DatabaseTable;
24:
25: /**
26: * A <code>CacheDatabaseTable</code> represents a database table and its
27: * associated cache entries. It has an array of <code>CacheDatabaseColumn</code>
28: * objects.
29: * <p>
30: * Keep it mind that <code>ArrayList</code> is not synchronized...
31: *
32: * @author <a href="mailto:Emmanuel.Cecchet@inria.fr">Emmanuel Cecchet</a>
33: * @version 1.0
34: */
35: public class SchedulerDatabaseTable {
36: /** Database table name. */
37: private String name;
38:
39: private TransactionExclusiveLock lock = new TransactionExclusiveLock();
40:
41: /**
42: * Creates a new <code>CacheDatabaseTable</code> instance.
43: *
44: * @param databaseTable the database table
45: */
46: public SchedulerDatabaseTable(DatabaseTable databaseTable) {
47: // Clone the name and the columns
48: name = databaseTable.getName();
49: }
50:
51: /**
52: * Gets the name of the table.
53: *
54: * @return the table name
55: */
56: public String getName() {
57: return name;
58: }
59:
60: /**
61: * Returns the lock for this table.
62: *
63: * @return a <code>TransactionExclusiveLock</code> instance
64: * @see TransactionExclusiveLock
65: */
66: public TransactionExclusiveLock getLock() {
67: return lock;
68: }
69:
70: /**
71: * Two <code>CacheDatabaseColumn</code> are equals if they have the same
72: * name and the same columns.
73: *
74: * @param other the object to compare with
75: * @return true if the 2 objects are the same
76: */
77: public boolean equals(Object other) {
78: if ((other == null)
79: || !(other instanceof SchedulerDatabaseTable))
80: return false;
81: else
82: return name.equals(((SchedulerDatabaseTable) other)
83: .getName());
84: }
85:
86: /**
87: * Returns information about the database table and its columns.
88: *
89: * @param longFormat <code>true</code> for a long format, <code>false</code>
90: * for a short summary
91: * @return a <code>String</code> value
92: */
93: public String getInformation(boolean longFormat) {
94: return "Table " + name + ": ";
95: }
96: }
|