01: /*
02: * Copyright 2006-2007 The Scriptella Project Team.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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(
29: null, null);
30: private String name;
31: private String version;
32:
33: /**
34: * Creates dialect identifier.
35: *
36: * @param name vendor name, e.g. Oracle. Null allowed.
37: * @param version product version, e.g. 1.1.2. Null allowed.
38: */
39: public DialectIdentifier(String name, String version) {
40: this .name = name;
41: this .version = version;
42: }
43:
44: /**
45: * @return vendor name.
46: */
47: public String getName() {
48: return name;
49: }
50:
51: /**
52: * @return product version
53: */
54: public String getVersion() {
55: return version;
56: }
57:
58: public boolean equals(final Object o) {
59: if (this == o) {
60: return true;
61: }
62:
63: if (!(o instanceof DialectIdentifier)) {
64: return false;
65: }
66:
67: final DialectIdentifier dialectIdentifier = (DialectIdentifier) o;
68:
69: if ((name != null) ? (!name.equals(dialectIdentifier.name))
70: : (dialectIdentifier.name != null)) {
71: return false;
72: }
73:
74: return !((version != null) ? (!version
75: .equals(dialectIdentifier.version))
76: : (dialectIdentifier.version != null));
77:
78: }
79:
80: public int hashCode() {
81: int result;
82: result = ((name != null) ? name.hashCode() : 0);
83: result = (29 * result)
84: + ((version != null) ? version.hashCode() : 0);
85:
86: return result;
87: }
88:
89: public String toString() {
90: return "Dialect{" + name + ' ' + version + "}";
91: }
92: }
|