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: * WhitespaceCollapse.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 WhitespaceCollapse implements Serializable {
042: public static final WhitespaceCollapse COLLAPSE = new WhitespaceCollapse(
043: "collapse");
044: public static final WhitespaceCollapse PRESERVE = new WhitespaceCollapse(
045: "preserve");
046: public static final WhitespaceCollapse DISCARD = new WhitespaceCollapse(
047: "discard");
048: public static final WhitespaceCollapse PRESERVE_BREAKS = new WhitespaceCollapse(
049: "preserve-breaks");
050: private String type;
051:
052: private WhitespaceCollapse(final String type) {
053: this .type = type;
054: }
055:
056: public boolean equals(final Object o) {
057: if (this == o) {
058: return true;
059: }
060: if (o == null || getClass() != o.getClass()) {
061: return false;
062: }
063:
064: final WhitespaceCollapse that = (WhitespaceCollapse) o;
065:
066: if (type != null ? !type.equals(that.type) : that.type != null) {
067: return false;
068: }
069:
070: return true;
071: }
072:
073: public int hashCode() {
074: return (type != null ? type.hashCode() : 0);
075: }
076:
077: public String toString() {
078: return type;
079: }
080:
081: /**
082: * Replaces the automatically generated instance with one of the enumeration instances.
083: *
084: * @return the resolved element
085: *
086: * @throws java.io.ObjectStreamException if the element could not be resolved.
087: * @noinspection UNUSED_SYMBOL
088: */
089: protected Object readResolve() throws ObjectStreamException {
090: if (this .type.equals(WhitespaceCollapse.COLLAPSE.type)) {
091: return WhitespaceCollapse.COLLAPSE;
092: }
093: if (this .type.equals(WhitespaceCollapse.PRESERVE.type)) {
094: return WhitespaceCollapse.PRESERVE;
095: }
096: if (this .type.equals(WhitespaceCollapse.DISCARD.type)) {
097: return WhitespaceCollapse.DISCARD;
098: }
099: if (this .type.equals(WhitespaceCollapse.PRESERVE_BREAKS.type)) {
100: return WhitespaceCollapse.PRESERVE_BREAKS;
101: }
102: // unknown element alignment...
103: throw new ObjectStreamResolveException();
104: }
105:
106: }
|