Debian Codegraph @

source/org/jfree/report/structure/SubReport.java

raw
1 /**
2 * ========================================
3 * JFreeReport : a free Java report library
4 * ========================================
5 *
6 * Project Info: http://reporting.pentaho.org/
7 *
8 * (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors.
9 *
10 * This library is free software; you can redistribute it and/or modify it under the terms
11 * of the GNU Lesser General Public License as published by the Free Software Foundation;
12 * either 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, but WITHOUT ANY WARRANTY;
15 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16 * See the GNU Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public License along with this
19 * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20 * Boston, MA 02111-1307, USA.
21 *
22 * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
23 * in the United States and other countries.]
24 *
25 * ------------
26 * $Id: SubReport.java 10756 2009-12-02 15:58:24Z tmorgner $
27 * ------------
28 * (C) Copyright 2000-2005, by Object Refinery Limited.
29 * (C) Copyright 2005-2007, by Pentaho Corporation.
30 */
31 package org.jfree.report.structure;
32
33 import java.util.HashMap;
34 import java.util.Map;
35
36 import org.jfree.report.flow.ParameterMapping;
37
38 /**
39 * Creation-Date: 04.03.2006, 21:38:21
40 *
41 * @author Thomas Morgner
42 */
43 public class SubReport extends ReportDefinition
44 {
45 private HashMap exportParameters;
46 private HashMap inputParameters;
47
48 public SubReport()
49 {
50 setType("sub-report");
51 exportParameters = new HashMap();
52 inputParameters = new HashMap();
53 }
54
55 public void addExportParameter (final String outerName,
56 final String innerName)
57 {
58 exportParameters.put(outerName, innerName);
59 }
60
61 public void removeExportParameter (final String outerName)
62 {
63 exportParameters.remove(outerName);
64 }
65
66 public String getExportParameter (final String outerName)
67 {
68 return (String) exportParameters.get(outerName);
69 }
70
71 public String[] getExportParameters ()
72 {
73 return (String[])
74 exportParameters.keySet().toArray(new String[exportParameters.size()]);
75 }
76
77 public String[] getPeerExportParameters ()
78 {
79 return (String[])
80 exportParameters.values().toArray(new String[exportParameters.size()]);
81 }
82
83 public ParameterMapping[] getExportMappings ()
84 {
85 final Map.Entry[] inputEntries = (Map.Entry[])
86 exportParameters.entrySet().toArray(new Map.Entry[exportParameters.size()]);
87 final ParameterMapping[] mapping =
88 new ParameterMapping[exportParameters.size()];
89
90 for (int i = 0; i < inputEntries.length; i++)
91 {
92 final Map.Entry entry = inputEntries[i];
93 mapping[i] = new ParameterMapping
94 ((String) entry.getKey(), (String) entry.getValue());
95 }
96 return mapping;
97 }
98
99 public void addInputParameter (final String outerName,
100 final String innerName)
101 {
102 inputParameters.put(outerName, innerName);
103 }
104
105 public void removeInputParameter (final String outerName)
106 {
107 inputParameters.remove(outerName);
108 }
109
110 public String getInnerParameter (final String outerName)
111 {
112 return (String) inputParameters.get(outerName);
113 }
114
115 public String[] getInputParameters ()
116 {
117 return (String[])
118 inputParameters.keySet().toArray(new String[inputParameters.size()]);
119 }
120
121 public String[] getPeerInputParameters ()
122 {
123 return (String[])
124 inputParameters.values().toArray(new String[inputParameters.size()]);
125 }
126
127 public ParameterMapping[] getInputMappings ()
128 {
129 final Map.Entry[] inputEntries = (Map.Entry[])
130 inputParameters.entrySet().toArray(new Map.Entry[inputParameters.size()]);
131 final ParameterMapping[] mapping =
132 new ParameterMapping[inputParameters.size()];
133
134 for (int i = 0; i < inputEntries.length; i++)
135 {
136 final Map.Entry entry = inputEntries[i];
137 mapping[i] = new ParameterMapping
138 ((String) entry.getKey(), (String) entry.getValue());
139 }
140 return mapping;
141 }
142
143 public boolean isGlobalImport()
144 {
145 return "*".equals(inputParameters.get("*"));
146 }
147
148 public boolean isGlobalExport()
149 {
150 return "*".equals(exportParameters.get("*"));
151 }
152
153
154 public Object clone()
155 throws CloneNotSupportedException
156 {
157 final SubReport report = (SubReport) super.clone();
158 report.inputParameters = (HashMap) inputParameters.clone();
159 report.exportParameters = (HashMap) exportParameters.clone();
160 return report;
161 }
162 }