1
/* ========================================================================
2
* JCommon : a free general purpose class library for the Java(tm) platform
3
* ========================================================================
5
* (C) Copyright 2000-2005, by Object Refinery Limited and Contributors.
7
* Project Info: http://www.jfree.org/jcommon/index.html
9
* This library is free software; you can redistribute it and/or modify it
10
* under the terms of the GNU Lesser General Public License as published by
11
* the Free Software Foundation; either version 2.1 of the License, or
12
* (at your option) any later version.
14
* This library is distributed in the hope that it will be useful, but
15
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
17
* License for more details.
19
* You should have received a copy of the GNU Lesser General Public
20
* License along with this library; if not, write to the Free Software
21
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
24
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
25
* in the United States and other countries.]
30
* (C) Copyright 2004, 2005, by Object Refinery Limited.
32
* Original Author: David Gilbert (for Object Refinery Limited);
35
* $Id: UnitType.java,v 1.7 2005/10/18 13:24:19 mungady Exp $
39
* 11-Feb-2004 : Version 1 (DG);
43
package org.jfree.util;
45
import java.io.ObjectStreamException;
46
import java.io.Serializable;
49
* Used to indicate absolute or relative units.
51
* @author David Gilbert
53
public final class UnitType implements Serializable {
55
/** For serialization. */
56
private static final long serialVersionUID = 6531925392288519884L;
59
public static final UnitType ABSOLUTE = new UnitType("UnitType.ABSOLUTE");
62
public static final UnitType RELATIVE = new UnitType("UnitType.RELATIVE");
68
* Private constructor.
70
* @param name the name.
72
private UnitType(final String name) {
77
* Returns a string representing the object.
81
public String toString() {
86
* Returns <code>true</code> if this object is equal to the specified
87
* object, and <code>false</code> otherwise.
89
* @param obj the other object.
93
public boolean equals(final Object obj) {
97
if (!(obj instanceof UnitType)) {
100
final UnitType that = (UnitType) obj;
101
if (!this.name.equals(that.name)) {
108
* Returns a hash code value for the object.
110
* @return The hashcode
112
public int hashCode() {
113
return this.name.hashCode();
117
* Ensures that serialization returns the unique instances.
119
* @return The object.
121
* @throws ObjectStreamException if there is a problem.
123
private Object readResolve() throws ObjectStreamException {
124
if (this.equals(UnitType.ABSOLUTE)) {
125
return UnitType.ABSOLUTE;
127
else if (this.equals(UnitType.RELATIVE)) {
128
return UnitType.RELATIVE;