01: /*
02: * Copyright 2006 Le Duc Bao, Ralf Joachim
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License"); you may not
05: * use this file except in compliance with the License. You may obtain a copy of
06: * the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13: * License for the specific language governing permissions and limitations under
14: * the License.
15: */
16: package org.castor.ddlgen.schemaobject;
17:
18: import java.util.ArrayList;
19: import java.util.HashMap;
20: import java.util.List;
21: import java.util.Map;
22:
23: /**
24: * Abstract base class for all schemas.
25: *
26: * @author <a href="mailto:leducbao AT gmail DOT com">Le Duc Bao</a>
27: * @author <a href="mailto:ralf DOT joachim AT syscon DOT eu">Ralf Joachim</a>
28: * @version $Revision: 5951 $ $Date: 2006-04-25 16:09:10 -0600 (Tue, 25 Apr 2006) $
29: * @since 1.1
30: */
31: public abstract class Schema extends AbstractSchemaObject {
32: //--------------------------------------------------------------------------
33:
34: /** List of tables for this schema. */
35: private List _tables = new ArrayList();
36:
37: /** Map of tables assoizated with their name. */
38: private Map _tableMap = new HashMap();
39:
40: //--------------------------------------------------------------------------
41:
42: /**
43: * Add given table to list of tables.
44: *
45: * @param table Table to add to list of tables.
46: */
47: public final void addTable(final Table table) {
48: _tables.add(table);
49: _tableMap.put(table.getName(), table);
50: }
51:
52: /**
53: * Get number of tables.
54: *
55: * @return Number of tables.
56: */
57: public final int getTableCount() {
58: return _tables.size();
59: }
60:
61: /**
62: * Get table at given index.
63: *
64: * @param index Index of table to return.
65: * @return Table at given index.
66: */
67: public final Table getTable(final int index) {
68: return (Table) _tables.get(index);
69: }
70:
71: /**
72: * Get table with given name.
73: *
74: * @param name Name of table to return.
75: * @return Table with given name.
76: */
77: public final Table getTable(final String name) {
78: return (Table) _tableMap.get(name);
79: }
80:
81: //--------------------------------------------------------------------------
82: }
|