Main Page | Packages | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

DatabaseUser.java

00001 /**
00002  * C-JDBC: Clustered JDBC.
00003  * Copyright (C) 2002-2004 French National Institute For Research In Computer
00004  * Science And Control (INRIA).
00005  * Contact: c-jdbc@objectweb.org
00006  * 
00007  * This library is free software; you can redistribute it and/or modify it
00008  * under the terms of the GNU Lesser General Public License as published by the
00009  * Free Software Foundation; either version 2.1 of the License, or any later
00010  * version.
00011  * 
00012  * This library is distributed in the hope that it will be useful, but WITHOUT
00013  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00014  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
00015  * for more details.
00016  * 
00017  * You should have received a copy of the GNU Lesser General Public License
00018  * along with this library; if not, write to the Free Software Foundation,
00019  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
00020  *
00021  * Initial developer(s): Julie Marguerite.
00022  * Contributor(s): Mathieu Peltier.
00023  */
00024 
00025 package org.objectweb.cjdbc.driver;
00026 
00027 import java.io.Serializable;
00028 
00029 /**
00030  * A <code>DatabaseUser</code> is just a login/password combination to
00031  * represent database user.
00032  * 
00033  * @author <a href="mailto:Julie.Marguerite@inria.fr">Julie Marguerite</a>
00034  * @author <a href="Mathieu.Peltier@inrialpes.fr">Mathieu Peltier</a>
00035  * @version 1.0
00036  */
00037 public class DatabaseUser implements Serializable
00038 {
00039   /** Virtual database name. */
00040   private String dbName;
00041 
00042   /** User name. */
00043   private String login;
00044 
00045   /** Password. */
00046   private String password;
00047 
00048   /**
00049    * Creates a new <code>DatabaseUser</code> instance.
00050    * 
00051    * @param dbName The virtual database name
00052    * @param login User name
00053    * @param password Password
00054    */
00055   public DatabaseUser(String dbName, String login, String password)
00056   {
00057     this.dbName = dbName;
00058     this.login = login;
00059     this.password = password;
00060   }
00061 
00062   /**
00063    * Tests if the virtual database name login and password provided matches the
00064    * virtual database name/login/password of this object.
00065    * 
00066    * @param dbName virtual database name
00067    * @param login a user name
00068    * @param password a password
00069    * @return <code>true</code> if it matches this object's virtual database
00070    *         name/login/password
00071    */
00072   public boolean matches(String dbName, String login, String password)
00073   {
00074     return (
00075       this.dbName.equals(dbName)
00076         && this.login.equals(login)
00077         && this.password.equals(password));
00078   }
00079 
00080   /**
00081    * Compares an object with this object.
00082    * 
00083    * @param other an <code>Object</code>
00084    * @return <code>true</code> if both objects have same virtual database
00085    *         name, login and password
00086    */
00087   public boolean equals(Object other)
00088   {
00089     if (!(other instanceof DatabaseUser))
00090       return false;
00091 
00092     DatabaseUser castOther = (DatabaseUser) other;
00093     return matches(castOther.dbName, castOther.login, castOther.password);
00094   }
00095 
00096   /**
00097    * Returns the virtual database name.
00098    * 
00099    * @return database name
00100    */
00101   public String getDbName()
00102   {
00103     return dbName;
00104   }
00105 
00106   /**
00107    * Gets the login name.
00108    * 
00109    * @return login name
00110    */
00111   public String getLogin()
00112   {
00113     return login;
00114   }
00115 
00116   /**
00117    * Gets the password.
00118    * 
00119    * @return password
00120    */
00121   public String getPassword()
00122   {
00123     return password;
00124   }
00125 }

Generated on Mon Apr 11 22:01:31 2005 for C-JDBC by  doxygen 1.3.9.1