001: /*
002: * ============================================================================
003: * GNU Lesser General Public License
004: * ============================================================================
005: *
006: * JasperReports - Free Java report-generating library.
007: * Copyright (C) 2001-2006 JasperSoft Corporation http://www.jaspersoft.com
008: *
009: * This library is free software; you can redistribute it and/or
010: * modify it under the terms of the GNU Lesser General Public
011: * License as published by the Free Software Foundation; either
012: * 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,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
017: * Lesser General Public License for more details.
018: *
019: * You should have received a copy of the GNU Lesser General Public
020: * License along with this library; if not, write to the Free Software
021: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
022: *
023: * JasperSoft Corporation
024: * 303 Second Street, Suite 450 North
025: * San Francisco, CA 94107
026: * http://www.jaspersoft.com
027: */
028: package net.sf.jasperreports.engine.fill;
029:
030: import net.sf.jasperreports.engine.JRExpression;
031: import net.sf.jasperreports.engine.JRField;
032: import net.sf.jasperreports.engine.JRPropertiesMap;
033:
034: /**
035: * @author Teodor Danciu (teodord@users.sourceforge.net)
036: * @version $Id: JRFillField.java 1669 2007-03-26 14:50:07Z lucianc $
037: */
038: public class JRFillField implements JRField {
039:
040: /**
041: *
042: */
043: protected JRField parent = null;
044:
045: /**
046: *
047: */
048: private Object previousOldValue = null;
049: private Object oldValue = null;
050: private Object value = null;
051: private Object savedValue;
052:
053: /**
054: *
055: */
056: protected JRFillField(JRField field, JRFillObjectFactory factory) {
057: factory.put(field, this );
058:
059: parent = field;
060: }
061:
062: /**
063: *
064: */
065: public String getName() {
066: return parent.getName();
067: }
068:
069: /**
070: *
071: */
072: public String getDescription() {
073: return parent.getDescription();
074: }
075:
076: /**
077: *
078: */
079: public void setDescription(String description) {
080: }
081:
082: /**
083: *
084: */
085: public Class getValueClass() {
086: return parent.getValueClass();
087: }
088:
089: /**
090: *
091: */
092: public String getValueClassName() {
093: return parent.getValueClassName();
094: }
095:
096: /**
097: *
098: */
099: public Object getOldValue() {
100: return oldValue;
101: }
102:
103: /**
104: *
105: */
106: public void setOldValue(Object oldValue) {
107: this .oldValue = oldValue;
108: }
109:
110: /**
111: *
112: */
113: public Object getValue() {
114: return value;
115: }
116:
117: /**
118: *
119: */
120: public void setValue(Object value) {
121: this .value = value;
122: }
123:
124: public Object getValue(byte evaluation) {
125: Object returnValue;
126: switch (evaluation) {
127: case JRExpression.EVALUATION_OLD:
128: returnValue = oldValue;
129: break;
130: default:
131: returnValue = value;
132: break;
133: }
134: return returnValue;
135: }
136:
137: public void overwriteValue(Object newValue, byte evaluation) {
138: switch (evaluation) {
139: case JRExpression.EVALUATION_OLD:
140: savedValue = oldValue;
141: oldValue = newValue;
142: break;
143: default:
144: savedValue = value;
145: value = newValue;
146: break;
147: }
148: }
149:
150: public void restoreValue(byte evaluation) {
151: switch (evaluation) {
152: case JRExpression.EVALUATION_OLD:
153: oldValue = savedValue;
154: break;
155: default:
156: value = savedValue;
157: break;
158: }
159: savedValue = null;
160: }
161:
162: public Object getPreviousOldValue() {
163: return previousOldValue;
164: }
165:
166: public void setPreviousOldValue(Object previousOldValue) {
167: this .previousOldValue = previousOldValue;
168: }
169:
170: public JRPropertiesMap getPropertiesMap() {
171: return parent.getPropertiesMap();
172: }
173:
174: }
|