KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > betwixt > schema > Dbms


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 JavaDoc;
20 import java.util.Iterator JavaDoc;
21 import java.util.List JavaDoc;
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 JavaDoc kind;
30     private ArrayList JavaDoc dbidCollection;
31     
32     public Dbms()
33     {
34         dbidCollection = new ArrayList JavaDoc();
35     }
36     
37     public Dbms(String JavaDoc 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 JavaDoc getDbids() {
49         return this.dbidCollection;
50     }
51
52     public void setKind(String JavaDoc kind)
53     {
54         this.kind = kind;
55     }
56     
57     public String JavaDoc getKind()
58     {
59         return this.kind;
60     }
61     
62     public boolean equals(Object JavaDoc 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 JavaDoc 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 JavaDoc toString() {
89         return "[DBMS: name='" + getKind() + "']";
90     }
91 }
92
93
Popular Tags