001 /* 002 Copyright (C) 2001-2003 Lionel Seinturier <Lionel.Seinturier@lip6.fr> 003 004 This program is free software; you can redistribute it and/or modify 005 it under the terms of the GNU Lesser General Public License as 006 published by the Free Software Foundation; either version 2 of the 007 License, or (at your option) any later version. 008 009 This program is distributed in the hope that it will be useful, 010 but WITHOUT ANY WARRANTY; without even the implied warranty of 011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 012 GNU Lesser General Public License for more details. 013 014 You should have received a copy of the GNU Lesser General Public License 015 along with this program; if not, write to the Free Software 016 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ 017 018 package org.objectweb.jac.aspects.distrans; 019 020 021 /** 022 * A struct to hold data source name data. 023 * 024 * @author Lionel Seinturier <Lionel.Seinturier@lip6.fr> 025 * @version 1.0 026 */ 027 028 public class DataSource { 029 030 public String driver; 031 public String url; 032 public String user; 033 public String password; 034 035 public DataSource( 036 String driver, String url, String user, String password ) { 037 038 this.driver = driver; 039 this.url = url; 040 this.user = user; 041 this.password = password; 042 } 043 044 public boolean equals( Object other ) { 045 if ( this == other ) return true; 046 if ( ! (other instanceof DataSource) ) return false; 047 048 DataSource dsother = (DataSource) other; 049 return ( dsother.driver.equals(driver) && 050 dsother.url.equals(url) && 051 dsother.user.equals(user) && 052 dsother.password.equals(password) ); 053 } 054 055 public String toString() { 056 return 057 super.toString() + 058 "[" + driver + "," + url + "," + user + "," + password + "]"; 059 } 060 061 public int hashCode() { 062 063 int h1 = (driver==null) ? 0 : driver.hashCode() & 255; 064 int h2 = (url==null) ? 0 : url.hashCode() & 255; 065 int h3 = (user==null) ? 0 : user.hashCode() & 255; 066 int h4 = (password==null) ? 0 : password.hashCode() & 255; 067 068 return (h1<<24) + (h2<<16) + (h3<<8) + h4; 069 } 070 }