KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > jasperreports > engine > fill > JRFillField


1 /*
2  * ============================================================================
3  * GNU Lesser General Public License
4  * ============================================================================
5  *
6  * JasperReports - Free Java report-generating library.
7  * Copyright (C) 2001-2006 JasperSoft Corporation http://www.jaspersoft.com
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
22  *
23  * JasperSoft Corporation
24  * 303 Second Street, Suite 450 North
25  * San Francisco, CA 94107
26  * http://www.jaspersoft.com
27  */

28 package net.sf.jasperreports.engine.fill;
29
30 import net.sf.jasperreports.engine.JRExpression;
31 import net.sf.jasperreports.engine.JRField;
32
33
34 /**
35  * @author Teodor Danciu (teodord@users.sourceforge.net)
36  * @version $Id: JRFillField.java 1321 2006-07-03 18:38:02 +0300 (Mon, 03 Jul 2006) lucianc $
37  */

38 public class JRFillField implements JRField
39 {
40
41
42     /**
43      *
44      */

45     protected JRField parent = null;
46
47     /**
48      *
49      */

50     private Object JavaDoc previousOldValue = null;
51     private Object JavaDoc oldValue = null;
52     private Object JavaDoc value = null;
53     private Object JavaDoc savedValue;
54
55
56     /**
57      *
58      */

59     protected JRFillField(
60         JRField field,
61         JRFillObjectFactory factory
62         )
63     {
64         factory.put(field, this);
65
66         parent = field;
67     }
68
69
70     /**
71      *
72      */

73     public String JavaDoc getName()
74     {
75         return parent.getName();
76     }
77         
78     /**
79      *
80      */

81     public String JavaDoc getDescription()
82     {
83         return parent.getDescription();
84     }
85         
86     /**
87      *
88      */

89     public void setDescription(String JavaDoc description)
90     {
91     }
92     
93     /**
94      *
95      */

96     public Class JavaDoc getValueClass()
97     {
98         return parent.getValueClass();
99     }
100     
101     /**
102      *
103      */

104     public String JavaDoc getValueClassName()
105     {
106         return parent.getValueClassName();
107     }
108     
109     /**
110      *
111      */

112     public Object JavaDoc getOldValue()
113     {
114         return oldValue;
115     }
116         
117     /**
118      *
119      */

120     public void setOldValue(Object JavaDoc oldValue)
121     {
122         this.oldValue = oldValue;
123     }
124
125     /**
126      *
127      */

128     public Object JavaDoc getValue()
129     {
130         return value;
131     }
132         
133     /**
134      *
135      */

136     public void setValue(Object JavaDoc value)
137     {
138         this.value = value;
139     }
140         
141     public Object JavaDoc getValue(byte evaluation)
142     {
143         Object JavaDoc returnValue;
144         switch (evaluation)
145         {
146             case JRExpression.EVALUATION_OLD:
147                 returnValue = oldValue;
148                 break;
149             default:
150                 returnValue = value;
151                 break;
152         }
153         return returnValue;
154     }
155     
156     public void overwriteValue(Object JavaDoc newValue, byte evaluation)
157     {
158         switch (evaluation)
159         {
160             case JRExpression.EVALUATION_OLD:
161                 savedValue = oldValue;
162                 oldValue = newValue;
163                 break;
164             default:
165                 savedValue = value;
166                 value = newValue;
167                 break;
168         }
169     }
170     
171     public void restoreValue(byte evaluation)
172     {
173         switch (evaluation)
174         {
175             case JRExpression.EVALUATION_OLD:
176                 oldValue = savedValue;
177                 break;
178             default:
179                 value = savedValue;
180                 break;
181         }
182         savedValue = null;
183     }
184
185
186     
187     public Object JavaDoc getPreviousOldValue()
188     {
189         return previousOldValue;
190     }
191
192
193     
194     public void setPreviousOldValue(Object JavaDoc previousOldValue)
195     {
196         this.previousOldValue = previousOldValue;
197     }
198     
199 }
200
Popular Tags