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: Dbms.java 438373 2006-08-30 05:17:21Z bayard $
27: */
28: public class Dbms {
29: private String kind;
30: private ArrayList dbidCollection;
31:
32: public Dbms() {
33: dbidCollection = new ArrayList();
34: }
35:
36: public Dbms(String kind) {
37: System.out.println("kind constructor called");
38: setKind(kind);
39: }
40:
41: public void addDbid(Dbid dbid) {
42: dbidCollection.add(dbid);
43: }
44:
45: public List getDbids() {
46: return this .dbidCollection;
47: }
48:
49: public void setKind(String kind) {
50: this .kind = kind;
51: }
52:
53: public String getKind() {
54: return this .kind;
55: }
56:
57: public boolean equals(Object object) {
58: if (object == null) {
59: return false;
60: }
61:
62: if (object instanceof Dbms) {
63: Dbms dbms = (Dbms) object;
64: if (dbms.getKind().equals(this .getKind())) {
65: int count = 0;
66: Iterator it = dbms.getDbids().iterator();
67: while (it.hasNext()) {
68: if (count >= dbidCollection.size()) {
69: return false;
70: }
71: if (!it.next().equals(dbidCollection.get(count++))) {
72: return false;
73: }
74: }
75:
76: return true;
77: }
78: }
79: return false;
80: }
81:
82: public String toString() {
83: return "[DBMS: name='" + getKind() + "']";
84: }
85: }
|