KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > continuent > sequoia > driver > DatabaseUser


1 /**
2  * Sequoia: Database clustering technology.
3  * Copyright (C) 2002-2004 French National Institute For Research In Computer
4  * Science And Control (INRIA).
5  * Copyright (C) 2005 AmicoSoft, Inc. dba Emic Networks
6  * Contact: sequoia@continuent.org
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  * Initial developer(s): Julie Marguerite.
21  * Contributor(s): Mathieu Peltier.
22  */

23
24 package org.continuent.sequoia.driver;
25
26 import java.io.Serializable JavaDoc;
27
28 /**
29  * A <code>DatabaseUser</code> is just a login/password combination to
30  * represent database user.
31  *
32  * @author <a HREF="mailto:Julie.Marguerite@inria.fr">Julie Marguerite</a>
33  * @author <a HREF="Mathieu.Peltier@inrialpes.fr">Mathieu Peltier</a>
34  * @version 1.0
35  */

36 public class DatabaseUser implements Serializable JavaDoc
37 {
38   private static final long serialVersionUID = 4733183236454586066L;
39
40   /** Virtual database name. */
41   private String JavaDoc dbName;
42
43   /** User name. */
44   private String JavaDoc login;
45
46   /** Password. */
47   private String JavaDoc password;
48
49   /**
50    * Creates a new <code>DatabaseUser</code> instance.
51    *
52    * @param dbName The virtual database name
53    * @param login User name
54    * @param password Password
55    */

56   public DatabaseUser(String JavaDoc dbName, String JavaDoc login, String JavaDoc password)
57   {
58     this.dbName = dbName;
59     this.login = login;
60     this.password = password;
61   }
62
63   /**
64    * Tests if the virtual database name login and password provided matches the
65    * virtual database name/login/password of this object.
66    *
67    * @param dbName virtual database name
68    * @param login a user name
69    * @param password a password
70    * @return <code>true</code> if it matches this object's virtual database
71    * name/login/password
72    */

73   public boolean matches(String JavaDoc dbName, String JavaDoc login, String JavaDoc password)
74   {
75     return (this.dbName.equals(dbName) && this.login.equals(login) && this.password
76         .equals(password));
77   }
78
79   /**
80    * Compares an object with this object.
81    *
82    * @param other an <code>Object</code>
83    * @return <code>true</code> if both objects have same virtual database
84    * name, login and password
85    */

86   public boolean equals(Object JavaDoc other)
87   {
88     if (!(other instanceof DatabaseUser))
89       return false;
90
91     DatabaseUser castOther = (DatabaseUser) other;
92     return matches(castOther.dbName, castOther.login, castOther.password);
93   }
94
95   /**
96    * Returns the virtual database name.
97    *
98    * @return database name
99    */

100   public String JavaDoc getDbName()
101   {
102     return dbName;
103   }
104
105   /**
106    * Gets the login name.
107    *
108    * @return login name
109    */

110   public String JavaDoc getLogin()
111   {
112     return login;
113   }
114
115   /**
116    * Gets the password.
117    *
118    * @return password
119    */

120   public String JavaDoc getPassword()
121   {
122     return password;
123   }
124 }
125
Popular Tags