1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.betwixt.schema;
18
19 import java.util.ArrayList;
20 import java.util.Iterator;
21 import java.util.List;
22
23 /***
24 * @author <a href="mailto:martin@mvdb.net">Martin van den Bemt</a>
25 * @version $Id: PhysicalSchema.java,v 1.7 2004/02/28 13:38:36 yoavs Exp $
26 */
27 public class PhysicalSchema
28 {
29
30 private ArrayList dbmsCollection;
31
32
33 private boolean autoCreate = false;
34
35 public PhysicalSchema()
36 {
37 dbmsCollection = new ArrayList();
38 }
39 public PhysicalSchema(String autoCreate)
40 {
41 this.autoCreate = autoCreate.equalsIgnoreCase("yes");
42 }
43 public void setAutocreate(String autoCreate)
44 {
45 this.autoCreate = (autoCreate.equalsIgnoreCase("yes"));
46 }
47
48 public String getAutocreate()
49 {
50 return this.autoCreate?"yes":"no";
51 }
52
53 public void addDbms(Dbms dbms)
54 {
55 dbmsCollection.add(dbms);
56 }
57
58 public List getDbmss()
59 {
60 return dbmsCollection;
61 }
62
63 public boolean equals(Object object)
64 {
65 if (object == null) {
66 return false;
67 }
68 if (object instanceof PhysicalSchema) {
69 PhysicalSchema schema = (PhysicalSchema) object;
70 if (schema.getAutocreate().equals(this.getAutocreate())) {
71 int count = 0;
72 Iterator it = schema.getDbmss().iterator();
73 while ( it.hasNext() ) {
74 if (count >= dbmsCollection.size() ) {
75 return false;
76 }
77 if (! it.next().equals( dbmsCollection.get(count++) ) ) {
78 return false;
79 }
80 }
81
82 return true;
83 }
84 }
85 return false;
86 }
87
88 public String toString() {
89 return "[PhysicalSchema] autocreate=" + getAutocreate() + " dbmass=" + getDbmss();
90 }
91 }
92