001: /**
002: * ===========================================
003: * JFreeReport : a free Java reporting library
004: * ===========================================
005: *
006: * Project Info: http://reporting.pentaho.org/
007: *
008: * (C) Copyright 2001-2007, by Object Refinery Ltd, Pentaho Corporation and Contributors.
009: *
010: * This library is free software; you can redistribute it and/or modify it under the terms
011: * of the GNU Lesser General Public License as published by the Free Software Foundation;
012: * either version 2.1 of the License, or (at your option) any later version.
013: *
014: * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
015: * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
016: * See the GNU Lesser General Public License for more details.
017: *
018: * You should have received a copy of the GNU Lesser General Public License along with this
019: * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
020: * Boston, MA 02111-1307, USA.
021: *
022: * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
023: * in the United States and other countries.]
024: *
025: * ------------
026: * BorderStyle.java
027: * ------------
028: * (C) Copyright 2001-2007, by Object Refinery Ltd, Pentaho Corporation and Contributors.
029: */package org.jfree.report.style;
030:
031: import java.io.ObjectStreamException;
032: import java.io.Serializable;
033:
034: import org.jfree.report.util.ObjectStreamResolveException;
035:
036: /**
037: * Creation-Date: 30.10.2005, 19:37:35
038: *
039: * @author Thomas Morgner
040: */
041: public class BorderStyle implements Serializable {
042: public static final BorderStyle NONE = new BorderStyle("none");
043: public static final BorderStyle HIDDEN = new BorderStyle("hidden");
044: public static final BorderStyle DOTTED = new BorderStyle("dotted");
045: public static final BorderStyle DASHED = new BorderStyle("dashed");
046: public static final BorderStyle SOLID = new BorderStyle("solid");
047: public static final BorderStyle DOUBLE = new BorderStyle("double");
048: public static final BorderStyle DOT_DASH = new BorderStyle(
049: "dot-dash");
050: public static final BorderStyle DOT_DOT_DASH = new BorderStyle(
051: "dot-dot-dash");
052: public static final BorderStyle WAVE = new BorderStyle("wave");
053: public static final BorderStyle GROOVE = new BorderStyle("groove");
054: public static final BorderStyle RIDGE = new BorderStyle("ridge");
055: public static final BorderStyle INSET = new BorderStyle("inset");
056: public static final BorderStyle OUTSET = new BorderStyle("outset");
057: private String type;
058:
059: private BorderStyle(final String type) {
060: this .type = type;
061: }
062:
063: public boolean equals(final Object o) {
064: if (this == o) {
065: return true;
066: }
067: if (o == null || getClass() != o.getClass()) {
068: return false;
069: }
070:
071: final BorderStyle that = (BorderStyle) o;
072:
073: if (type != null ? !type.equals(that.type) : that.type != null) {
074: return false;
075: }
076:
077: return true;
078: }
079:
080: public int hashCode() {
081: return (type != null ? type.hashCode() : 0);
082: }
083:
084: public String toString() {
085: return type;
086: }
087:
088: /**
089: * Replaces the automatically generated instance with one of the enumeration instances.
090: *
091: * @return the resolved element
092: *
093: * @throws java.io.ObjectStreamException if the element could not be resolved.
094: * @noinspection UNUSED_SYMBOL
095: */
096: protected Object readResolve() throws ObjectStreamException {
097: if (this .type.equals(BorderStyle.NONE.type)) {
098: return BorderStyle.NONE;
099: }
100: if (this .type.equals(BorderStyle.DASHED.type)) {
101: return BorderStyle.DASHED;
102: }
103: if (this .type.equals(BorderStyle.DOT_DASH.type)) {
104: return BorderStyle.DOT_DASH;
105: }
106: if (this .type.equals(BorderStyle.DOT_DOT_DASH.type)) {
107: return BorderStyle.DOT_DOT_DASH;
108: }
109: if (this .type.equals(BorderStyle.DOTTED.type)) {
110: return BorderStyle.DOTTED;
111: }
112: if (this .type.equals(BorderStyle.DOUBLE.type)) {
113: return BorderStyle.DOUBLE;
114: }
115: if (this .type.equals(BorderStyle.GROOVE.type)) {
116: return BorderStyle.GROOVE;
117: }
118: if (this .type.equals(BorderStyle.HIDDEN.type)) {
119: return BorderStyle.HIDDEN;
120: }
121: if (this .type.equals(BorderStyle.INSET.type)) {
122: return BorderStyle.INSET;
123: }
124: if (this .type.equals(BorderStyle.NONE.type)) {
125: return BorderStyle.NONE;
126: }
127: if (this .type.equals(BorderStyle.OUTSET.type)) {
128: return BorderStyle.OUTSET;
129: }
130: if (this .type.equals(BorderStyle.RIDGE.type)) {
131: return BorderStyle.RIDGE;
132: }
133: if (this .type.equals(BorderStyle.SOLID.type)) {
134: return BorderStyle.SOLID;
135: }
136: if (this .type.equals(BorderStyle.WAVE.type)) {
137: return BorderStyle.WAVE;
138: }
139: // unknown element alignment...
140: throw new ObjectStreamResolveException();
141: }
142:
143: }
|