KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > gjc > spi > ConnectionRequestInfo


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23  
24 package com.sun.gjc.spi;
25
26 /**
27  * ConnectionRequestInfo implementation for Generic JDBC Connector.
28  *
29  * @version 1.0, 02/07/31
30  * @author Binod P.G
31  */

32 public class ConnectionRequestInfo implements javax.resource.spi.ConnectionRequestInfo JavaDoc{
33
34     private String JavaDoc user;
35     private String JavaDoc password;
36
37     /**
38      * Constructs a new <code>ConnectionRequestInfo</code> object
39      *
40      * @param user User Name.
41      * @param password Password
42      */

43     public ConnectionRequestInfo(String JavaDoc user, String JavaDoc password) {
44         this.user = user;
45         this.password = password;
46     }
47
48     /**
49      * Retrieves the user name of the ConnectionRequestInfo.
50      *
51      * @return User name of ConnectionRequestInfo.
52      */

53     public String JavaDoc getUser() {
54         return user;
55     }
56
57     /**
58      * Retrieves the password of the ConnectionRequestInfo.
59      *
60      * @return Password of ConnectionRequestInfo.
61      */

62     public String JavaDoc getPassword() {
63         return password;
64     }
65
66     /**
67      * Verify whether two ConnectionRequestInfos are equal.
68      *
69      * @return True, if they are equal and false otherwise.
70      */

71     public boolean equals(Object JavaDoc obj) {
72         if (obj == null) return false;
73         if (obj instanceof ConnectionRequestInfo) {
74             ConnectionRequestInfo other = (ConnectionRequestInfo) obj;
75             return (isEqual(this.user, other.user) &&
76                     isEqual(this.password, other.password));
77         } else {
78             return false;
79         }
80     }
81
82     /**
83      * Retrieves the hashcode of the object.
84      *
85      * @return hashCode.
86      */

87     public int hashCode() {
88         String JavaDoc result = "" + user + password;
89         return result.hashCode();
90     }
91     
92     /**
93      * Compares two objects.
94      *
95      * @param o1 First object.
96      * @param o2 Second object.
97      */

98     private boolean isEqual(Object JavaDoc o1, Object JavaDoc o2) {
99         if (o1 == null) {
100             return (o2 == null);
101         } else {
102             return o1.equals(o2);
103         }
104     }
105
106 }
Popular Tags