KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > sun > share > serverresources > SunDatasource


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 /*
20  * SunDatasource.java
21  *
22  * Created on March 18, 2006, 5:56 PM
23  *
24  */

25
26 package org.netbeans.modules.j2ee.sun.share.serverresources;
27
28 import java.io.File JavaDoc;
29 import org.netbeans.modules.j2ee.deployment.common.api.Datasource;
30 import org.openide.util.NbBundle;
31
32 /**
33  *
34  * @author Nitya Doraisamy
35  */

36 public class SunDatasource implements Datasource{
37     private String JavaDoc jndiName;
38     private String JavaDoc url;
39     private String JavaDoc username;
40     private String JavaDoc password;
41     private String JavaDoc driverClassName;
42     private File JavaDoc resourceDir;
43   
44     private volatile int hash = -1;
45     
46     /** Creates a new instance of SunDatasource */
47     public SunDatasource(String JavaDoc jndiName, String JavaDoc url, String JavaDoc username, String JavaDoc password, String JavaDoc driverClassName) {
48         this.jndiName = jndiName;
49         this.url = url;
50         this.username = username;
51         this.password = password;
52         this.driverClassName = driverClassName;
53     }
54
55     public String JavaDoc getJndiName() {
56         return jndiName;
57     }
58
59     public String JavaDoc getUrl() {
60         return url;
61     }
62
63     public String JavaDoc getUsername() {
64         return username;
65     }
66
67     public String JavaDoc getPassword() {
68         return password;
69     }
70
71     public String JavaDoc getDriverClassName() {
72         return driverClassName;
73     }
74
75     public String JavaDoc getDisplayName() {
76         return jndiName;
77     }
78
79     public boolean equals(Object JavaDoc obj) {
80         if (this == obj){
81             return true;
82         }
83         if (!(obj instanceof SunDatasource)){
84             return false;
85         }
86         
87         SunDatasource ds = (SunDatasource)obj;
88         if (jndiName == null && ds.getJndiName() != null || jndiName != null && !jndiName.equals(ds.getJndiName())){
89             return false;
90         }
91         if (url == null && ds.getUrl() != null || url != null && !url.equals(ds.getUrl())){
92             return false;
93         }
94         if (username == null && ds.getUsername() != null || username != null && !username.equals(ds.getUsername())){
95             return false;
96         }
97         if (password == null && ds.getPassword() != null || password != null && !password.equals(ds.getPassword())){
98             return false;
99         }
100         if (driverClassName == null && ds.getDriverClassName() != null || driverClassName != null && !driverClassName.equals(ds.getDriverClassName())){
101             return false;
102         }
103        
104         return true;
105     }
106     
107     public String JavaDoc toString() {
108         return "[ " + // NOI18N
109
NbBundle.getMessage(SunDatasource.class, "LBL_JNDI") + ": '" + jndiName + "', " + // NOI18N
110
NbBundle.getMessage(SunDatasource.class, "LBL_URL") + ": '" + url + "', " + // NOI18N
111
NbBundle.getMessage(SunDatasource.class, "LBL_USER") + ": '" + username + "', " + // NOI18N
112
NbBundle.getMessage(SunDatasource.class, "LBL_PASS") + ": '" + password + "', " + // NOI18N
113
NbBundle.getMessage(SunDatasource.class, "LBL_DRV") + ": '" + driverClassName + "' ]"; // NOI18N
114
}
115     
116     public int hashCode() {
117         if (hash == -1) {
118             int result = 17;
119             result += 37 * result + (jndiName == null ? 0 : jndiName.hashCode());
120             result += 37 * result + (url == null ? 0 : url.hashCode());
121             result += 37 * result + (username == null ? 0 : username.hashCode());
122             result += 37 * result + (password == null ? 0 : password.hashCode());
123             result += 37 * result + (driverClassName == null ? 0 : driverClassName.hashCode());
124             hash = result;
125         }
126         return hash;
127     }
128
129     public File JavaDoc getResourceDir() {
130         return resourceDir;
131     }
132
133     public void setResourceDir(File JavaDoc resourceDir) {
134         this.resourceDir = resourceDir;
135     }
136 }
137
Popular Tags