1   /*
2    * Copyright 2001-2004 The Apache Software Foundation.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
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: Dbms.java,v 1.6 2004/02/28 13:38:36 yoavs Exp $
26   */
27  public class Dbms
28  {
29      private String kind;
30      private ArrayList dbidCollection;
31      
32      public Dbms()
33      {
34          dbidCollection = new ArrayList();
35      }
36      
37      public Dbms(String kind) 
38      {
39          System.out.println("kind constructor called");
40          setKind(kind);
41      }
42      
43      public void addDbid(Dbid dbid)
44      {
45          dbidCollection.add(dbid);
46      }
47      
48      public List getDbids() {
49          return this.dbidCollection;
50      }
51  
52      public void setKind(String kind) 
53      {
54          this.kind = kind;
55      }
56      
57      public String getKind()
58      {
59          return this.kind;
60      }
61      
62      public boolean equals(Object object) 
63      {
64          if (object == null) {
65              return false;
66          }
67          
68          if (object instanceof Dbms) {
69              Dbms dbms = (Dbms) object;
70              if (dbms.getKind().equals(this.getKind())) {
71                  int count = 0;
72                  Iterator it = dbms.getDbids().iterator();
73                  while ( it.hasNext() ) {
74                      if (count >= dbidCollection.size() ) {
75                          return false;
76                      }
77                      if (! it.next().equals( dbidCollection.get(count++) ) ) {
78                          return false;
79                      }
80                  }
81                  
82                  return true;
83              }
84          }
85          return false;
86      }
87      
88      public String toString() {
89          return "[DBMS: name='" + getKind() + "']";
90      }
91  }
92