KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jac > aspects > distrans > DataSource


1 /*
2   Copyright (C) 2001-2003 Lionel Seinturier <Lionel.Seinturier@lip6.fr>
3
4   This program is free software; you can redistribute it and/or modify
5   it under the terms of the GNU Lesser General Public License as
6   published by the Free Software Foundation; either version 2 of the
7   License, or (at your option) any later version.
8
9   This program is distributed in the hope that it will be useful,
10   but WITHOUT ANY WARRANTY; without even the implied warranty of
11   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12   GNU Lesser General Public License for more details.
13
14   You should have received a copy of the GNU Lesser General Public License
15   along with this program; if not, write to the Free Software
16   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */

17
18 package org.objectweb.jac.aspects.distrans;
19
20
21 /**
22  * A struct to hold data source name data.
23  *
24  * @author Lionel Seinturier <Lionel.Seinturier@lip6.fr>
25  * @version 1.0
26  */

27
28 public class DataSource {
29     
30     public String JavaDoc driver;
31     public String JavaDoc url;
32     public String JavaDoc user;
33     public String JavaDoc password;
34     
35     public DataSource(
36         String JavaDoc driver, String JavaDoc url, String JavaDoc user, String JavaDoc password ) {
37         
38         this.driver = driver;
39         this.url = url;
40         this.user = user;
41         this.password = password;
42     }
43     
44     public boolean equals( Object JavaDoc other ) {
45         if ( this == other ) return true;
46         if ( ! (other instanceof DataSource) ) return false;
47
48         DataSource dsother = (DataSource) other;
49         return ( dsother.driver.equals(driver) &&
50                  dsother.url.equals(url) &&
51                  dsother.user.equals(user) &&
52                  dsother.password.equals(password) );
53     }
54
55     public String JavaDoc toString() {
56         return
57             super.toString() +
58             "[" + driver + "," + url + "," + user + "," + password + "]";
59     }
60
61     public int hashCode() {
62
63         int h1 = (driver==null) ? 0 : driver.hashCode() & 255;
64         int h2 = (url==null) ? 0 : url.hashCode() & 255;
65         int h3 = (user==null) ? 0 : user.hashCode() & 255;
66         int h4 = (password==null) ? 0 : password.hashCode() & 255;
67         
68         return (h1<<24) + (h2<<16) + (h3<<8) + h4;
69     }
70 }
71
Popular Tags