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.design;
029:
030: import java.util.List;
031: import java.util.Map;
032:
033: import net.sf.jasperreports.crosstabs.design.JRDesignCrosstab;
034: import net.sf.jasperreports.engine.JRExpression;
035: import net.sf.jasperreports.engine.JRExpressionCollector;
036: import net.sf.jasperreports.engine.JRVariable;
037:
038: /**
039: * Expression evaluator source code generation information.
040: *
041: * @author Lucian Chirita (lucianc@users.sourceforge.net)
042: * @version $Id: JRSourceCompileTask.java 1640 2007-03-15 15:20:59Z lucianc $
043: */
044: public class JRSourceCompileTask {
045: private JasperDesign jasperDesign;
046: private String unitName;
047: private JRExpressionCollector expressionCollector;
048: private Map parametersMap;
049: private Map fieldsMap;
050: private Map variablesMap;
051: private JRVariable[] variables;
052: private List expressions;
053: private boolean onlyDefaultEvaluation;
054:
055: protected JRSourceCompileTask(JasperDesign jasperDesign,
056: String unitName, JRExpressionCollector expressionCollector,
057: Map parametersMap, Map fieldsMap, Map variablesMap,
058: JRVariable[] variables, boolean onlyDefaultEvaluation) {
059: this .jasperDesign = jasperDesign;
060: this .unitName = unitName;
061: this .expressionCollector = expressionCollector;
062: this .parametersMap = parametersMap;
063: this .fieldsMap = fieldsMap;
064: this .variablesMap = variablesMap;
065: this .variables = variables;
066: this .expressions = expressionCollector.getExpressions();
067: this .onlyDefaultEvaluation = onlyDefaultEvaluation;
068: }
069:
070: /**
071: * Creates source code generation information for a dataset of a report.
072: *
073: * @param jasperDesign the report
074: * @param dataset the dataset
075: * @param expressionCollector the expression collector used for the report
076: * @param unitName the unit name of the code to be generated
077: */
078: public JRSourceCompileTask(JasperDesign jasperDesign,
079: JRDesignDataset dataset,
080: JRExpressionCollector expressionCollector, String unitName) {
081: this (jasperDesign, unitName, expressionCollector
082: .getCollector(dataset), dataset.getParametersMap(),
083: dataset.getFieldsMap(), dataset.getVariablesMap(),
084: dataset.getVariables(), false);
085: }
086:
087: /**
088: * Creates source code generation information for a crosstab of a report.
089: *
090: * @param jasperDesign the report
091: * @param crosstab the crosstab
092: * @param expressionCollector the expression collector used for the report
093: * @param unitName the unit name of the code to be generated
094: */
095: public JRSourceCompileTask(JasperDesign jasperDesign,
096: JRDesignCrosstab crosstab,
097: JRExpressionCollector expressionCollector, String unitName) {
098: this (jasperDesign, unitName, expressionCollector
099: .getCollector(crosstab), crosstab.getParametersMap(),
100: null, crosstab.getVariablesMap(), crosstab
101: .getVariables(), true);
102: }
103:
104: public List getExpressions() {
105: return expressions;
106: }
107:
108: public Map getFieldsMap() {
109: return fieldsMap;
110: }
111:
112: public JasperDesign getJasperDesign() {
113: return jasperDesign;
114: }
115:
116: public String[] getImports() {
117: return jasperDesign.getImports();
118: }
119:
120: public boolean isOnlyDefaultEvaluation() {
121: return onlyDefaultEvaluation;
122: }
123:
124: public Map getParametersMap() {
125: return parametersMap;
126: }
127:
128: public String getUnitName() {
129: return unitName;
130: }
131:
132: public JRVariable[] getVariables() {
133: return variables;
134: }
135:
136: public Map getVariablesMap() {
137: return variablesMap;
138: }
139:
140: public Integer getExpressionId(JRExpression expression) {
141: return expressionCollector.getExpressionId(expression);
142: }
143:
144: public JRExpression getExpression(int expressionId) {
145: return expressionCollector.getExpression(expressionId);
146: }
147: }
|