KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > scriptella > spi > DialectIdentifier


1 /*
2  * Copyright 2006-2007 The Scriptella Project Team.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package scriptella.spi;
17
18 /**
19  * Represents vendor dialect information.
20  *
21  * @author Fyodor Kupolov
22  * @version 1.0
23  */

24 public class DialectIdentifier {
25     /**
26      * Null-Object to use instead of nulls if necessary
27      */

28     public static final DialectIdentifier NULL_DIALECT = new DialectIdentifier(null, null);
29     private String JavaDoc name;
30     private String JavaDoc version;
31
32     /**
33      * Creates dialect identifier.
34      *
35      * @param name vendor name, e.g. Oracle. Null allowed.
36      * @param version product version, e.g. 1.1.2. Null allowed.
37      */

38     public DialectIdentifier(String JavaDoc name, String JavaDoc version) {
39         this.name = name;
40         this.version = version;
41     }
42
43     /**
44      * @return vendor name.
45      */

46     public String JavaDoc getName() {
47         return name;
48     }
49
50     /**
51      * @return product version
52      */

53     public String JavaDoc getVersion() {
54         return version;
55     }
56
57     public boolean equals(final Object JavaDoc o) {
58         if (this == o) {
59             return true;
60         }
61
62         if (!(o instanceof DialectIdentifier)) {
63             return false;
64         }
65
66         final DialectIdentifier dialectIdentifier = (DialectIdentifier) o;
67
68         if ((name != null) ? (!name.equals(dialectIdentifier.name))
69                 : (dialectIdentifier.name != null)) {
70             return false;
71         }
72
73         return !((version != null) ? (!version.equals(dialectIdentifier.version))
74                 : (dialectIdentifier.version != null));
75
76     }
77
78     public int hashCode() {
79         int result;
80         result = ((name != null) ? name.hashCode() : 0);
81         result = (29 * result) + ((version != null) ? version.hashCode() : 0);
82
83         return result;
84     }
85
86     public String JavaDoc toString() {
87         return "Dialect{" + name + ' ' + version + "}";
88     }
89 }
90
Popular Tags