01: /**
02: * Copyright 2006 Webmedia Group Ltd.
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: **/package org.araneaframework.uilib.support;
16:
17: import java.io.Serializable;
18:
19: /**
20: * This class defines the <code>Map</code> key, that is used to find a
21: * converter between data held in {@link org.araneaframework.uilib.form.Control} and
22: * corresponding {@link org.araneaframework.uilib.form.Data}.
23: *
24: * @see org.araneaframework.uilib.form.converter.ConverterFactory
25: *
26: * @author Jevgeni Kabanov (ekabanov <i>at</i> araneaframework <i>dot</i> org)
27: */
28: public class ConverterKey implements Serializable {
29: private String fromType;
30: private String toType;
31:
32: /**
33: * Returns the type from which the conversion goes.
34: *
35: * @return the type from which the conversion goes.
36: */
37: public String getFromType() {
38: return fromType;
39: }
40:
41: /**
42: * Returns the type to which the conversion goes.
43: *
44: * @return the type to which the conversion goes.
45: */
46: public String getToType() {
47: return toType;
48: }
49:
50: /**
51: * Creates the class, initializing both "to" and "from" types.
52: *
53: * @param fromType
54: * the type from which the conversion goes.
55: * @param toType
56: * the type to which the conversion goes.
57: */
58: public ConverterKey(String fromType, String toType) {
59: this .fromType = fromType;
60: this .toType = toType;
61: }
62:
63: /**
64: * Implements the {@link Object#equals(java.lang.Object)} method, using both
65: * types.
66: */
67: public boolean equals(Object o) {
68: if (!(o instanceof ConverterKey))
69: return false;
70: ConverterKey inst = (ConverterKey) o;
71: if (!(this .fromType == null ? inst.fromType == null
72: : this .fromType.equals(inst.fromType)))
73: return false;
74: if (!(this .toType == null ? inst.toType == null : this .toType
75: .equals(inst.toType)))
76: return false;
77: return true;
78: }
79:
80: /**
81: * Implemets the {@link Object#hashCode()} method, using both
82: * types.
83: *
84: *
85: */
86: public int hashCode() {
87: int result = 17;
88: result = 37 * result + fromType.hashCode();
89: result = 37 * result + toType.hashCode();
90: return result;
91: }
92: }
|