01: /*
02: * GeoTools - OpenSource mapping toolkit
03: * http://geotools.org
04: * (C) 2002-2006, GeoTools Project Managment Committee (PMC)
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation;
09: * version 2.1 of the License.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: */
16: package org.geotools.styling;
17:
18: import org.geotools.event.AbstractGTComponent;
19: import org.geotools.resources.Utilities;
20: import org.opengis.util.Cloneable;
21:
22: /**
23: *
24: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/main/src/main/java/org/geotools/styling/ExtentImpl.java $
25: */
26: public class ExtentImpl extends AbstractGTComponent implements Extent,
27: Cloneable {
28: private String name;
29: private String value;
30:
31: public String getName() {
32: return name;
33: }
34:
35: public void setName(String name) {
36: String old = this .name;
37: this .name = name;
38:
39: fireChildChanged("name", this .name, old);
40: }
41:
42: public String getValue() {
43: return value;
44: }
45:
46: public void setValue(String value) {
47: String old = this .value;
48: this .value = value;
49:
50: fireChildChanged("value", this .value, old);
51: }
52:
53: public boolean equals(Object obj) {
54: if (this == obj) {
55: return true;
56: }
57:
58: if (obj instanceof ExtentImpl) {
59: ExtentImpl other = (ExtentImpl) obj;
60:
61: return Utilities.equals(this .name, other.name)
62: && Utilities.equals(this .value, other.value);
63: }
64:
65: return false;
66: }
67:
68: public int hashCode() {
69: final int PRIME = 1000003;
70: int result = 0;
71:
72: if (name != null) {
73: result = (PRIME * result) + name.hashCode();
74: }
75:
76: if (value != null) {
77: result = (PRIME * result) + value.hashCode();
78: }
79:
80: return result;
81: }
82:
83: public Object clone() {
84: try {
85: ExtentImpl clone = (ExtentImpl) super .clone();
86: clone.setName(name);
87: clone.setValue(value);
88:
89: return clone;
90: } catch (CloneNotSupportedException e) {
91: //This will never happen
92: throw new RuntimeException("Failed to clone ExtentImpl");
93: }
94: }
95: }
|