1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    * 
9    *      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  {
30      private String kind;
31      private ArrayList dbidCollection;
32      
33      public Dbms()
34      {
35          dbidCollection = new ArrayList();
36      }
37      
38      public Dbms(String kind) 
39      {
40          System.out.println("kind constructor called");
41          setKind(kind);
42      }
43      
44      public void addDbid(Dbid dbid)
45      {
46          dbidCollection.add(dbid);
47      }
48      
49      public List getDbids() {
50          return this.dbidCollection;
51      }
52  
53      public void setKind(String kind) 
54      {
55          this.kind = kind;
56      }
57      
58      public String getKind()
59      {
60          return this.kind;
61      }
62      
63      public boolean equals(Object object) 
64      {
65          if (object == null) {
66              return false;
67          }
68          
69          if (object instanceof Dbms) {
70              Dbms dbms = (Dbms) object;
71              if (dbms.getKind().equals(this.getKind())) {
72                  int count = 0;
73                  Iterator it = dbms.getDbids().iterator();
74                  while ( it.hasNext() ) {
75                      if (count >= dbidCollection.size() ) {
76                          return false;
77                      }
78                      if (! it.next().equals( dbidCollection.get(count++) ) ) {
79                          return false;
80                      }
81                  }
82                  
83                  return true;
84              }
85          }
86          return false;
87      }
88      
89      public String toString() {
90          return "[DBMS: name='" + getKind() + "']";
91      }
92  }
93