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: * ReportStateKey.java
027: * ------------
028: * (C) Copyright 2001-2007, by Object Refinery Ltd, Pentaho Corporation and Contributors.
029: */package org.jfree.report.states;
030:
031: /**
032: * The process-state key is a unique functional identifier of report-states. However, it does not
033: * get updated with changes to the report-state, so it always represents the process-state at the
034: * beginning of the report-state processing. This key can be used to see whether there was some progress
035: * and to uniquely identify report-states, but for everything else, this class is not suitable.
036: *
037: * @author Thomas Morgner
038: */
039: public class ReportStateKey {
040: private ReportStateKey parent;
041: private int cursor;
042: private int stateCode;
043: private int groupLevel;
044: private int subreport;
045: private Integer hashCode;
046:
047: public ReportStateKey(final ReportStateKey parent,
048: final int cursor, final int stateCode,
049: final int groupLevel, final int subreport) {
050: this .parent = parent;
051: this .cursor = cursor;
052: this .stateCode = stateCode;
053: this .groupLevel = groupLevel;
054: this .subreport = subreport;
055: }
056:
057: public ReportStateKey getParent() {
058: return parent;
059: }
060:
061: public int getCursor() {
062: return cursor;
063: }
064:
065: public int getStateCode() {
066: return stateCode;
067: }
068:
069: public int getGroupLevel() {
070: return groupLevel;
071: }
072:
073: public int getSubreport() {
074: return subreport;
075: }
076:
077: public boolean equals(final Object o) {
078: if (this == o) {
079: return true;
080: }
081: if (o == null || getClass() != o.getClass()) {
082: return false;
083: }
084:
085: final ReportStateKey that = (ReportStateKey) o;
086:
087: if (cursor != that.cursor) {
088: return false;
089: }
090: if (groupLevel != that.groupLevel) {
091: return false;
092: }
093: if (stateCode != that.stateCode) {
094: return false;
095: }
096: if (subreport != that.subreport) {
097: return false;
098: }
099: if (parent != null ? !parent.equals(that.parent)
100: : that.parent != null) {
101: return false;
102: }
103: return true;
104: }
105:
106: public int hashCode() {
107: if (hashCode == null) {
108: int result = (parent != null ? parent.hashCode() : 0);
109: result = 29 * result + cursor;
110: result = 29 * result + stateCode;
111: result = 29 * result + groupLevel;
112: result = 29 * result + subreport;
113: hashCode = new Integer(result);
114: return result;
115: }
116: return hashCode.intValue();
117: }
118:
119: public String toString() {
120: return "ReportStateKey{" + "parent=" + parent + ", cursor="
121: + cursor + ", stateCode=" + stateCode + ", groupLevel="
122: + groupLevel + ", subreport=" + subreport + '}';
123: }
124: }
|