01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: package org.apache.commons.betwixt.schema;
19:
20: import java.util.ArrayList;
21: import java.util.Iterator;
22: import java.util.List;
23:
24: /**
25: * @author <a href="mailto:martin@mvdb.net">Martin van den Bemt</a>
26: * @version $Id: PhysicalSchema.java 438373 2006-08-30 05:17:21Z bayard $
27: */
28: public class PhysicalSchema {
29:
30: private ArrayList dbmsCollection;
31:
32: private boolean autoCreate = false;
33:
34: public PhysicalSchema() {
35: dbmsCollection = new ArrayList();
36: }
37:
38: public PhysicalSchema(String autoCreate) {
39: this .autoCreate = autoCreate.equalsIgnoreCase("yes");
40: }
41:
42: public void setAutocreate(String autoCreate) {
43: this .autoCreate = (autoCreate.equalsIgnoreCase("yes"));
44: }
45:
46: public String getAutocreate() {
47: return this .autoCreate ? "yes" : "no";
48: }
49:
50: public void addDbms(Dbms dbms) {
51: dbmsCollection.add(dbms);
52: }
53:
54: public List getDbmss() {
55: return dbmsCollection;
56: }
57:
58: public boolean equals(Object object) {
59: if (object == null) {
60: return false;
61: }
62: if (object instanceof PhysicalSchema) {
63: PhysicalSchema schema = (PhysicalSchema) object;
64: if (schema.getAutocreate().equals(this .getAutocreate())) {
65: int count = 0;
66: Iterator it = schema.getDbmss().iterator();
67: while (it.hasNext()) {
68: if (count >= dbmsCollection.size()) {
69: return false;
70: }
71: if (!it.next().equals(dbmsCollection.get(count++))) {
72: return false;
73: }
74: }
75:
76: return true;
77: }
78: }
79: return false;
80: }
81:
82: public String toString() {
83: return "[PhysicalSchema] autocreate=" + getAutocreate()
84: + " dbmass=" + getDbmss();
85: }
86: }
|