KickJava   Java API By Example, From Geeks To Geeks.

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


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 java.io.Serializable JavaDoc;
31 import java.util.HashMap JavaDoc;
32 import java.util.HashSet JavaDoc;
33 import java.util.Map JavaDoc;
34 import java.util.Set JavaDoc;
35
36 /**
37  * Recorded values container used by elements with
38  * {@link net.sf.jasperreports.engine.JRExpression#EVALUATION_TIME_AUTO Auto evaluation time}.
39  *
40  * @author Lucian Chirita (lucianc@users.sourceforge.net)
41  * @version $Id: JRRecordedValues.java 1229 2006-04-19 13:27:35 +0300 (Wed, 19 Apr 2006) teodord $
42  */

43 public class JRRecordedValues implements Serializable JavaDoc
44 {
45     private Set JavaDoc evaluationTimes;
46     private Map JavaDoc recordedVariableValues;
47     private Map JavaDoc recordedFieldValues;
48
49     /**
50      * Creates a recorded values set.
51      *
52      * @param evaluationTimes future times when the values will be recorded
53      */

54     public JRRecordedValues(Set JavaDoc evaluationTimes)
55     {
56         this.evaluationTimes = new HashSet JavaDoc(evaluationTimes);
57     }
58
59     
60     /**
61      * Marks an evaluation time as done.
62      *
63      * @param evaluationTime the evaluation time
64      */

65     public void doneEvaluation(JREvaluationTime evaluationTime)
66     {
67         evaluationTimes.remove(evaluationTime);
68     }
69     
70     
71     /**
72      * Decides whether this is the last evaluation time.
73      *
74      * @return whether this is the last evaluation time
75      */

76     public boolean lastEvaluationTime()
77     {
78         return evaluationTimes.size() == 1;
79     }
80     
81     
82     /**
83      * Decides whether all required evaluations are done.
84      *
85      * @return whether all required evaluations are done
86      */

87     public boolean finishedEvaluations()
88     {
89         return evaluationTimes.isEmpty();
90     }
91     
92     
93     /**
94      * Records a variable value.
95      *
96      * @param variableName the variable name
97      * @param value the variable value to record
98      */

99     public void recordVariableValue(String JavaDoc variableName, Object JavaDoc value)
100     {
101         if (recordedVariableValues == null)
102         {
103             recordedVariableValues = new HashMap JavaDoc();
104         }
105         recordedVariableValues.put(variableName, value);
106     }
107     
108     
109     /**
110      * Records a field value.
111      *
112      * @param fieldName the field name
113      * @param value the field value to record
114      */

115     public void recordFieldValue(String JavaDoc fieldName, Object JavaDoc value)
116     {
117         if (recordedFieldValues == null)
118         {
119             recordedFieldValues = new HashMap JavaDoc();
120         }
121         recordedFieldValues.put(fieldName, value);
122     }
123     
124     
125     /**
126      * Returns the recorded variable values indexed by variable name.
127      *
128      * @return the recorded variable values
129      */

130     public Map JavaDoc getRecordedVariableValues()
131     {
132         return recordedVariableValues;
133     }
134     
135     
136     /**
137      * Returns the recorded field values indexed by field name.
138      *
139      * @return the recorded field values
140      */

141     public Map JavaDoc getRecordedFieldValues()
142     {
143         return recordedFieldValues;
144     }
145 }
146
Popular Tags