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;
029:
030: import net.sf.jasperreports.engine.export.JRExportProgressMonitor;
031: import net.sf.jasperreports.engine.export.JRHyperlinkProducerFactory;
032: import net.sf.jasperreports.engine.util.JRProperties;
033:
034: /**
035: * Instances of this class are used for defining and setting exporter parameters.
036: * <p>
037: * The {@link JasperPrint} object needed for the export can be specified in many ways: an instance of <tt>JasperPrint</tt>,
038: * an input stream, a file on disk, or an URL. The export engine will search for this object through parameters in the following
039: * order: JASPER_PRINT_LIST, JASPER_PRINT, INPUT_STREAM, INPUT_URL, INPUT_FILE, INPUT_FILE_NAME.
040: * <p>
041: * The output type of the export process can also vary: a string buffer, an output stream / writer of a file on disk. The order of
042: * parameters used by JasperReports when looking for the output depends on the final document format and is explained in detail
043: * for each format (see documentation for the children of this class).
044: * <p>
045: * JasperReports allows users to export only a page range from the entire report or even a single page. The engine first
046: * searches for the PAGE_INDEX parameter. If this is not present, it looks for the START_PAGE_INDEX and END_PAGE_INDEX
047: * parameters. The engine will try to narrow the page range (which is initially the entire report) by using these two
048: * parameters, if present.
049: *
050: * @author Teodor Danciu (teodord@users.sourceforge.net)
051: * @version $Id: JRExporterParameter.java 1824 2007-08-23 14:19:12Z teodord $
052: */
053: public class JRExporterParameter {
054:
055: /**
056: *
057: */
058: private String name = null;
059:
060: /**
061: *
062: */
063: protected JRExporterParameter(String name) {
064: this .name = name;
065: }
066:
067: /**
068: *
069: */
070: public String toString() {
071: return this .name;
072: }
073:
074: /**
075: * The {@link JasperPrint} object that will be exported. If you already have a JasperPrint object, you can pass it
076: * to the export engine.
077: */
078: public static final JRExporterParameter JASPER_PRINT = new JRExporterParameter(
079: "JasperPrint Object");
080:
081: /**
082: * A list of {@link JasperPrint} objects to be exported. If you need to concatenate several reports into the same
083: * document, you can use this feature.
084: */
085: public static final JRExporterParameter JASPER_PRINT_LIST = new JRExporterParameter(
086: "JasperPrint List");
087:
088: /**
089: * The input stream that the exported {@link JasperPrint} object will be read from. If you want to read the JasperPrint
090: * object from an input stream (like a web location), you can pass the stream to this parameter.
091: */
092: public static final JRExporterParameter INPUT_STREAM = new JRExporterParameter(
093: "InputStream Object");
094:
095: /**
096: * The URL that the {@link JasperPrint} object will be read from. If the JasperPrint object is available as a web
097: * resource, you can use this parameter, instead of opening a HTTP connection and read from the input stream.
098: */
099: public static final JRExporterParameter INPUT_URL = new JRExporterParameter(
100: "URL Object");
101:
102: /**
103: * A <tt>java.io.File</tt> pointing to a file representing the serialized form of the {@link JasperPrint} object. This is
104: * useful if the JasperPrint object is representing a file on disk.
105: */
106: public static final JRExporterParameter INPUT_FILE = new JRExporterParameter(
107: "Input File");
108:
109: /**
110: * A file representing the serialized form of the {@link JasperPrint} object. You can use this parameter to specify a file
111: * name where the object can be found.
112: */
113: public static final JRExporterParameter INPUT_FILE_NAME = new JRExporterParameter(
114: "Input File Name");
115:
116: /**
117: * The string buffer to send the export output to. Useful for just storing the result in a string for later use.
118: */
119: public static final JRExporterParameter OUTPUT_STRING_BUFFER = new JRExporterParameter(
120: "Output StringBuffer Object");
121:
122: /**
123: * The <tt>java.io.Writer</tt> instance that will be used to send the export output to. This is useful for sending
124: * the export result to a character stream, such as the <tt>PrintWriter</tt> of a servlet.
125: */
126: public static final JRExporterParameter OUTPUT_WRITER = new JRExporterParameter(
127: "Output Writer Object");
128:
129: /**
130: * The <tt>java.io.OutputStream</tt> instance that will be used to send the export output to. This is useful for sending
131: * the export result to an output stream, such as a <tt>ServletOutputStream</tt>.
132: */
133: public static final JRExporterParameter OUTPUT_STREAM = new JRExporterParameter(
134: "OutputStream Object");
135:
136: /**
137: * The <tt>java.io.File</tt> instance that will be used to specify the file name of the exported report. This is useful when
138: * exporting to a file and the <tt>File</tt> instance is already there.
139: */
140: public static final JRExporterParameter OUTPUT_FILE = new JRExporterParameter(
141: "Output File");
142:
143: /**
144: * The file name of the exported report. This is an alternative to the OUTPUT_FILE parameter.
145: */
146: public static final JRExporterParameter OUTPUT_FILE_NAME = new JRExporterParameter(
147: "Output File Name");
148:
149: /**
150: * An integer value representing the index of the page to be exported. This is useful when only one page of the entire
151: * report is needed for export.
152: */
153: public static final JRExporterParameter PAGE_INDEX = new JRExporterParameter(
154: "Page Index");
155:
156: /**
157: * An integer value representing the start index of the page range to be exported. This is useful when only a range of
158: * pages is needed for export.
159: */
160: public static final JRExporterParameter START_PAGE_INDEX = new JRExporterParameter(
161: "Start Page Index");
162:
163: /**
164: * An integer value representing the end index of the page range to be exported. This is useful when only a range of
165: * pages is needed for export.
166: */
167: public static final JRExporterParameter END_PAGE_INDEX = new JRExporterParameter(
168: "End Page Index");
169:
170: /**
171: * The character encoding used for export.
172: */
173: public static final JRExporterParameter CHARACTER_ENCODING = new JRExporterParameter(
174: "Character Encoding");
175:
176: /**
177: * Property whose value is used as default for the {@link #CHARACTER_ENCODING CHARACTER_ENCODING} export parameter.
178: *
179: * @see JRProperties
180: */
181: public static final String PROPERTY_CHARACTER_ENCODING = JRProperties.PROPERTY_PREFIX
182: + "export.character.encoding";
183:
184: /**
185: * A {@link JRExportProgressMonitor} instance for monitoring export status. This is useful for users who need to be
186: * notified after each page is exported (a GUI tool that shows a progress bar might need this feature).
187: */
188: public static final JRExporterParameter PROGRESS_MONITOR = new JRExporterParameter(
189: "Progress Monitor");
190:
191: /**
192: * A parameter that allows users to move the entire content of each page horizontally. It is mostly useful for printing,
193: * when the report data does not fit inside the page margins.
194: */
195: public static final JRExporterParameter OFFSET_X = new JRExporterParameter(
196: "Offset X");
197:
198: /**
199: * A parameter that allows users to move the entire content of each page vertically. It is mostly useful for printing,
200: * when the report data does not fit inside the page margins.
201: */
202: public static final JRExporterParameter OFFSET_Y = new JRExporterParameter(
203: "Offset Y");
204:
205: /**
206: *
207: */
208: public static final JRExporterParameter FONT_MAP = new JRExporterParameter(
209: "Font Map");
210:
211: /**
212: *
213: */
214: public static final JRExporterParameter CLASS_LOADER = new JRExporterParameter(
215: "Class Loader");
216:
217: /**
218: * URL stream handler factory to be used while exporting the report.
219: * <p/>
220: * The values should be of type {@link java.net.URLStreamHandlerFactory java.net.URLStreamHandlerFactory}.
221: *
222: * @see net.sf.jasperreports.engine.util.JRResourcesUtil#createURL(String, java.net.URLStreamHandlerFactory)
223: */
224: public static final JRExporterParameter URL_HANDLER_FACTORY = new JRExporterParameter(
225: "URL Handler Factory");
226:
227: /**
228: * A {@link JRHyperlinkProducerFactory JRHyperlinkProducerFactory} which should be used for custom
229: * hyperlink types during export.
230: */
231: public static final JRExporterParameter HYPERLINK_PRODUCER_FACTORY = new JRExporterParameter(
232: "Hyperlink producer factory");
233:
234: }
|