01: /**
02: * Copyright (C) 2001-2005 France Telecom R&D
03: */package org.objectweb.speedo.metadata;
04:
05: import java.util.ArrayList;
06: import java.util.Iterator;
07: import java.util.List;
08:
09: public class SpeedoTable extends SpeedoElement {
10: /**
11: * The name of the table.
12: */
13: public String name;
14:
15: /**
16: * The catalog of the table (null if none).
17: */
18: public String catalog;
19:
20: /**
21: * The schema of the table (null if none).
22: */
23: public String schema;
24:
25: /**
26: * If it is a secondary table, specify the join with the main table.
27: */
28: public SpeedoJoin join;
29:
30: /**
31: * List of SpeedoIndexes
32: */
33: public List indexes = new ArrayList();
34:
35: /**
36: * A list of unique constraints associated with the table.
37: */
38: public ArrayList uniqueConstraints = new ArrayList();
39:
40: public SpeedoTable() {
41: SpeedoDefaults.setDefaults(this );
42: }
43:
44: /**
45: * Add a new unique constraint to this table. If it already exist, ignored.
46: * @param cols The list of columns specifying the constraint.
47: * @return false if it was already defined.
48: */
49: public boolean addUniqueConstraint(ArrayList cols) {
50: Iterator it = uniqueConstraints.iterator();
51: while (it.hasNext()) {
52: ArrayList al = (ArrayList) it.next();
53: Iterator it1 = cols.iterator();
54: Iterator it2 = al.iterator();
55: while (it1.hasNext() && it2.hasNext()) {
56: if (it1.next() != it2.next()) {
57: break;
58: }
59: }
60: if (it1.hasNext() || it2.hasNext()) {
61: continue;
62: }
63: return false;
64: }
65: uniqueConstraints.add(cols);
66: return true;
67: }
68:
69: public boolean isMain() {
70: return join == null;
71: }
72: }
|