improved syntax highlighting (php tag/return keyword/brackets and operators)
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.quantum.sql / src / com / quantum / model / JDBCDriver.java
1 package com.quantum.model;
2
3 import java.beans.PropertyChangeListener;
4 import java.beans.PropertyChangeSupport;
5 import java.sql.Driver;
6
7 import com.quantum.util.JarUtil;
8
9
10 /**
11  * @author BC
12  */
13 public class JDBCDriver {
14         private String name;
15         private String version;
16         private String className;
17         private String jarFileName;
18         private String type;
19         private PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this);
20         /**
21          * @param className
22          * @param jarFileName
23          */
24         public JDBCDriver(String className, String jarFileName, String type) {
25                 this(className, jarFileName, type, null, null);
26         }
27         /**
28          * 
29          */
30         public JDBCDriver() {
31         }
32         /**
33          * @param className
34          * @param jarFileName
35          * @param name
36          * @param version
37          */
38         public JDBCDriver(String className, String jarFileName, String type, String name, String version) {
39                 this.name = name;
40                 this.version = version;
41                 this.type = type;
42                 this.className = className;
43                 this.jarFileName = jarFileName;
44         }
45         /**
46          * @return Returns the className.
47          */
48         public String getClassName() {
49                 return this.className;
50         }
51         /**
52          * @param className The className to set.
53          */
54         public void setClassName(String className) {
55                 if (className != null && !className.equals(this.className)) {
56                         String original = this.className;
57                         this.className = className;
58                         this.propertyChangeSupport.firePropertyChange("className", original, className);
59                 }
60         }
61         /**
62          * @return Returns the jarFileName.
63          */
64         public String getJarFileName() {
65                 return this.jarFileName;
66         }
67         /**
68          * @param jarFileName The jarFileName to set.
69          */
70         public void setJarFileName(String jarFileName) {
71                 if (jarFileName != null && !jarFileName.equals(this.jarFileName)) {
72                         String original = this.jarFileName;
73                         this.jarFileName = jarFileName;
74                         this.propertyChangeSupport.firePropertyChange("jarFileName", original, jarFileName);
75                 }
76         }
77         /**
78          * @return Returns the name.
79          */
80         public String getName() {
81                 return this.name == null || this.name.trim().length() == 0 ? getClassName() : this.name;
82         }
83         /**
84          * @param name The name to set.
85          */
86         public void setName(String name) {
87                 if (name != null && !name.equals(this.name)) {
88                         String original = this.name;
89                         this.name = name;
90                         this.propertyChangeSupport.firePropertyChange("name", original, name);
91                 }
92         }
93         /**
94          * @return Returns the version.
95          */
96         public String getVersion() {
97                 return this.version;
98         }
99         /**
100          * @param version The version to set.
101          */
102         public void setVersion(String version) {
103                 if (version != null && !version.equals(this.version)) {
104                         String original = this.version;
105                         this.version = version;
106                         this.propertyChangeSupport.firePropertyChange("version", original, version);
107                 }
108         }
109         
110         public boolean equals(Object object) {
111                 if (super.equals(object)) {
112                         return true;
113                 } else if (object == null) {
114                         return false;
115                 } else if (getClass() != object.getClass()) {
116                         return false;
117                 } else {
118                         JDBCDriver that = (JDBCDriver) object;
119                         
120                         if (this.className == null && that.className != null) {
121                                 return false;
122                         } else if (this.className != null && !this.className.equals(that.className)) {
123                                 return false;
124                         } else if (this.jarFileName == null && that.jarFileName != null) {
125                                 return false;
126                         } else if (this.jarFileName != null && !this.jarFileName.equals(that.jarFileName)) {
127                                 return false;
128                         } else if (this.type == null && that.type != null) {
129                                 return false;
130                         } else if (this.type != null && !this.type.equals(that.type)) {
131                                 return false;
132                         } else {
133                                 return true;
134                         }
135                 }
136         }
137         public int hashCode() {
138                 int hashCode = 31;
139                 if (this.className != null) {
140                         hashCode ^= this.className.hashCode();
141                 }
142                 if (this.jarFileName != null) {
143                         hashCode ^= this.jarFileName.hashCode();
144                 }
145                 if (this.type != null) {
146                         hashCode ^= this.type.hashCode();
147                 }
148                 return hashCode;
149         }
150         
151         public Driver getDriver() {
152                 return JarUtil.loadDriver(getJarFileName(), getClassName());
153         }
154         /**
155          * @param listener
156          */
157         public void addPropertyChangeListener(PropertyChangeListener listener) {
158                 this.propertyChangeSupport.addPropertyChangeListener(listener);
159         }
160         /**
161          * @param propertyName
162          * @param listener
163          */
164         public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
165                 this.propertyChangeSupport.addPropertyChangeListener(propertyName, listener);
166         }
167         /**
168          * @param arg0
169          */
170         public void removePropertyChangeListener(PropertyChangeListener arg0) {
171                 this.propertyChangeSupport.removePropertyChangeListener(arg0);
172         }
173         /**
174          * @param arg0
175          * @param arg1
176          */
177         public void removePropertyChangeListener(String arg0, PropertyChangeListener arg1) {
178                 this.propertyChangeSupport.removePropertyChangeListener(arg0, arg1);
179         }
180         /**
181          * @return Returns the type.
182          */
183         public String getType() {
184                 return this.type;
185         }
186         /**
187          * @param type The type to set.
188          */
189         public void setType(String type) {
190                 if (type != null && !type.equals(this.type)) {
191                         String original = this.type;
192                         this.type = type;
193                         this.propertyChangeSupport.firePropertyChange("type", original, type);
194                 }
195         }
196 }