001: /**
002: * ========================================
003: * JFreeReport : a free Java report library
004: * ========================================
005: *
006: * Project Info: http://reporting.pentaho.org/
007: *
008: * (C) Copyright 2000-2007, by Object Refinery Limited, 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: * $Id: SubReport.java 3048 2007-07-28 18:02:42Z tmorgner $
027: * ------------
028: * (C) Copyright 2000-2005, by Object Refinery Limited.
029: * (C) Copyright 2005-2007, by Pentaho Corporation.
030: */package org.jfree.report.structure;
031:
032: import java.util.HashMap;
033: import java.util.Map;
034:
035: import org.jfree.report.flow.ParameterMapping;
036:
037: /**
038: * Creation-Date: 04.03.2006, 21:38:21
039: *
040: * @author Thomas Morgner
041: */
042: public class SubReport extends ReportDefinition {
043: private HashMap exportParameters;
044: private HashMap inputParameters;
045:
046: public SubReport() {
047: setType("sub-report");
048: exportParameters = new HashMap();
049: inputParameters = new HashMap();
050: }
051:
052: public void addExportParameter(final String outerName,
053: final String innerName) {
054: exportParameters.put(outerName, innerName);
055: }
056:
057: public void removeExportParameter(final String outerName) {
058: exportParameters.remove(outerName);
059: }
060:
061: public String getExportParameter(final String outerName) {
062: return (String) exportParameters.get(outerName);
063: }
064:
065: public String[] getExportParameters() {
066: return (String[]) exportParameters.keySet().toArray(
067: new String[exportParameters.size()]);
068: }
069:
070: public String[] getPeerExportParameters() {
071: return (String[]) exportParameters.values().toArray(
072: new String[exportParameters.size()]);
073: }
074:
075: public ParameterMapping[] getExportMappings() {
076: final Map.Entry[] inputEntries = (Map.Entry[]) exportParameters
077: .entrySet().toArray(
078: new Map.Entry[exportParameters.size()]);
079: final ParameterMapping[] mapping = new ParameterMapping[exportParameters
080: .size()];
081:
082: for (int i = 0; i < inputEntries.length; i++) {
083: final Map.Entry entry = inputEntries[i];
084: mapping[i] = new ParameterMapping((String) entry.getKey(),
085: (String) entry.getValue());
086: }
087: return mapping;
088: }
089:
090: public void addInputParameter(final String outerName,
091: final String innerName) {
092: inputParameters.put(outerName, innerName);
093: }
094:
095: public void removeInputParameter(final String outerName) {
096: inputParameters.remove(outerName);
097: }
098:
099: public String getInnerParameter(final String outerName) {
100: return (String) inputParameters.get(outerName);
101: }
102:
103: public String[] getInputParameters() {
104: return (String[]) inputParameters.keySet().toArray(
105: new String[inputParameters.size()]);
106: }
107:
108: public String[] getPeerInputParameters() {
109: return (String[]) inputParameters.values().toArray(
110: new String[inputParameters.size()]);
111: }
112:
113: public ParameterMapping[] getInputMappings() {
114: final Map.Entry[] inputEntries = (Map.Entry[]) inputParameters
115: .entrySet().toArray(
116: new Map.Entry[inputParameters.size()]);
117: final ParameterMapping[] mapping = new ParameterMapping[inputParameters
118: .size()];
119:
120: for (int i = 0; i < inputEntries.length; i++) {
121: final Map.Entry entry = inputEntries[i];
122: mapping[i] = new ParameterMapping((String) entry.getKey(),
123: (String) entry.getValue());
124: }
125: return mapping;
126: }
127:
128: public boolean isGlobalImport() {
129: return "*".equals(inputParameters.get("*"));
130: }
131:
132: public boolean isGlobalExport() {
133: return "*".equals(exportParameters.get("*"));
134: }
135:
136: public Object clone() throws CloneNotSupportedException {
137: final SubReport report = (SubReport) super .clone();
138: report.inputParameters = (HashMap) inputParameters.clone();
139: report.exportParameters = (HashMap) exportParameters.clone();
140: return report;
141: }
142: }
|