001: /**
002: * ===========================================
003: * JFreeReport : a free Java reporting library
004: * ===========================================
005: *
006: * Project Info: http://reporting.pentaho.org/
007: *
008: * (C) Copyright 2001-2007, by Object Refinery Ltd, 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: * FlowCSVOutputProcessor.java
027: * ------------
028: * (C) Copyright 2001-2007, by Object Refinery Ltd, Pentaho Corporation and Contributors.
029: */package org.jfree.report.modules.output.table.csv;
030:
031: import org.jfree.report.layout.model.LogicalPageBox;
032: import org.jfree.report.layout.output.ContentProcessingException;
033: import org.jfree.report.layout.output.DisplayAllFlowSelector;
034: import org.jfree.report.layout.output.FlowSelector;
035: import org.jfree.report.layout.output.LogicalPageKey;
036: import org.jfree.report.layout.output.OutputProcessorMetaData;
037: import org.jfree.report.modules.output.table.base.AbstractTableOutputProcessor;
038: import org.jfree.report.modules.output.table.base.TableContentProducer;
039: import org.jfree.report.modules.output.table.csv.helper.CSVOutputProcessorMetaData;
040: import org.jfree.repository.ContentLocation;
041: import org.jfree.repository.NameGenerator;
042: import org.jfree.util.Configuration;
043:
044: /**
045: * Creation-Date: 09.05.2007, 14:36:28
046: *
047: * @author Thomas Morgner
048: */
049: public class FlowCSVOutputProcessor extends
050: AbstractTableOutputProcessor {
051: private OutputProcessorMetaData metaData;
052: private FlowSelector flowSelector;
053: private CSVPrinter printer;
054:
055: public FlowCSVOutputProcessor(final Configuration config) {
056: this .metaData = new CSVOutputProcessorMetaData(config,
057: CSVOutputProcessorMetaData.PAGINATION_MANUAL);
058: this .flowSelector = new DisplayAllFlowSelector();
059: this .printer = new CSVPrinter();
060: }
061:
062: public OutputProcessorMetaData getMetaData() {
063: return metaData;
064: }
065:
066: public void setFlowSelector(final FlowSelector flowSelector) {
067: this .flowSelector = flowSelector;
068: }
069:
070: public FlowSelector getFlowSelector() {
071: return flowSelector;
072: }
073:
074: protected void processTableContent(
075: final LogicalPageKey logicalPageKey,
076: final LogicalPageBox logicalPage,
077: final TableContentProducer contentProducer)
078: throws ContentProcessingException {
079: printer.print(logicalPage, contentProducer, metaData, false);
080: }
081:
082: protected void updateTableContent(
083: final LogicalPageKey logicalPageKey,
084: final LogicalPageBox logicalPageBox,
085: final TableContentProducer tableContentProducer,
086: final boolean performOutput)
087: throws ContentProcessingException {
088: printer.print(logicalPageBox, tableContentProducer, metaData,
089: true);
090: }
091:
092: protected void processingContentFinished() {
093: if (isContentGeneratable() == false) {
094: return;
095: }
096:
097: this .printer.close();
098: }
099:
100: public ContentLocation getContentLocation() {
101: return printer.getContentLocation();
102: }
103:
104: public void setContentLocation(final ContentLocation contentLocation) {
105: printer.setContentLocation(contentLocation);
106: }
107:
108: public NameGenerator getContentNameGenerator() {
109: return printer.getContentNameGenerator();
110: }
111:
112: public void setContentNameGenerator(
113: final NameGenerator contentNameGenerator) {
114: printer.setContentNameGenerator(contentNameGenerator);
115: }
116: }
|