pentaho-reporting-flow-engine-0.9.4/ 0000755 0001750 0001750 00000000000 11636167147 016061 5 ustar rene rene pentaho-reporting-flow-engine-0.9.4/source/ 0000755 0001750 0001750 00000000000 11305540676 017354 5 ustar rene rene pentaho-reporting-flow-engine-0.9.4/source/loader.properties 0000644 0001750 0001750 00000001246 11305540676 022743 0 ustar rene rene # # This file registers the loader-factories defined in JFreeReport. Do not # modify it, unless you really want to *remove* support for one of the created # types. org.pentaho.reporting.libraries.resourceloader.factory.type.org.jfree.report.ReportDataFactory=org.jfree.report.modules.factories.data.base.ReportDataFactoryXmlResourceFactory org.pentaho.reporting.libraries.resourceloader.factory.type.org.jfree.report.JFreeReport=org.jfree.report.modules.factories.report.base.JFreeReportXmlResourceFactory org.pentaho.reporting.libraries.resourceloader.factory.type.org.jfree.report.structure.SubReport=org.jfree.report.modules.factories.report.base.SubReportXmlResourceFactory pentaho-reporting-flow-engine-0.9.4/source/overview.html 0000644 0001750 0001750 00000000676 11305540676 022121 0 ustar rene rene
JFreeReport is a free report library for Java, designed to work withTableModel
data, providing on-screen print preview,
printing, export to PDF, HTML, text, Excel and CSV format.
Please visit http://jfreereport.pentaho.org/ for the latest information about JFreeReport. pentaho-reporting-flow-engine-0.9.4/source/org/ 0000755 0001750 0001750 00000000000 11305540676 020143 5 ustar rene rene pentaho-reporting-flow-engine-0.9.4/source/org/jfree/ 0000755 0001750 0001750 00000000000 11305540676 021236 5 ustar rene rene pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/ 0000755 0001750 0001750 00000000000 11305540700 022535 5 ustar rene rene pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/engine.css 0000644 0001750 0001750 00000002411 11305540676 024526 0 ustar rene rene /** * The StyleSheet mapping for the built-in elements. This mapping is only * active, if no namespace aware XML-parser touched the elements. */ @namespace xml url(http://www.w3.org/XML/1998/namespace); @namespace report url(http://jfreereport.sourceforge.net/namespaces/engine); @namespace url(http://jfreereport.sourceforge.net/namespaces/engine); /** * Everything except the content element is now considered a block-level element. * This looks like a sane default to me. * { display: block; } */ content { content: attr("report|content"); display: inline; } content[report|isDate=true] { content: format(attr("report|content", date), date); } content[report|isDate=true][format] { content: format(attr("report|content", date), date, attr("format",string)); } content[report|isNumber=true] { content: format(attr("report|content", number), number, "#,##0.00"); } content[report|isNumber=true][format] { content: format(attr("report|content", number), number, attr("format",string)); } content[report|isNumber=true][report|isInteger=true] { content: format(attr("report|content", number), number, "#,##0"); } content[report|isNumber=true][report|isInteger=true][format] { content: format(attr("report|content", number), number, attr("format",string)); } pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/flow/ 0000755 0001750 0001750 00000000000 11305540700 023504 5 ustar rene rene pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/flow/FlowControlOperation.java 0000644 0001750 0001750 00000007245 11305540700 030510 0 ustar rene rene /** * ======================================== * JFreeReport : a free Java report library * ======================================== * * Project Info: http://reporting.pentaho.org/ * * (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors. * * This library is free software; you can redistribute it and/or modify it under the terms * of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License along with this * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307, USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------ * $Id: FlowControlOperation.java 10756 2009-12-02 15:58:24Z tmorgner $ * ------------ * (C) Copyright 2000-2005, by Object Refinery Limited. * (C) Copyright 2005-2007, by Pentaho Corporation. */ package org.jfree.report.flow; /** * These objects define, how the iteration over the report definition affects * the data source. * * @author Thomas Morgner */ public class FlowControlOperation { /** * Stores the current datarow state for a later recall. Markpoints from different * sources can be nested. Marking does not change the user datasource. */ public static final FlowControlOperation MARK = new FlowControlOperation("mark"); /** * Requests that the datasource should be moved to the next row. An advance * operation does not change the current cursor position. The cursor is not * moved until a 'COMMIT' operation has been reached. * * Repeatable sections will perform an auto-commit based on the group in which * they are in. */ public static final FlowControlOperation ADVANCE = new FlowControlOperation("advance"); /** Recalls a marked position. */ public static final FlowControlOperation RECALL = new FlowControlOperation("recall"); /** Do nothing. */ public static final FlowControlOperation NO_OP = new FlowControlOperation("no-op"); /** * Finishes (and closes) the currently open context. If the last mark has been * closed, the datasource is also closed. *
* If all datasources have been closes, the empty datasource is used. This * datasource cannot be closed (closing has no effect on it). */ public static final FlowControlOperation DONE = new FlowControlOperation("done"); private final String myName; // for debug only /** * A commit checks for an pending advance request and commites that request * by moving the cursor of the currend datarow forward by one row. */ public static final FlowControlOperation COMMIT = new FlowControlOperation("commit"); protected FlowControlOperation(String name) { if (name == null) { throw new NullPointerException(); } myName = name; } public String toString() { return myName; } public boolean equals(final Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } final FlowControlOperation that = (FlowControlOperation) o; return myName.equals(that.myName); } public int hashCode() { return myName.hashCode(); } } pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/flow/ReportProcessor.java 0000644 0001750 0001750 00000003646 11305540676 027547 0 ustar rene rene /** * ======================================== * JFreeReport : a free Java report library * ======================================== * * Project Info: http://reporting.pentaho.org/ * * (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors. * * This library is free software; you can redistribute it and/or modify it under the terms * of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License along with this * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307, USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------ * $Id: ReportProcessor.java 10756 2009-12-02 15:58:24Z tmorgner $ * ------------ * (C) Copyright 2000-2005, by Object Refinery Limited. * (C) Copyright 2005-2007, by Pentaho Corporation. */ package org.jfree.report.flow; import org.jfree.report.DataSourceException; import org.jfree.report.ReportDataFactoryException; import org.jfree.report.ReportProcessingException; /** * The report processor is the public frontend to the reporting process. * In its most generic appearance, it accepts a report job and fully processes * that job without any other programmatic work required. * * @author Thomas Morgner */ public interface ReportProcessor { void processReport (ReportJob job) throws ReportDataFactoryException, DataSourceException, ReportProcessingException; } pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/flow/EmptyReportTarget.java 0000644 0001750 0001750 00000005665 11305540676 030040 0 ustar rene rene /** * ======================================== * JFreeReport : a free Java report library * ======================================== * * Project Info: http://reporting.pentaho.org/ * * (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors. * * This library is free software; you can redistribute it and/or modify it under the terms * of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License along with this * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307, USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------ * $Id: EmptyReportTarget.java 10756 2009-12-02 15:58:24Z tmorgner $ * ------------ * (C) Copyright 2000-2005, by Object Refinery Limited. * (C) Copyright 2005-2007, by Pentaho Corporation. */ package org.jfree.report.flow; import org.jfree.layouting.namespace.NamespaceDefinition; import org.jfree.layouting.util.AttributeMap; import org.jfree.report.DataFlags; import org.jfree.report.DataSourceException; import org.jfree.report.ReportProcessingException; /** * This target does nothing. * * @author Thomas Morgner */ public class EmptyReportTarget implements ReportTarget { private ReportJob job; private String reportDescriptor; public EmptyReportTarget(final ReportJob job, final String reportDescriptor) { this.job = job; this.reportDescriptor = reportDescriptor; } public void startReport(ReportStructureRoot report) throws DataSourceException, ReportProcessingException { } public void startElement(final AttributeMap attrs) throws DataSourceException, ReportProcessingException { } public void processText(String text) throws DataSourceException, ReportProcessingException { } public void processContent(final DataFlags value) throws DataSourceException, ReportProcessingException { } public void endElement(final AttributeMap attrs) throws DataSourceException, ReportProcessingException { } public void endReport(ReportStructureRoot report) throws DataSourceException, ReportProcessingException { } public NamespaceDefinition getNamespaceByUri(String uri) { return null; } public ReportJob getReportJob() { return job; } public String getExportDescriptor() { return reportDescriptor; } public void commit() throws ReportProcessingException { } } pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/flow/SinglePassReportProcessor.java 0000644 0001750 0001750 00000004636 11305540676 031540 0 ustar rene rene /** * ======================================== * JFreeReport : a free Java report library * ======================================== * * Project Info: http://reporting.pentaho.org/ * * (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors. * * This library is free software; you can redistribute it and/or modify it under the terms * of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License along with this * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307, USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------ * $Id: SinglePassReportProcessor.java 10756 2009-12-02 15:58:24Z tmorgner $ * ------------ * (C) Copyright 2000-2005, by Object Refinery Limited. * (C) Copyright 2005-2007, by Pentaho Corporation. */ package org.jfree.report.flow; import org.jfree.report.DataSourceException; import org.jfree.report.ReportDataFactoryException; import org.jfree.report.ReportProcessingException; /** * The abstract report processor implements a single-pass report processing * schema. This is suitable for most raw exports and the streaming-liblayout * export. * * @author Thomas Morgner */ public abstract class SinglePassReportProcessor extends AbstractReportProcessor { public SinglePassReportProcessor() { } protected abstract ReportTarget createReportTarget (ReportJob job) throws ReportProcessingException; /** * Bootstraps the local report processing. This way of executing the report * must be supported by *all* report processor implementations. It should * fully process the complete report. * * @param job * @throws ReportDataFactoryException */ public void processReport (ReportJob job) throws ReportDataFactoryException, DataSourceException, ReportProcessingException { processReportRun(job, createReportTarget(job)); } } pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/flow/ReportTarget.java 0000644 0001750 0001750 00000005264 11305540676 027014 0 ustar rene rene /** * ======================================== * JFreeReport : a free Java report library * ======================================== * * Project Info: http://reporting.pentaho.org/ * * (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors. * * This library is free software; you can redistribute it and/or modify it under the terms * of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License along with this * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307, USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------ * $Id: ReportTarget.java 10756 2009-12-02 15:58:24Z tmorgner $ * ------------ * (C) Copyright 2000-2005, by Object Refinery Limited. * (C) Copyright 2005-2007, by Pentaho Corporation. */ package org.jfree.report.flow; import org.jfree.layouting.namespace.NamespaceDefinition; import org.jfree.layouting.util.AttributeMap; import org.jfree.report.DataFlags; import org.jfree.report.DataSourceException; import org.jfree.report.ReportProcessingException; /** * The report target is responsible for the content creation. There are targets * which forward all incomming calls to LibLayout, while other targets process * the content directly. * * @author Thomas Morgner */ public interface ReportTarget { public void startReport (ReportStructureRoot report) throws DataSourceException, ReportProcessingException; public void startElement (final AttributeMap attrs) throws DataSourceException, ReportProcessingException; public void processText (final String text) throws DataSourceException, ReportProcessingException; public void processContent (final DataFlags value) throws DataSourceException, ReportProcessingException; public void endElement (final AttributeMap attrs) throws DataSourceException, ReportProcessingException; public void endReport (ReportStructureRoot report) throws DataSourceException, ReportProcessingException; public String getExportDescriptor(); public NamespaceDefinition getNamespaceByUri(String uri); public void commit() throws ReportProcessingException; } pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/flow/LibLayoutReportTarget.java 0000644 0001750 0001750 00000025255 11305540700 030627 0 ustar rene rene /** * ======================================== * JFreeReport : a free Java report library * ======================================== * * Project Info: http://reporting.pentaho.org/ * * (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors. * * This library is free software; you can redistribute it and/or modify it under the terms * of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License along with this * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307, USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------ * $Id: LibLayoutReportTarget.java 10756 2009-12-02 15:58:24Z tmorgner $ * ------------ * (C) Copyright 2000-2005, by Object Refinery Limited. * (C) Copyright 2005-2007, by Pentaho Corporation. */ package org.jfree.report.flow; import java.util.Iterator; import java.util.Map; import org.jfree.layouting.LayoutProcess; import org.jfree.layouting.LayoutProcessState; import org.jfree.layouting.StateException; import org.jfree.layouting.input.style.StyleSheet; import org.jfree.layouting.layouter.context.DocumentContext; import org.jfree.layouting.layouter.feed.InputFeed; import org.jfree.layouting.layouter.feed.InputFeedException; import org.jfree.layouting.namespace.NamespaceCollection; import org.jfree.layouting.namespace.NamespaceDefinition; import org.jfree.layouting.output.OutputProcessor; import org.jfree.layouting.util.AttributeMap; import org.jfree.report.DataFlags; import org.jfree.report.DataSourceException; import org.jfree.report.JFreeReport; import org.jfree.report.JFreeReportInfo; import org.jfree.report.ReportProcessingException; import org.pentaho.reporting.libraries.resourceloader.ResourceKey; import org.pentaho.reporting.libraries.resourceloader.ResourceManager; /** * Creation-Date: 07.03.2006, 18:56:37 * * @author Thomas Morgner */ public class LibLayoutReportTarget extends AbstractReportTarget implements StatefullReportTarget { protected static class LibLayoutReportTargetState implements ReportTargetState { private LayoutProcessState layoutProcess; private ReportJob reportJob; private ResourceKey baseResourceKey; private ResourceManager resourceManager; private NamespaceCollection namespaceCollection; public LibLayoutReportTargetState() { } public void fill (final LibLayoutReportTarget target) throws StateException { this.layoutProcess = target.getLayoutProcess().saveState(); this.reportJob = target.getReportJob(); this.baseResourceKey = target.getBaseResource(); this.resourceManager = target.getResourceManager(); this.namespaceCollection = target.getNamespaces(); } public ReportTarget restore(final OutputProcessor out) throws StateException { final LayoutProcess layoutProcess = this.layoutProcess.restore(out); return new LibLayoutReportTarget(reportJob, baseResourceKey, resourceManager, layoutProcess, namespaceCollection); } } private InputFeed feed; private NamespaceCollection namespaces; private LayoutProcess layoutProcess; /** * * @param reportJob * @param baseResourceKey may be null, if the report has not gone through the parser * @param resourceManager may be null, a generic resource manager will be built * @param layoutProcess */ public LibLayoutReportTarget (final ReportJob reportJob, final ResourceKey baseResourceKey, final ResourceManager resourceManager, final LayoutProcess layoutProcess) { super(reportJob, resourceManager, baseResourceKey); if (layoutProcess == null) { throw new NullPointerException(); } this.layoutProcess = layoutProcess; this.feed = layoutProcess.getInputFeed(); } protected LibLayoutReportTarget(final ReportJob reportJob, final ResourceKey baseResource, final ResourceManager resourceManager, final LayoutProcess layoutProcess, final NamespaceCollection namespaces) { this(reportJob, baseResource, resourceManager, layoutProcess); this.namespaces = namespaces; } public ReportTargetState saveState() throws StateException { final LibLayoutReportTargetState state = new LibLayoutReportTargetState(); state.fill(this); return state; } public void commit() { } public NamespaceCollection getNamespaces() { return namespaces; } public boolean isPagebreakEncountered() { return layoutProcess.isPagebreakEncountered(); } protected LayoutProcess getLayoutProcess() { return layoutProcess; } protected InputFeed getInputFeed () { return feed; } public void startReport (ReportStructureRoot report) throws DataSourceException, ReportProcessingException { try { final InputFeed feed = getInputFeed(); feed.startDocument(); feed.startMetaInfo(); feed.addDocumentAttribute(DocumentContext.BASE_RESOURCE_ATTR, report.getBaseResource()); feed.addDocumentAttribute(DocumentContext.RESOURCE_MANAGER_ATTR, report.getResourceManager()); String strictStyleMode = "false"; if ("true".equals(strictStyleMode)) { feed.addDocumentAttribute(DocumentContext.STRICT_STYLE_MODE, Boolean.TRUE); } final NamespaceDefinition[] namespaces = createDefaultNameSpaces(); for (int i = 0; i < namespaces.length; i++) { final NamespaceDefinition definition = namespaces[i]; feed.startMetaNode(); feed.setMetaNodeAttribute("type", "namespace"); feed.setMetaNodeAttribute("definition", definition); feed.endMetaNode(); } if (report instanceof JFreeReport) { final JFreeReport realReport = (JFreeReport) report; final int size = realReport.getStyleSheetCount(); for (int i = 0; i < size; i++) { final StyleSheet styleSheet = realReport.getStyleSheet(i); feed.startMetaNode(); feed.setMetaNodeAttribute("type", "style"); feed.setMetaNodeAttribute("#content", styleSheet); feed.endMetaNode(); } } feed.endMetaInfo(); this.namespaces = feed.getNamespaceCollection(); } catch (InputFeedException dse) { dse.printStackTrace(); throw new ReportProcessingException("Failed to process inputfeed", dse); } } public void startElement (final AttributeMap attrs) throws DataSourceException, ReportProcessingException { try { final String namespace = ReportTargetUtil.getNamespaceFromAttribute(attrs); final String type = ReportTargetUtil.getElemenTypeFromAttribute(attrs); final InputFeed feed = getInputFeed(); feed.startElement(namespace, type); handleAttributes(attrs); } catch (InputFeedException e) { throw new ReportProcessingException("Failed to process inputfeed", e); } } public void processText(String text) throws DataSourceException, ReportProcessingException { try { final InputFeed feed = getInputFeed(); feed.addContent(text); } catch (InputFeedException e) { throw new ReportProcessingException("Failed to process inputfeed", e); } } public void processContent (final DataFlags value) throws DataSourceException, ReportProcessingException { final InputFeed feed = getInputFeed(); try { feed.setAttribute(JFreeReportInfo.REPORT_NAMESPACE, "content", value.getValue()); feed.setAttribute(JFreeReportInfo.REPORT_NAMESPACE, "isChanged", String.valueOf(value.isChanged())); feed.setAttribute(JFreeReportInfo.REPORT_NAMESPACE, "isDate", String.valueOf(value.isDate())); feed.setAttribute(JFreeReportInfo.REPORT_NAMESPACE, "isNegative", String.valueOf(value.isNegative())); feed.setAttribute(JFreeReportInfo.REPORT_NAMESPACE, "isNull", String.valueOf(value.isNull())); feed.setAttribute(JFreeReportInfo.REPORT_NAMESPACE, "isNumber", String.valueOf(value.isNumeric())); feed.setAttribute(JFreeReportInfo.REPORT_NAMESPACE, "isPositive", String.valueOf(value.isPositive())); feed.setAttribute(JFreeReportInfo.REPORT_NAMESPACE, "isZero", String.valueOf(value.isZero())); } catch (InputFeedException e) { throw new ReportProcessingException("Failed to process inputfeed", e); } } public NamespaceDefinition getNamespaceByUri(String uri) { if (uri == null) { return null; } return namespaces.getDefinition(uri); } protected void handleAttributes(AttributeMap map) throws ReportProcessingException { try { final InputFeed feed = getInputFeed(); final String[] namespaces = map.getNameSpaces(); for (int i = 0; i < namespaces.length; i++) { final String namespace = namespaces[i]; final Map localAttrs = map.getAttributes(namespace); final Iterator it = localAttrs.entrySet().iterator(); while (it.hasNext()) { Map.Entry entry = (Map.Entry) it.next(); feed.setAttribute(namespace, (String) entry.getKey(), entry.getValue()); } } } catch (InputFeedException e) { throw new ReportProcessingException("Failed to set attribute", e); } } public void endElement (final AttributeMap attrs) throws DataSourceException, ReportProcessingException { final InputFeed feed = getInputFeed(); try { feed.endElement(); } catch (InputFeedException e) { throw new ReportProcessingException("Failed to process inputfeed", e); } } public void endReport (ReportStructureRoot report) throws DataSourceException, ReportProcessingException { try { getInputFeed().endDocument(); } catch (InputFeedException e) { throw new ReportProcessingException("Failed to process inputfeed", e); } } public void resetPagebreakFlag() { getInputFeed().resetPageBreakFlag(); } public String getExportDescriptor() { return getLayoutProcess().getOutputMetaData().getExportDescriptor(); } } pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/flow/FlowController.java 0000644 0001750 0001750 00000006733 11305540676 027347 0 ustar rene rene /** * ======================================== * JFreeReport : a free Java report library * ======================================== * * Project Info: http://reporting.pentaho.org/ * * (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors. * * This library is free software; you can redistribute it and/or modify it under the terms * of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License along with this * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307, USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------ * $Id: FlowController.java 10756 2009-12-02 15:58:24Z tmorgner $ * ------------ * (C) Copyright 2000-2005, by Object Refinery Limited. * (C) Copyright 2005-2007, by Pentaho Corporation. */ package org.jfree.report.flow; import org.jfree.report.DataSourceException; import org.jfree.report.ReportDataFactoryException; import org.jfree.report.data.ExpressionSlot; import org.jfree.report.data.GlobalMasterRow; import org.jfree.report.data.PrecomputedValueRegistry; /** * A flow-controller is an immutable object. Whenever an method, that may change * the internal state of the controller, is invoked, a new instance of the * controller is returned. * * @author Thomas Morgner */ public interface FlowController { public FlowController performOperation(FlowControlOperation operation) throws DataSourceException; public GlobalMasterRow getMasterRow(); public ReportContext getReportContext(); public String getExportDescriptor(); public boolean isAdvanceRequested(); public FlowController performQuery(final String query) throws ReportDataFactoryException, DataSourceException; public FlowController performSubReportQuery(final String query, final ParameterMapping[] inputParameters, final ParameterMapping[] outputParameters) throws ReportDataFactoryException, DataSourceException; /** * Activates expressions that compute running values. This does not activate * precomputed expressions. * * @param expressions * @return * @throws DataSourceException */ public FlowController activateExpressions(final ExpressionSlot[] expressions) throws DataSourceException; /** * Returns the current expression slots of all currently active expressions. * (Maybe we should limit the access to the name and value of the expression * instead?) * * @return * @throws DataSourceException */ public ExpressionSlot[] getActiveExpressions () throws DataSourceException; public FlowController deactivateExpressions() throws DataSourceException; public ReportJob getReportJob(); public FlowController performReturnFromQuery() throws DataSourceException; public FlowController createPrecomputeInstance () throws DataSourceException; public PrecomputedValueRegistry getPrecomputedValueRegistry(); } pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/flow/ReportStructureRoot.java 0000644 0001750 0001750 00000003731 11305540676 030427 0 ustar rene rene /** * ======================================== * JFreeReport : a free Java report library * ======================================== * * Project Info: http://reporting.pentaho.org/ * * (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors. * * This library is free software; you can redistribute it and/or modify it under the terms * of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License along with this * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307, USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------ * $Id: ReportStructureRoot.java 10756 2009-12-02 15:58:24Z tmorgner $ * ------------ * (C) Copyright 2000-2005, by Object Refinery Limited. * (C) Copyright 2005-2007, by Pentaho Corporation. */ package org.jfree.report.flow; import java.util.Locale; import org.jfree.report.ReportDataFactory; import org.jfree.report.util.ReportParameters; import org.pentaho.reporting.libraries.base.config.Configuration; import org.pentaho.reporting.libraries.resourceloader.ResourceManager; import org.pentaho.reporting.libraries.resourceloader.ResourceKey; public interface ReportStructureRoot { public ReportDataFactory getDataFactory(); public ReportParameters getInputParameters(); public Configuration getConfiguration(); public Locale getLocale(); public ResourceManager getResourceManager(); public ResourceKey getBaseResource(); } pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/flow/layoutprocessor/ 0000755 0001750 0001750 00000000000 11305540700 026761 5 ustar rene rene ././@LongLink 0000000 0000000 0000000 00000000160 00000000000 011562 L ustar root root pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/flow/layoutprocessor/SubReportLayoutController.java pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/flow/layoutprocessor/SubReportLayoutCont0000644 0001750 0001750 00000004742 11305540676 032676 0 ustar rene rene /** * ======================================== * JFreeReport : a free Java report library * ======================================== * * Project Info: http://reporting.pentaho.org/ * * (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors. * * This library is free software; you can redistribute it and/or modify it under the terms * of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License along with this * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307, USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------ * $Id: SubReportLayoutController.java 10756 2009-12-02 15:58:24Z tmorgner $ * ------------ * (C) Copyright 2000-2005, by Object Refinery Limited. * (C) Copyright 2005-2007, by Pentaho Corporation. */ package org.jfree.report.flow.layoutprocessor; import org.jfree.report.DataSourceException; import org.jfree.report.ReportDataFactoryException; import org.jfree.report.ReportProcessingException; import org.jfree.report.flow.FlowController; import org.jfree.report.flow.ReportTarget; import org.jfree.report.structure.SubReport; /** * Creation-Date: 24.11.2006, 13:56:57 * * @author Thomas Morgner */ public class SubReportLayoutController extends SectionLayoutController { public SubReportLayoutController() { } protected FlowController startData(final ReportTarget target, final FlowController fc) throws DataSourceException, ReportProcessingException, ReportDataFactoryException { final SubReport report = (SubReport) getElement(); return fc.performSubReportQuery(report.getQuery(), report.getInputMappings(), report.getExportMappings()); } protected FlowController finishData(final ReportTarget target, final FlowController fc) throws DataSourceException, ReportProcessingException { return fc.performReturnFromQuery(); } } ././@LongLink 0000000 0000000 0000000 00000000156 00000000000 011567 L ustar root root pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/flow/layoutprocessor/ElementLayoutController.java pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/flow/layoutprocessor/ElementLayoutContro0000644 0001750 0001750 00000045146 11305540676 032706 0 ustar rene rene /** * ======================================== * JFreeReport : a free Java report library * ======================================== * * Project Info: http://reporting.pentaho.org/ * * (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors. * * This library is free software; you can redistribute it and/or modify it under the terms * of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License along with this * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307, USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------ * $Id: ElementLayoutController.java 10756 2009-12-02 15:58:24Z tmorgner $ * ------------ * (C) Copyright 2000-2005, by Object Refinery Limited. * (C) Copyright 2005-2007, by Pentaho Corporation. */ package org.jfree.report.flow.layoutprocessor; import org.jfree.report.DataSourceException; import org.jfree.report.ReportDataFactoryException; import org.jfree.report.ReportProcessingException; import org.jfree.report.data.ExpressionSlot; import org.jfree.report.data.PrecomputeNodeKey; import org.jfree.report.data.PrecomputedExpressionSlot; import org.jfree.report.data.PrecomputedValueRegistry; import org.jfree.report.data.RunningExpressionSlot; import org.jfree.report.data.StaticExpressionRuntimeData; import org.jfree.report.expressions.Expression; import org.jfree.report.flow.FlowControlOperation; import org.jfree.report.flow.FlowController; import org.jfree.report.flow.ReportTarget; import org.jfree.report.flow.LayoutExpressionRuntime; import org.jfree.report.structure.Element; import org.jfree.layouting.util.AttributeMap; /** * Creation-Date: 24.11.2006, 13:56:30 * * @author Thomas Morgner */ public abstract class ElementLayoutController implements LayoutController { protected static class ElementPrecomputeKey implements PrecomputeNodeKey { private String name; private String id; private String namespace; private String tagName; public ElementPrecomputeKey(final Element element) { this.name = element.getName(); this.tagName = element.getType(); this.namespace = element.getNamespace(); this.id = element.getId(); } public boolean equals(final Object obj) { if (this == obj) { return true; } if (obj == null || getClass() != obj.getClass()) { return false; } final ElementPrecomputeKey that = (ElementPrecomputeKey) obj; if (id != null ? !id.equals(that.id) : that.id != null) { return false; } if (name != null ? !name.equals(that.name) : that.name != null) { return false; } if (namespace != null ? !namespace.equals( that.namespace) : that.namespace != null) { return false; } if (tagName != null ? !tagName.equals( that.tagName) : that.tagName != null) { return false; } return true; } public int hashCode() { int result = (name != null ? name.hashCode() : 0); result = 29 * result + (id != null ? id.hashCode() : 0); result = 29 * result + (namespace != null ? namespace.hashCode() : 0); result = 29 * result + (tagName != null ? tagName.hashCode() : 0); return result; } public boolean equals(final PrecomputeNodeKey otherKey) { return false; } } public static final int NOT_STARTED = 0; public static final int OPENED = 1; public static final int WAITING_FOR_JOIN = 2; public static final int FINISHING = 3; //public static final int JOINING = 4; public static final int FINISHED = 4; private int processingState; private FlowController flowController; private Element element; private LayoutController parent; private boolean precomputing; private AttributeMap attributeMap; private int expressionsCount; private int iterationCount; protected ElementLayoutController() { this.processingState = ElementLayoutController.NOT_STARTED; } public String toString() { return "ElementLayoutController{" + "processingState=" + processingState + ", element=" + element + ", precomputing=" + precomputing + ", expressionsCount=" + expressionsCount + ", iterationCount=" + iterationCount + '}'; } /** * Retrieves the parent of this layout controller. This allows childs to query * their context. * * @return the layout controller's parent tonull
if there is no
* parent.
*/
public LayoutController getParent()
{
return parent;
}
/**
* Initializes the layout controller. This method is called exactly once. It
* is the creators responsibility to call this method.
*
* Calling initialize after the first advance must result in a
* IllegalStateException.
*
* @param node the currently processed object or layout node.
* @param flowController the current flow controller.
* @param parent the parent layout controller that was responsible for
* instantiating this controller.
* @throws DataSourceException if there was a problem reading data from
* the datasource.
* @throws ReportProcessingException if there was a general problem during
* the report processing.
* @throws ReportDataFactoryException if a query failed.
*/
public void initialize(final Object node,
final FlowController flowController,
final LayoutController parent)
throws DataSourceException, ReportDataFactoryException,
ReportProcessingException
{
if (processingState != ElementLayoutController.NOT_STARTED)
{
throw new IllegalStateException();
}
this.element = (Element) node;
this.flowController = flowController;
this.parent = parent;
this.iterationCount = -1;
}
/**
* Advances the layout controller to the next state. This method delegates the
* call to one of the following methods: null
if there is no
* parent.
*/
public LayoutController getParent()
{
return parent;
}
/**
* Initializes the layout controller. This method is called exactly once. It
* is the creators responsibility to call this method.
*
* Calling initialize after the first advance must result in a
* IllegalStateException.
*
* @param node the currently processed object or layout node.
* @param flowController the current flow controller.
* @param parent the parent layout controller that was responsible for
* instantiating this controller.
* @throws DataSourceException if there was a problem reading data from
* the datasource.
* @throws ReportProcessingException if there was a general problem during
* the report processing.
* @throws ReportDataFactoryException if a query failed.
*/
public void initialize(final Object node, final FlowController flowController,
final LayoutController parent)
throws DataSourceException, ReportDataFactoryException,
ReportProcessingException
{
if (initialized == true)
{
throw new IllegalStateException();
}
this.initialized = true;
this.node = node;
this.flowController = flowController;
this.parent = parent;
}
public Object clone()
{
try
{
return super.clone();
}
catch (CloneNotSupportedException e)
{
throw new IllegalStateException("Clone failed?");
}
}
public FlowController getFlowController()
{
return flowController;
}
public Object getNode()
{
return node;
}
public boolean isInitialized()
{
return initialized;
}
/**
* Derives a copy of this controller that is suitable to perform a
* precomputation.
*
* @param fc
* @return
*/
public LayoutController createPrecomputeInstance(FlowController fc)
{
final AbstractLayoutController lc = (AbstractLayoutController) clone();
lc.flowController = fc;
return lc;
}
}
././@LongLink 0000000 0000000 0000000 00000000160 00000000000 011562 L ustar root root pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/flow/layoutprocessor/BufferingLayoutController.java pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/flow/layoutprocessor/BufferingLayoutCont0000644 0001750 0001750 00000014751 11305540676 032661 0 ustar rene rene /**
* ========================================
* JFreeReport : a free Java report library
* ========================================
*
* Project Info: http://reporting.pentaho.org/
*
* (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors.
*
* This library is free software; you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation;
* either version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* ------------
* $Id: BufferingLayoutController.java 10756 2009-12-02 15:58:24Z tmorgner $
* ------------
* (C) Copyright 2000-2005, by Object Refinery Limited.
* (C) Copyright 2005-2007, by Pentaho Corporation.
*/
package org.jfree.report.flow.layoutprocessor;
import org.jfree.report.DataSourceException;
import org.jfree.report.ReportDataFactoryException;
import org.jfree.report.ReportProcessingException;
import org.jfree.report.flow.FlowController;
import org.jfree.report.flow.ReportTarget;
/**
* Todo: Document me!
*
* @author Thomas Morgner
* @since 05.03.2007
*/
public abstract class BufferingLayoutController
extends AbstractLayoutController
{
private BufferedReportTarget reportTarget;
private LayoutController delegate;
private boolean finished;
protected BufferingLayoutController()
{
reportTarget = new BufferedReportTarget();
}
/**
* Advances the processing position.
*
* @param target the report target that receives generated events.
* @return the new layout controller instance representing the new state.
*
* @throws DataSourceException if there was a problem reading data from
* the datasource.
* @throws ReportProcessingException if there was a general problem during
* the report processing.
* @throws ReportDataFactoryException if a query failed.
*/
public LayoutController advance(final ReportTarget target)
throws DataSourceException, ReportDataFactoryException,
ReportProcessingException
{
reportTarget.setTarget(target);
if (delegate != null)
{
try
{
final BufferingLayoutController bc = (BufferingLayoutController) clone();
bc.delegate = delegate.advance(reportTarget);
return bc;
}
finally
{
reportTarget.setTarget(null);
}
}
// write all buffered changes to the real report target.
reportTarget.close(target);
if (getParent() == null)
{
final BufferingLayoutController bc = (BufferingLayoutController) clone();
bc.finished = true;
return bc;
}
return joinWithParent();
}
/**
* Joins the layout controller with the parent. This simply calls
* {@link #join(org.jfree.report.flow.FlowController)} on the parent. A join
* operation is necessary to propagate changes in the flow-controller to the
* parent for further processing.
*
* @return the joined parent.
* @throws IllegalStateException if this layout controller has no parent.
* @throws org.jfree.report.ReportProcessingException
* @throws org.jfree.report.ReportDataFactoryException
* @throws org.jfree.report.DataSourceException
*/
protected LayoutController joinWithParent()
throws ReportProcessingException, ReportDataFactoryException,
DataSourceException
{
final LayoutController parent = getParent();
if (parent == null)
{
// skip to the next step ..
throw new IllegalStateException("There is no parent to join with. " +
"This should not happen in a sane environment!");
}
return parent.join(getFlowController());
}
/**
* Initializes the layout controller. This method is called exactly once. It
* is the creators responsibility to call this method.
*
* Calling initialize after the first advance must result in a
* IllegalStateException.
*
* @param node the currently processed object or layout node.
* @param flowController the current flow controller.
* @param parent the parent layout controller that was responsible for
* instantiating this controller.
* @throws DataSourceException if there was a problem reading data from
* the datasource.
* @throws ReportProcessingException if there was a general problem during
* the report processing.
* @throws ReportDataFactoryException if a query failed.
*/
public void initialize(final Object node, final FlowController flowController,
final LayoutController parent)
throws DataSourceException, ReportDataFactoryException,
ReportProcessingException
{
super.initialize(node, flowController, parent);
delegate = getInitialDelegate();
}
protected abstract LayoutController getInitialDelegate();
public boolean isAdvanceable()
{
if (delegate == null)
{
return finished == false;
}
return delegate.isAdvanceable();
}
/**
* Joins with a delegated process flow. This is generally called from a child
* flow and should *not* (I mean it!) be called from outside. If you do,
* you'll suffer.
*
* @param flowController the flow controller of the parent.
* @return the joined layout controller that incorperates all changes from
* the delegate.
*/
public LayoutController join(final FlowController flowController)
throws ReportProcessingException, DataSourceException
{
// the delegation is finished, the element has returned.
final BufferingLayoutController bc = (BufferingLayoutController) clone();
bc.delegate = null;
return bc;
}
public Object clone()
{
final BufferingLayoutController o = (BufferingLayoutController) super.clone();
o.reportTarget = (BufferedReportTarget) reportTarget.clone();
return o;
}
}
././@LongLink 0000000 0000000 0000000 00000000155 00000000000 011566 L ustar root root pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/flow/layoutprocessor/ReportLayoutController.java pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/flow/layoutprocessor/ReportLayoutControl0000644 0001750 0001750 00000005173 11305540676 032740 0 ustar rene rene /**
* ========================================
* JFreeReport : a free Java report library
* ========================================
*
* Project Info: http://reporting.pentaho.org/
*
* (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors.
*
* This library is free software; you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation;
* either version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* ------------
* $Id: ReportLayoutController.java 10756 2009-12-02 15:58:24Z tmorgner $
* ------------
* (C) Copyright 2000-2005, by Object Refinery Limited.
* (C) Copyright 2005-2007, by Pentaho Corporation.
*/
package org.jfree.report.flow.layoutprocessor;
import org.jfree.report.DataSourceException;
import org.jfree.report.JFreeReport;
import org.jfree.report.ReportDataFactoryException;
import org.jfree.report.ReportProcessingException;
import org.jfree.report.flow.FlowController;
import org.jfree.report.flow.ReportTarget;
/**
* Creation-Date: 24.11.2006, 13:56:50
*
* @author Thomas Morgner
*/
public class ReportLayoutController extends SectionLayoutController
{
public ReportLayoutController()
{
}
protected FlowController startData(final ReportTarget target,
final FlowController fc)
throws DataSourceException,
ReportProcessingException, ReportDataFactoryException
{
final JFreeReport report = (JFreeReport) getElement();
target.startReport(report);
return fc.performQuery(report.getQuery());
}
protected FlowController finishData(final ReportTarget target,
final FlowController fc)
throws DataSourceException, ReportProcessingException
{
final JFreeReport report = (JFreeReport) getElement();
target.endReport(report);
// do something fancy ... query the data, for instance.
// this implies that we create a new global datarow.
return fc.performReturnFromQuery();
}
}
././@LongLink 0000000 0000000 0000000 00000000153 00000000000 011564 L ustar root root pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/flow/layoutprocessor/LayoutControllerUtil.java pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/flow/layoutprocessor/LayoutControllerUti0000644 0001750 0001750 00000044566 11305540676 032742 0 ustar rene rene /**
* ========================================
* JFreeReport : a free Java report library
* ========================================
*
* Project Info: http://reporting.pentaho.org/
*
* (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors.
*
* This library is free software; you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation;
* either version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* ------------
* $Id: LayoutControllerUtil.java 10756 2009-12-02 15:58:24Z tmorgner $
* ------------
* (C) Copyright 2000-2005, by Object Refinery Limited.
* (C) Copyright 2005-2007, by Pentaho Corporation.
*/
package org.jfree.report.flow.layoutprocessor;
import java.util.Iterator;
import java.util.Map;
import org.jfree.layouting.input.style.CSSDeclarationRule;
import org.jfree.layouting.input.style.CSSStyleRule;
import org.jfree.layouting.input.style.StyleKey;
import org.jfree.layouting.input.style.StyleKeyRegistry;
import org.jfree.layouting.input.style.StyleRule;
import org.jfree.layouting.input.style.values.CSSValue;
import org.jfree.layouting.namespace.NamespaceDefinition;
import org.jfree.layouting.namespace.Namespaces;
import org.jfree.layouting.util.AttributeMap;
import org.jfree.report.DataSourceException;
import org.jfree.report.EmptyReportData;
import org.jfree.report.JFreeReportInfo;
import org.jfree.report.ReportDataFactoryException;
import org.jfree.report.ReportProcessingException;
import org.jfree.report.data.GlobalMasterRow;
import org.jfree.report.data.PrecomputeNode;
import org.jfree.report.data.PrecomputeNodeKey;
import org.jfree.report.data.PrecomputedValueRegistry;
import org.jfree.report.data.ReportDataRow;
import org.jfree.report.data.StaticExpressionRuntimeData;
import org.jfree.report.expressions.Expression;
import org.jfree.report.expressions.ExpressionRuntime;
import org.jfree.report.flow.EmptyReportTarget;
import org.jfree.report.flow.FlowControlOperation;
import org.jfree.report.flow.FlowController;
import org.jfree.report.flow.LayoutExpressionRuntime;
import org.jfree.report.flow.ReportContext;
import org.jfree.report.flow.ReportJob;
import org.jfree.report.flow.ReportStructureRoot;
import org.jfree.report.flow.ReportTarget;
import org.jfree.report.structure.Element;
import org.jfree.report.structure.Group;
import org.jfree.report.structure.Node;
import org.jfree.report.structure.Section;
import org.pentaho.reporting.libraries.resourceloader.Resource;
import org.pentaho.reporting.libraries.resourceloader.ResourceKey;
import org.pentaho.reporting.libraries.resourceloader.ResourceManager;
/**
* Creation-Date: 24.11.2006, 15:01:22
*
* @author Thomas Morgner
*/
public class LayoutControllerUtil
{
public static final EmptyReportData EMPTY_REPORT_DATA = new EmptyReportData();
private LayoutControllerUtil()
{
}
public static int findNodeInParent(final Section parentSection,
final Node n)
{
final Node[] nodes = parentSection.getNodeArray();
for (int i = 0; i < nodes.length; i++)
{
final Node node = nodes[i];
if (node == n)
{
return i;
}
}
return -1;
}
public static StaticExpressionRuntimeData getStaticExpressionRuntime
(final FlowController fc,
final Object declaringParent)
{
final GlobalMasterRow dataRow = fc.getMasterRow();
final ReportJob reportJob = fc.getReportJob();
final StaticExpressionRuntimeData sdd = new StaticExpressionRuntimeData();
sdd.setData(dataRow.getReportDataRow().getReportData());
sdd.setDeclaringParent(declaringParent);
sdd.setConfiguration(reportJob.getConfiguration());
sdd.setReportContext(fc.getReportContext());
return sdd;
}
public static LayoutExpressionRuntime getExpressionRuntime
(final FlowController fc, final Object node)
{
final LayoutExpressionRuntime ler = new LayoutExpressionRuntime();
ler.setConfiguration(fc.getReportJob().getConfiguration());
ler.setReportContext(fc.getReportContext());
final GlobalMasterRow masterRow = fc.getMasterRow();
ler.setDataRow(masterRow.getGlobalView());
final ReportDataRow reportDataRow = masterRow.getReportDataRow();
if (reportDataRow == null)
{
ler.setData(EMPTY_REPORT_DATA);
ler.setCurrentRow(-1);
}
else
{
ler.setData(reportDataRow.getReportData());
ler.setCurrentRow(reportDataRow.getCursor());
}
ler.setDeclaringParent(node);
return ler;
}
public static FlowController processFlowOperations(FlowController fc,
final FlowControlOperation[] ops)
throws DataSourceException
{
for (int i = 0; i < ops.length; i++)
{
final FlowControlOperation op = ops[i];
fc = fc.performOperation(op);
}
return fc;
}
/**
* Checks, whether the current group should continue. If there is no group, we assume that we should continue. (This
* emulates the control-break-algorithm's default behaviour if testing an empty set of arguments.)
*
* @param fc the current flow controller holding the data
* @param node the current node.
* @return true, if the group is finished and we should stop reiterating it, false if the group is not finished and we
* can start iterating it again.
* @throws org.jfree.report.DataSourceException
*
*/
public static boolean isGroupFinished(final FlowController fc,
final Node node)
throws DataSourceException
{
final Node nodeParent = node.getParent();
if (nodeParent == null)
{
return false;
}
Group group = nodeParent.getGroup();
if (group == null)
{
return false;
}
// maybe we can move this state into the layoutstate itself so that
// we do not have to rebuild that crap all the time.
LayoutExpressionRuntime ler = null;
// OK, now we are almost complete.
while (group != null)
{
if (ler == null)
{
ler = getExpressionRuntime(fc, node);
}
ler.setDeclaringParent(group);
final Expression groupingExpression = group.getGroupingExpression();
if (groupingExpression != null)
{
groupingExpression.setRuntime(ler);
final Object groupFinished;
try
{
groupFinished = groupingExpression.computeValue();
}
finally
{
groupingExpression.setRuntime(null);
}
if (Boolean.TRUE.equals(groupFinished))
{
// If the group expression returns true, we should pack our belongings
// and stop with that process. The group is finished.
// In Cobol, this would mean that one of the group-fields has changed.
return true;
}
}
final Node parent = group.getParent();
if (parent == null)
{
group = null;
}
else
{
group = parent.getGroup();
}
}
return false;
}
private static void mergeDeclarationRule(final CSSDeclarationRule target,
final CSSDeclarationRule source)
{
final StyleKey[] styleKeys = source.getPropertyKeysAsArray();
for (int i = 0; i < styleKeys.length; i++)
{
final StyleKey key = styleKeys[i];
final CSSValue value = source.getPropertyCSSValue(key);
if (value == null)
{
continue;
}
final boolean sourceImportant = source.isImportant(key);
final boolean targetImportant = target.isImportant(key);
if (targetImportant)
{
continue;
}
target.setPropertyValue(key, value);
target.setImportant(key, sourceImportant);
}
}
private static CSSDeclarationRule processStyleAttribute
(final Object styleAttributeValue,
final Element node,
final ExpressionRuntime runtime,
CSSDeclarationRule targetRule)
throws DataSourceException
{
if (targetRule == null)
{
try
{
targetRule = (CSSDeclarationRule) node.getStyle().clone();
}
catch (CloneNotSupportedException e)
{
targetRule = new CSSStyleRule(null, null);
}
}
if (styleAttributeValue instanceof String)
{
// ugly, we have to parse that thing. Cant think of nothing
// worse than that.
final String styleText = (String) styleAttributeValue;
try
{
final ReportContext reportContext = runtime.getReportContext();
final ReportStructureRoot root = reportContext.getReportStructureRoot();
final ResourceKey baseResource = root.getBaseResource();
final ResourceManager resourceManager = root.getResourceManager();
final byte[] bytes = styleText.getBytes("UTF-8");
final ResourceKey key = resourceManager.createKey(bytes);
final Resource resource = resourceManager.create
(key, baseResource, StyleRule.class);
final CSSDeclarationRule parsedRule =
(CSSDeclarationRule) resource.getResource();
mergeDeclarationRule(targetRule, parsedRule);
}
catch (Exception e)
{
// ignore ..
e.printStackTrace();
}
}
else if (styleAttributeValue instanceof CSSStyleRule)
{
final CSSStyleRule styleRule =
(CSSStyleRule) styleAttributeValue;
mergeDeclarationRule(targetRule, styleRule);
}
// ok, not lets fill in the stuff from the style expressions ..
final Map styleExpressions = node.getStyleExpressions();
final Iterator styleExIt = styleExpressions.entrySet().iterator();
while (styleExIt.hasNext())
{
final Map.Entry entry = (Map.Entry) styleExIt.next();
final String name = (String) entry.getKey();
final Expression expression = (Expression) entry.getValue();
try
{
expression.setRuntime(runtime);
final Object value = expression.computeValue();
final StyleKey keyByName =
StyleKeyRegistry.getRegistry().findKeyByName(name);
if (value instanceof CSSValue)
{
final CSSValue cssvalue = (CSSValue) value;
if (keyByName != null)
{
targetRule.setPropertyValue(keyByName, cssvalue);
}
else
{
targetRule.setPropertyValueAsString(name, cssvalue.getCSSText());
}
}
else if (value != null)
{
targetRule.setPropertyValueAsString(name, String.valueOf(value));
}
}
finally
{
expression.setRuntime(null);
}
}
return targetRule;
}
private static AttributeMap collectAttributes(final Element node,
final ExpressionRuntime runtime)
throws DataSourceException
{
AttributeMap attributes = node.getAttributeMap();
final AttributeMap attributeExpressions = node.getAttributeExpressionMap();
if (attributeExpressions.isEmpty())
{
return attributes;
}
final String[] namespaces = attributeExpressions.getNameSpaces();
for (int i = 0; i < namespaces.length; i++)
{
final String namespace = namespaces[i];
final Map attrEx = attributeExpressions.getAttributes(namespace);
final Iterator attributeExIt = attrEx.entrySet().iterator();
while (attributeExIt.hasNext())
{
final Map.Entry entry = (Map.Entry) attributeExIt.next();
final String name = (String) entry.getKey();
final Expression expression = (Expression) entry.getValue();
try
{
expression.setRuntime(runtime);
final Object value = expression.computeValue();
if (attributes.isReadOnly())
{
attributes = new AttributeMap(attributes);
}
attributes.setAttribute(namespace, name, value);
}
finally
{
expression.setRuntime(null);
}
}
}
return attributes.createUnmodifiableMap();
}
public static AttributeMap processAttributes(final Element node,
final ReportTarget target,
final ExpressionRuntime runtime)
throws DataSourceException
{
final AttributeMap attributes = collectAttributes(node, runtime);
CSSDeclarationRule rule = null;
final String[] attrNamespaces = attributes.getNameSpaces();
for (int i = 0; i < attrNamespaces.length; i++)
{
final String namespace = attrNamespaces[i];
final Map attributeMap = attributes.getAttributes(namespace);
if (attributeMap == null || attributeMap.isEmpty())
{
continue;
}
final NamespaceDefinition nsDef = target.getNamespaceByUri(namespace);
final Iterator attributeIt = attributeMap.entrySet().iterator();
while (attributeIt.hasNext())
{
final Map.Entry entry = (Map.Entry) attributeIt.next();
final String key = (String) entry.getKey();
if (isStyleAttribute(nsDef, node.getType(), key))
{
final Object styleAttributeValue = entry.getValue();
rule = processStyleAttribute(styleAttributeValue, node, runtime, rule);
}
}
}
// Just in case there was no style-attribute but there are style-expressions
if (rule == null)
{
rule = processStyleAttribute(null, node, runtime, rule);
}
if (rule != null && rule.isEmpty() == false)
{
final AttributeMap retval = new AttributeMap(attributes);
retval.setAttribute(Namespaces.LIBLAYOUT_NAMESPACE, "style", rule);
retval.makeReadOnly();
return retval;
}
return attributes;
}
private static boolean isStyleAttribute(final NamespaceDefinition def,
final String elementName,
final String attrName)
{
if (def == null)
{
return false;
}
final String[] styleAttr = def.getStyleAttribute(elementName);
for (int i = 0; i < styleAttr.length; i++)
{
final String styleAttrib = styleAttr[i];
if (attrName.equals(styleAttrib))
{
return true;
}
}
return false;
}
public static AttributeMap createEmptyMap(final String namespace,
final String tagName)
{
final AttributeMap map = new AttributeMap();
map.setAttribute(JFreeReportInfo.REPORT_NAMESPACE,
Element.NAMESPACE_ATTRIBUTE, namespace);
map.setAttribute(JFreeReportInfo.REPORT_NAMESPACE,
Element.TYPE_ATTRIBUTE, tagName);
return map;
}
public static Object performPrecompute(final int expressionPosition,
final PrecomputeNodeKey nodeKey,
final LayoutController layoutController,
final FlowController flowController)
throws ReportProcessingException, ReportDataFactoryException,
DataSourceException
{
final FlowController fc = flowController.createPrecomputeInstance();
final PrecomputedValueRegistry pcvr = fc.getPrecomputedValueRegistry();
pcvr.startElementPrecomputation(nodeKey);
final LayoutController rootLc = layoutController.createPrecomputeInstance(fc);
final LayoutController rootParent = rootLc.getParent();
final ReportTarget target = new EmptyReportTarget(fc.getReportJob(), fc.getExportDescriptor());
LayoutController lc = rootLc;
while (lc.isAdvanceable())
{
lc = lc.advance(target);
while (lc.isAdvanceable() == false && lc.getParent() != null)
{
final LayoutController parent = lc.getParent();
lc = parent.join(lc.getFlowController());
}
}
target.commit();
final PrecomputeNode precomputeNode = pcvr.currentNode();
final Object functionResult = precomputeNode.getFunctionResult(expressionPosition);
pcvr.finishElementPrecomputation(nodeKey);
return functionResult;
// throw new IllegalStateException
// ("Ups - we did not get to the root parent again. This is awful and we cannot continue.");
}
public static LayoutController skipInvisibleElement(final LayoutController layoutController)
throws ReportProcessingException, ReportDataFactoryException, DataSourceException
{
final FlowController fc = layoutController.getFlowController();
final ReportTarget target = new EmptyReportTarget(fc.getReportJob(), fc.getExportDescriptor());
final LayoutController rootParent = layoutController.getParent();
// Now start to iterate until the derived layout controller 'lc' that has this given parent
// wants to join.
LayoutController lc = layoutController;
while (lc.isAdvanceable())
{
lc = lc.advance(target);
while (lc.isAdvanceable() == false && lc.getParent() != null)
{
final LayoutController parent = lc.getParent();
lc = parent.join(lc.getFlowController());
if (parent == rootParent)
{
target.commit();
return lc;
}
}
}
target.commit();
throw new IllegalStateException
("Ups - we did not get to the root parent again. This is awful and we cannot continue.");
// return lc;
}
public static Object evaluateExpression(final FlowController flowController,
final Object declaringParent,
final Expression expression)
throws DataSourceException
{
final ExpressionRuntime runtime =
getExpressionRuntime(flowController, declaringParent);
try
{
expression.setRuntime(runtime);
return expression.computeValue();
}
catch (DataSourceException dse)
{
throw dse;
}
catch (Exception e)
{
throw new DataSourceException("Failed to evaluate expression", e);
}
finally
{
expression.setRuntime(null);
}
}
}
././@LongLink 0000000 0000000 0000000 00000000165 00000000000 011567 L ustar root root pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/flow/layoutprocessor/DefaultLayoutControllerFactory.java pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/flow/layoutprocessor/DefaultLayoutContro0000644 0001750 0001750 00000010566 11305540676 032677 0 ustar rene rene /**
* ========================================
* JFreeReport : a free Java report library
* ========================================
*
* Project Info: http://reporting.pentaho.org/
*
* (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors.
*
* This library is free software; you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation;
* either version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* ------------
* $Id: DefaultLayoutControllerFactory.java 10756 2009-12-02 15:58:24Z tmorgner $
* ------------
* (C) Copyright 2000-2005, by Object Refinery Limited.
* (C) Copyright 2005-2007, by Pentaho Corporation.
*/
package org.jfree.report.flow.layoutprocessor;
import java.util.HashMap;
import java.util.Iterator;
import org.jfree.report.DataSourceException;
import org.jfree.report.ReportDataFactoryException;
import org.jfree.report.ReportProcessingException;
import org.jfree.report.flow.FlowController;
import org.jfree.report.flow.ReportJob;
import org.jfree.report.structure.Node;
import org.pentaho.reporting.libraries.base.config.Configuration;
import org.pentaho.reporting.libraries.base.util.ObjectUtilities;
/**
* A layout controller factory that selects layout controllers by their node
* implementation type.
*
* @author Thomas Morgner
*/
public class DefaultLayoutControllerFactory implements LayoutControllerFactory
{
private HashMap registry;
private static final String PREFIX = "org.jfree.report.flow.structure.";
public DefaultLayoutControllerFactory()
{
registry = new HashMap();
}
public void initialize (final ReportJob job)
{
final Configuration configuration = job.getConfiguration();
final Iterator propertyKeys =
configuration.findPropertyKeys(DefaultLayoutControllerFactory.PREFIX);
while (propertyKeys.hasNext())
{
final String key = (String) propertyKeys.next();
final String nodeClassName = key.substring
(DefaultLayoutControllerFactory.PREFIX.length());
final String procClassName = configuration.getConfigProperty(key);
final Class nodeClass = load(nodeClassName);
final Object processor = ObjectUtilities.loadAndInstantiate
(procClassName, DefaultLayoutControllerFactory.class, LayoutController.class);
if (nodeClass == null || processor == null)
{
// sanity check ..
continue;
}
registry.put(nodeClassName, procClassName);
}
}
private Class load (final String className)
{
if (className == null)
{
return null;
}
final ClassLoader classLoader = ObjectUtilities.getClassLoader
(DefaultLayoutControllerFactory.class);
try
{
return classLoader.loadClass(className);
}
catch (ClassNotFoundException e)
{
return null;
}
}
public LayoutController create(final FlowController controller,
final Object node,
final LayoutController parent)
throws ReportProcessingException, ReportDataFactoryException, DataSourceException
{
Class nodeClass = node.getClass();
while (Node.class.isAssignableFrom(nodeClass))
{
final String targetClass = (String) registry.get(nodeClass.getName());
if (targetClass != null)
{
final LayoutController lc = (LayoutController)
ObjectUtilities.loadAndInstantiate (targetClass,
DefaultLayoutControllerFactory.class, LayoutController.class);
if (lc != null)
{
lc.initialize(node, controller, parent);
return lc;
}
}
nodeClass = nodeClass.getSuperclass();
}
throw new ReportProcessingException("No processor for node " + node);
}
}
././@LongLink 0000000 0000000 0000000 00000000156 00000000000 011567 L ustar root root pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/flow/layoutprocessor/LayoutControllerFactory.java pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/flow/layoutprocessor/LayoutControllerFac0000644 0001750 0001750 00000003717 11305540676 032663 0 ustar rene rene /**
* ========================================
* JFreeReport : a free Java report library
* ========================================
*
* Project Info: http://reporting.pentaho.org/
*
* (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors.
*
* This library is free software; you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation;
* either version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* ------------
* $Id: LayoutControllerFactory.java 10756 2009-12-02 15:58:24Z tmorgner $
* ------------
* (C) Copyright 2000-2005, by Object Refinery Limited.
* (C) Copyright 2005-2007, by Pentaho Corporation.
*/
package org.jfree.report.flow.layoutprocessor;
import org.jfree.report.DataSourceException;
import org.jfree.report.ReportDataFactoryException;
import org.jfree.report.ReportProcessingException;
import org.jfree.report.flow.FlowController;
/**
* Creation-Date: 24.11.2006, 14:25:02
*
* @author Thomas Morgner
*/
public interface LayoutControllerFactory
{
public LayoutController create (final FlowController controller,
final Object node,
final LayoutController parent)
throws ReportProcessingException, ReportDataFactoryException, DataSourceException;
}
././@LongLink 0000000 0000000 0000000 00000000161 00000000000 011563 L ustar root root pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/flow/layoutprocessor/StaticTextLayoutController.java pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/flow/layoutprocessor/StaticTextLayoutCon0000644 0001750 0001750 00000010516 11305540676 032655 0 ustar rene rene /**
* ========================================
* JFreeReport : a free Java report library
* ========================================
*
* Project Info: http://reporting.pentaho.org/
*
* (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors.
*
* This library is free software; you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation;
* either version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* ------------
* $Id: StaticTextLayoutController.java 10756 2009-12-02 15:58:24Z tmorgner $
* ------------
* (C) Copyright 2000-2005, by Object Refinery Limited.
* (C) Copyright 2005-2007, by Pentaho Corporation.
*/
package org.jfree.report.flow.layoutprocessor;
import org.jfree.report.DataSourceException;
import org.jfree.report.ReportDataFactoryException;
import org.jfree.report.ReportProcessingException;
import org.jfree.report.flow.FlowController;
import org.jfree.report.flow.ReportTarget;
import org.jfree.report.structure.StaticText;
/**
* Creation-Date: 24.11.2006, 15:06:56
*
* @author Thomas Morgner
*/
public class StaticTextLayoutController extends AbstractLayoutController
{
public static final int NOT_STARTED = 0;
public static final int FINISHED = 2;
private int state;
public StaticTextLayoutController()
{
}
/**
* Advances the processing position.
*
* @param target the report target that receives generated events.
* @return the new layout controller instance representing the new state.
*
* @throws DataSourceException if there was a problem reading data from
* the datasource.
* @throws ReportProcessingException if there was a general problem during
* the report processing.
* @throws ReportDataFactoryException if a query failed.
*/
public LayoutController advance(final ReportTarget target)
throws DataSourceException, ReportDataFactoryException, ReportProcessingException
{
if (state != StaticTextLayoutController.NOT_STARTED)
{
throw new IllegalStateException();
}
final StaticText text = (StaticText) getNode();
target.processText(text.getText());
final StaticTextLayoutController derived = (StaticTextLayoutController) clone();
derived.state = StaticTextLayoutController.FINISHED;
return derived;
}
/**
* Joins with a delegated process flow. This is generally called from a child
* flow and should *not* (I mean it!) be called from outside. If you do,
* you'll suffer.
*
* @param flowController the flow controller of the parent.
* @return the joined layout controller that incorperates all changes from
* the delegate.
*/
public LayoutController join(final FlowController flowController)
{
throw new UnsupportedOperationException("Static text does not have childs.");
}
/**
* Checks, whether the layout controller would be advanceable. If this method
* returns true, it is generally safe to call the 'advance()' method.
*
* @return true, if the layout controller is advanceable, false otherwise.
*/
public boolean isAdvanceable()
{
return state != StaticTextLayoutController.FINISHED;
}
/**
* Derives a copy of this controller that is suitable to perform a
* precomputation. The returned layout controller must be independent from
* the it's anchestor controller.
*
* @param fc a new flow controller for the precomputation.
* @return a copy that is suitable for precomputation.
*/
public LayoutController createPrecomputeInstance(final FlowController fc)
{
throw new UnsupportedOperationException
("Static Text does not perform any precomputation.");
}
}
././@LongLink 0000000 0000000 0000000 00000000165 00000000000 011567 L ustar root root pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/flow/layoutprocessor/ContentElementLayoutController.java pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/flow/layoutprocessor/ContentElementLayou0000644 0001750 0001750 00000012345 11305540676 032663 0 ustar rene rene /**
* ========================================
* JFreeReport : a free Java report library
* ========================================
*
* Project Info: http://reporting.pentaho.org/
*
* (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors.
*
* This library is free software; you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation;
* either version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* ------------
* $Id: ContentElementLayoutController.java 10756 2009-12-02 15:58:24Z tmorgner $
* ------------
* (C) Copyright 2000-2005, by Object Refinery Limited.
* (C) Copyright 2005-2007, by Pentaho Corporation.
*/
package org.jfree.report.flow.layoutprocessor;
import org.jfree.report.DataFlags;
import org.jfree.report.DataSourceException;
import org.jfree.report.ReportDataFactoryException;
import org.jfree.report.ReportProcessingException;
import org.jfree.report.data.DefaultDataFlags;
import org.jfree.report.expressions.Expression;
import org.jfree.report.flow.FlowController;
import org.jfree.report.flow.LayoutExpressionRuntime;
import org.jfree.report.flow.ReportContext;
import org.jfree.report.flow.ReportTarget;
import org.jfree.report.structure.ContentElement;
import org.jfree.report.structure.Node;
/**
* Creation-Date: 24.11.2006, 15:06:56
*
* @author Thomas Morgner
*/
public class ContentElementLayoutController extends ElementLayoutController
{
public ContentElementLayoutController()
{
}
protected LayoutController processContent(final ReportTarget target)
throws DataSourceException, ReportProcessingException, ReportDataFactoryException
{
final Node node = getElement();
final FlowController flowController = getFlowController();
final LayoutExpressionRuntime er =
LayoutControllerUtil.getExpressionRuntime(flowController, node);
final ContentElement element = (ContentElement) node;
final Expression ex = element.getValueExpression();
final Object value;
if (ex != null)
{
try
{
ex.setRuntime(er);
value = ex.computeValue();
}
finally
{
ex.setRuntime(null);
}
}
else
{
value = null;
}
// This should be a very rare case indeed ..
if (value instanceof DataFlags)
{
target.processContent((DataFlags) value);
final ContentElementLayoutController derived = (ContentElementLayoutController) clone();
derived.setProcessingState(ElementLayoutController.FINISHING);
derived.setFlowController(flowController);
return derived;
}
if (value instanceof Node)
{
// we explictly allow structural content here.
// As this might be a very expensive thing, if we
// keep it in a single state, we continue on a separate state.
final Node valueNode = (Node) value;
valueNode.updateParent(node.getParent());
final ReportContext reportContext = flowController.getReportContext();
final LayoutControllerFactory layoutControllerFactory =
reportContext.getLayoutControllerFactory();
// actually, this is the same as if the element were a
// child element of a section. The only difference is
// that there can be only one child, and that there is no
// direct parent-child direction.
final ContentElementLayoutController derived =
(ContentElementLayoutController) clone();
derived.setProcessingState(ElementLayoutController.WAITING_FOR_JOIN);
derived.setFlowController(flowController);
return layoutControllerFactory.create
(flowController, valueNode, derived);
}
if (ex != null)
{
target.processContent (new DefaultDataFlags(ex.getName(), value, true));
}
final ContentElementLayoutController derived = (ContentElementLayoutController) clone();
derived.setProcessingState(ElementLayoutController.FINISHING);
derived.setFlowController(flowController);
return derived;
}
/**
* Joins with a delegated process flow. This is generally called from a child
* flow and should *not* (I mean it!) be called from outside. If you do,
* you'll suffer.
*
* @param flowController the flow controller of the parent.
* @return the joined layout controller that incorperates all changes from
* the delegate.
*/
public LayoutController join(final FlowController flowController)
{
final ContentElementLayoutController derived = (ContentElementLayoutController) clone();
derived.setProcessingState(ElementLayoutController.FINISHING);
derived.setFlowController(flowController);
return derived;
}
}
././@LongLink 0000000 0000000 0000000 00000000156 00000000000 011567 L ustar root root pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/flow/layoutprocessor/SectionLayoutController.java pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/flow/layoutprocessor/SectionLayoutContro0000644 0001750 0001750 00000020631 11305540676 032711 0 ustar rene rene /**
* ========================================
* JFreeReport : a free Java report library
* ========================================
*
* Project Info: http://reporting.pentaho.org/
*
* (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors.
*
* This library is free software; you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation;
* either version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* ------------
* $Id: SectionLayoutController.java 10756 2009-12-02 15:58:24Z tmorgner $
* ------------
* (C) Copyright 2000-2005, by Object Refinery Limited.
* (C) Copyright 2005-2007, by Pentaho Corporation.
*/
package org.jfree.report.flow.layoutprocessor;
import org.jfree.report.DataSourceException;
import org.jfree.report.ReportDataFactoryException;
import org.jfree.report.ReportProcessingException;
import org.jfree.report.expressions.Expression;
import org.jfree.report.flow.FlowController;
import org.jfree.report.flow.ReportContext;
import org.jfree.report.flow.ReportTarget;
import org.jfree.report.structure.Node;
import org.jfree.report.structure.Section;
/**
* Creation-Date: 24.11.2006, 13:56:10
*
* @author Thomas Morgner
*/
public class SectionLayoutController extends ElementLayoutController
{
// we store the child instead of the index, as the report can be manipulated
// it is safer this way ..
private Node[] nodes;
private int index;
public SectionLayoutController()
{
}
protected FlowController startData(final ReportTarget target,
final FlowController fc)
throws DataSourceException, ReportProcessingException,
ReportDataFactoryException
{
final Section s = (Section) getElement();
return LayoutControllerUtil.processFlowOperations
(fc, s.getOperationBefore());
}
protected LayoutController processContent(final ReportTarget target)
throws DataSourceException, ReportProcessingException,
ReportDataFactoryException
{
final FlowController flowController = getFlowController();
final Node[] nodes = getNodes();
final int currentIndex = getIndex();
if (currentIndex < nodes.length)
{
final Node node = nodes[currentIndex];
final SectionLayoutController derived = (SectionLayoutController) clone();
return processChild(derived, node, flowController);
}
else
{
final SectionLayoutController derived = (SectionLayoutController) clone();
derived.setProcessingState(ElementLayoutController.FINISHING);
return derived;
}
}
protected LayoutController processChild(final SectionLayoutController derived,
final Node node,
final FlowController flowController)
throws DataSourceException, ReportProcessingException,
ReportDataFactoryException
{
final ReportContext reportContext = flowController.getReportContext();
final LayoutControllerFactory layoutControllerFactory = reportContext.getLayoutControllerFactory();
if (isDisplayable(node))
{
derived.setProcessingState(ElementLayoutController.WAITING_FOR_JOIN);
return layoutControllerFactory.create(flowController, node, derived);
}
else
{
derived.setProcessingState(ElementLayoutController.WAITING_FOR_JOIN);
final LayoutController childLc = layoutControllerFactory.create(flowController, node, derived);
return LayoutControllerUtil.skipInvisibleElement(childLc);
// derived.setIndex(derived.getIndex() + 1);
// return LayoutControllerUtil.skipInvisibleElement(derived);
}
}
protected boolean isDisplayable(final Node node)
throws DataSourceException
{
if (node.isEnabled() == false)
{
return false;
}
final Expression expression = node.getDisplayCondition();
if (expression == null)
{
return true;
}
final Object result = LayoutControllerUtil.evaluateExpression(getFlowController(), node, expression);
if (Boolean.TRUE.equals(result))
{
return true;
}
return false;
}
/**
* Finishes the processing of this element. This method is called when the
* processing state is 'FINISHING'. The element should be closed now and all
* privatly owned resources should be freed. If the element has a parent, it
* would be time to join up with the parent now, else the processing state
* should be set to 'FINISHED'.
*
* @param target the report target that receives generated events.
* @return the new layout controller instance representing the new state.
*
* @throws DataSourceException if there was a problem reading data from
* the datasource.
* @throws ReportProcessingException if there was a general problem during
* the report processing.
* @throws ReportDataFactoryException if there was an error trying query
* data.
*/
protected LayoutController finishElement(final ReportTarget target)
throws ReportProcessingException, DataSourceException,
ReportDataFactoryException
{
FlowController fc = handleDefaultEndElement(target);
// unwind the stack ..
final Section s = (Section) getElement();
fc = finishData(target, fc);
if (s.isRepeat())
{
final FlowController cfc = tryRepeatingCommit(fc);
if (cfc != null)
{
// Go back to the beginning ...
final SectionLayoutController derived = (SectionLayoutController) clone();
derived.setProcessingState(ElementLayoutController.NOT_STARTED);
derived.setFlowController(cfc);
derived.resetSectionForRepeat();
return derived;
}
}
// Go back to the beginning ...
final SectionLayoutController derived = (SectionLayoutController) clone();
derived.setProcessingState(ElementLayoutController.FINISHED);
derived.setFlowController(fc);
return derived;
}
protected void resetSectionForRepeat()
{
setIndex(0);
}
protected FlowController finishData(final ReportTarget target,
final FlowController fc)
throws DataSourceException, ReportProcessingException
{
final Section s = (Section) getElement();
return LayoutControllerUtil.processFlowOperations
(fc, s.getOperationAfter());
}
/**
* Joins with a delegated process flow. This is generally called from a child
* flow and should *not* (I mean it!) be called from outside. If you do,
* you'll suffer.
*
* @param flowController the flow controller of the parent.
* @return the joined layout controller that incorperates all changes from the
* delegate.
*/
public LayoutController join(final FlowController flowController)
{
final Node[] nodes = getNodes();
int index = getIndex() + 1;
for (; index < nodes.length; index++)
{
final Node node = nodes[index];
if (node.isEnabled())
{
break;
}
}
if (index < nodes.length)
{
final SectionLayoutController derived = (SectionLayoutController) clone();
derived.setProcessingState(ElementLayoutController.OPENED);
derived.setFlowController(flowController);
derived.setIndex(index);
return derived;
}
final SectionLayoutController derived = (SectionLayoutController) clone();
derived.setProcessingState(ElementLayoutController.FINISHING);
derived.setFlowController(flowController);
return derived;
}
public Node[] getNodes()
{
if (nodes == null)
{
final Section s = (Section) getElement();
nodes = s.getNodeArray();
}
return nodes;
}
public int getIndex()
{
return index;
}
public void setIndex(final int index)
{
this.index = index;
}
}
././@LongLink 0000000 0000000 0000000 00000000147 00000000000 011567 L ustar root root pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/flow/layoutprocessor/LayoutController.java pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/flow/layoutprocessor/LayoutController.ja0000644 0001750 0001750 00000012220 11305540676 032627 0 ustar rene rene /**
* ========================================
* JFreeReport : a free Java report library
* ========================================
*
* Project Info: http://reporting.pentaho.org/
*
* (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors.
*
* This library is free software; you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation;
* either version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* ------------
* $Id: LayoutController.java 10756 2009-12-02 15:58:24Z tmorgner $
* ------------
* (C) Copyright 2000-2005, by Object Refinery Limited.
* (C) Copyright 2005-2007, by Pentaho Corporation.
*/
package org.jfree.report.flow.layoutprocessor;
import org.jfree.report.DataSourceException;
import org.jfree.report.ReportDataFactoryException;
import org.jfree.report.ReportProcessingException;
import org.jfree.report.flow.FlowController;
import org.jfree.report.flow.ReportTarget;
/**
* The layout controller iterates over the report layout. It uses a flow
* controller to query the data.
*
* @author Thomas Morgner
*/
public interface LayoutController extends Cloneable
{
/**
* Retrieves the parent of this layout controller. This allows childs to query
* their context.
*
* @return the layout controller's parent to null
if there is no
* parent.
*/
public LayoutController getParent();
/**
* Initializes the layout controller. This method is called exactly once. It
* is the creators responsibility to call this method.
*
* Calling initialize after the first advance must result in a
* IllegalStateException.
*
* @param node the currently processed object or layout node.
* @param flowController the current flow controller.
* @param parent the parent layout controller that was responsible for
* instantiating this controller.
* @throws DataSourceException if there was a problem reading data from
* the datasource.
* @throws ReportProcessingException if there was a general problem during
* the report processing.
* @throws ReportDataFactoryException if a query failed.
*/
public void initialize(final Object node,
final FlowController flowController,
final LayoutController parent)
throws DataSourceException, ReportDataFactoryException,
ReportProcessingException;
/**
* Advances the processing position.
*
* @param target the report target that receives generated events.
* @return the new layout controller instance representing the new state.
*
* @throws DataSourceException if there was a problem reading data from
* the datasource.
* @throws ReportProcessingException if there was a general problem during
* the report processing.
* @throws ReportDataFactoryException if a query failed.
*/
public LayoutController advance(ReportTarget target)
throws DataSourceException, ReportDataFactoryException,
ReportProcessingException;
/**
* Checks, whether the layout controller would be advanceable. If this method
* returns true, it is generally safe to call the 'advance()' method.
*
* @return true, if the layout controller is advanceable, false otherwise.
*/
public boolean isAdvanceable();
/**
* Joins with a delegated process flow. This is generally called from a child
* flow and should *not* (I mean it!) be called from outside. If you do,
* you'll suffer.
*
* @param flowController the flow controller of the parent.
* @return the joined layout controller that incorperates all changes from
* the delegate.
*/
public LayoutController join(FlowController flowController)
throws DataSourceException, ReportDataFactoryException,
ReportProcessingException;
/**
* Creates a copy of this layout controller.
*
* @return a copy.
*/
public Object clone();
/**
* Derives a copy of this controller that is suitable to perform a
* precomputation. The returned layout controller must be independent from
* the it's anchestor controller.
*
* @param fc a new flow controller for the precomputation.
* @return a copy that is suitable for precomputation.
*/
public LayoutController createPrecomputeInstance(FlowController fc);
public FlowController getFlowController();
public Object getNode();
}
pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/flow/raw/ 0000755 0001750 0001750 00000000000 11305540676 024311 5 ustar rene rene pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/flow/raw/XmlPrintReportProcessor.java 0000644 0001750 0001750 00000005132 11305540676 032026 0 ustar rene rene /**
* ========================================
* JFreeReport : a free Java report library
* ========================================
*
* Project Info: http://reporting.pentaho.org/
*
* (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors.
*
* This library is free software; you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation;
* either version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* ------------
* $Id: XmlPrintReportProcessor.java 10756 2009-12-02 15:58:24Z tmorgner $
* ------------
* (C) Copyright 2000-2005, by Object Refinery Limited.
* (C) Copyright 2005-2007, by Pentaho Corporation.
*/
package org.jfree.report.flow.raw;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import org.jfree.report.ReportProcessingException;
import org.jfree.report.flow.ReportJob;
import org.jfree.report.flow.ReportTarget;
import org.jfree.report.flow.SinglePassReportProcessor;
import org.pentaho.reporting.libraries.xmlns.writer.XmlWriter;
/**
* Todo: Document me!
*
* @author Thomas Morgner
* @since 20.03.2007
*/
public class XmlPrintReportProcessor extends SinglePassReportProcessor
{
private OutputStream outputStream;
private String encoding;
public XmlPrintReportProcessor(final OutputStream outputStream,
final String encoding)
{
this.outputStream = outputStream;
this.encoding = encoding;
}
protected ReportTarget createReportTarget(final ReportJob job)
throws ReportProcessingException
{
try
{
final OutputStreamWriter osw =
new OutputStreamWriter(outputStream, encoding);
final XmlWriter writer = new XmlWriter(osw);
writer.writeXmlDeclaration(encoding);
return new XmlPrintReportTarget(job, writer);
}
catch (IOException e)
{
throw new ReportProcessingException("Failed to create writer", e);
}
}
}
pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/flow/raw/XmlPrintReportTarget.java 0000644 0001750 0001750 00000017710 11305540676 031302 0 ustar rene rene /**
* ========================================
* JFreeReport : a free Java report library
* ========================================
*
* Project Info: http://reporting.pentaho.org/
*
* (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors.
*
* This library is free software; you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation;
* either version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* ------------
* $Id: XmlPrintReportTarget.java 10756 2009-12-02 15:58:24Z tmorgner $
* ------------
* (C) Copyright 2000-2005, by Object Refinery Limited.
* (C) Copyright 2005-2007, by Pentaho Corporation.
*/
package org.jfree.report.flow.raw;
import java.awt.Image;
import java.io.IOException;
import java.util.Iterator;
import java.util.Map;
import org.jfree.layouting.namespace.NamespaceDefinition;
import org.jfree.layouting.namespace.Namespaces;
import org.jfree.layouting.namespace.NamespaceCollection;
import org.jfree.layouting.namespace.DefaultNamespaceCollection;
import org.jfree.layouting.util.AttributeMap;
import org.jfree.layouting.LibLayoutBoot;
import org.jfree.report.DataFlags;
import org.jfree.report.DataSourceException;
import org.jfree.report.JFreeReportInfo;
import org.jfree.report.ReportProcessingException;
import org.jfree.report.util.AttributeNameGenerator;
import org.jfree.report.flow.ReportJob;
import org.jfree.report.flow.ReportStructureRoot;
import org.jfree.report.flow.ReportTarget;
import org.jfree.report.flow.ReportTargetUtil;
import org.pentaho.reporting.libraries.xmlns.writer.XmlWriter;
import org.pentaho.reporting.libraries.xmlns.writer.XmlWriterSupport;
import org.pentaho.reporting.libraries.xmlns.common.AttributeList;
/**
* Todo: Document me!
*
* @author Thomas Morgner
* @since 20.03.2007
*/
public class XmlPrintReportTarget implements ReportTarget
{
private ReportJob reportJob;
private XmlWriter writer;
private NamespaceCollection namespaces;
private AttributeNameGenerator namespacePrefixGenerator;
public XmlPrintReportTarget(final ReportJob job,
final XmlWriter writer)
{
this.reportJob = job;
this.writer = writer;
final NamespaceDefinition[] reportNamespaces = Namespaces.createFromConfig
(reportJob.getConfiguration(), "org.jfree.report.namespaces.", null);
final NamespaceDefinition[] layoutNamespaces = Namespaces.createFromConfig
(LibLayoutBoot.getInstance().getGlobalConfig(),
"org.jfree.layouting.namespaces.", null);
DefaultNamespaceCollection namespaces = new DefaultNamespaceCollection();
namespaces.addDefinitions(reportNamespaces);
namespaces.addDefinitions(layoutNamespaces);
this.namespaces = namespaces;
this.namespacePrefixGenerator = new AttributeNameGenerator();
}
public ReportJob getReportJob()
{
return reportJob;
}
public void startReport(final ReportStructureRoot report)
throws DataSourceException, ReportProcessingException
{
try
{
writer.writeComment("starting report");
}
catch (IOException e)
{
throw new ReportProcessingException("IOError", e);
}
}
public void startElement(final AttributeMap attrs)
throws DataSourceException, ReportProcessingException
{
final String namespace = ReportTargetUtil.getNamespaceFromAttribute(attrs);
final String elementType =
ReportTargetUtil.getElemenTypeFromAttribute(attrs);
try
{
final AttributeList attrList = buildAttributeList(attrs);
validateNamespace(namespace, attrList);
writer.writeTag(namespace, elementType, attrList,
XmlWriterSupport.OPEN);
}
catch (IOException e)
{
throw new ReportProcessingException("IOError", e);
}
}
public void processContent(final DataFlags value)
throws DataSourceException, ReportProcessingException
{
final Object rawvalue = value.getValue();
if (rawvalue == null)
{
return;
}
// special handler for image (possibly also for URL ..)
if (rawvalue instanceof Image)
{
// do nothing yet. We should define something for that later ..
return;
}
try
{
final String text = String.valueOf(rawvalue);
writer.writeTextNormalized(text, false);
}
catch (IOException e)
{
throw new ReportProcessingException("Failed", e);
}
}
public void endElement(final AttributeMap attrs)
throws DataSourceException, ReportProcessingException
{
try
{
writer.writeCloseTag();
}
catch (IOException e)
{
throw new ReportProcessingException("IOError", e);
}
}
public void endReport(final ReportStructureRoot report)
throws DataSourceException, ReportProcessingException
{
try
{
writer.writeComment("starting report");
}
catch (IOException e)
{
throw new ReportProcessingException("IOError", e);
}
}
public NamespaceDefinition getNamespaceByUri(final String uri)
{
return namespaces.getDefinition(uri);
}
public void processText(final String text)
throws DataSourceException, ReportProcessingException
{
try
{
writer.writeTextNormalized(text, false);
}
catch (IOException e)
{
throw new ReportProcessingException("IOError", e);
}
}
public void commit()
throws ReportProcessingException
{
try
{
writer.flush();
}
catch (IOException e)
{
throw new ReportProcessingException("Failed to flush", e);
}
}
public String getExportDescriptor()
{
return "raw/text+xml";
}
protected AttributeList buildAttributeList(final AttributeMap attrs)
{
final AttributeList attrList = new AttributeList();
final String[] namespaces = attrs.getNameSpaces();
for (int i = 0; i < namespaces.length; i++)
{
final String attrNamespace = namespaces[i];
if (isInternalNamespace(attrNamespace))
{
continue;
}
final Map localAttributes = attrs.getAttributes(attrNamespace);
final Iterator entries = localAttributes.entrySet().iterator();
while (entries.hasNext())
{
final Map.Entry entry = (Map.Entry) entries.next();
final String key = String.valueOf(entry.getKey());
validateNamespace(attrNamespace, attrList);
attrList.setAttribute(attrNamespace, key,
String.valueOf(entry.getValue()));
}
}
return attrList;
}
private void validateNamespace(final String uri, final AttributeList list)
{
if (writer.isNamespaceDefined(uri))
{
return;
}
if (list.isNamespaceUriDefined(uri))
{
return;
}
final NamespaceDefinition def = getNamespaceByUri(uri);
if (def != null)
{
final String prefix = def.getPreferredPrefix();
if (writer.isNamespacePrefixDefined(prefix) == false &&
list.isNamespacePrefixDefined(prefix) == false)
{
list.addNamespaceDeclaration (prefix, uri);
}
else
{
list.addNamespaceDeclaration
(namespacePrefixGenerator.generateName(prefix), uri);
}
}
else
{
list.addNamespaceDeclaration
(namespacePrefixGenerator.generateName("auto"), uri);
}
}
private boolean isInternalNamespace(final String namespace)
{
return JFreeReportInfo.REPORT_NAMESPACE.equals(namespace);
}
}
pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/flow/raw/RawReportTarget.java 0000644 0001750 0001750 00000006030 11305540676 030247 0 ustar rene rene /**
* ========================================
* JFreeReport : a free Java report library
* ========================================
*
* Project Info: http://reporting.pentaho.org/
*
* (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors.
*
* This library is free software; you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation;
* either version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* ------------
* $Id: RawReportTarget.java 10756 2009-12-02 15:58:24Z tmorgner $
* ------------
* (C) Copyright 2000-2005, by Object Refinery Limited.
* (C) Copyright 2005-2007, by Pentaho Corporation.
*/
package org.jfree.report.flow.raw;
import org.jfree.layouting.namespace.NamespaceDefinition;
import org.jfree.layouting.util.AttributeMap;
import org.jfree.report.DataFlags;
import org.jfree.report.DataSourceException;
import org.jfree.report.ReportProcessingException;
import org.jfree.report.flow.ReportJob;
import org.jfree.report.flow.ReportStructureRoot;
import org.jfree.report.flow.ReportTarget;
/**
* The Raw report processor defines the base for all non-layouting output
* methods. As no layouting is involved, this output method is lightning
* fast.
*
* @author Thomas Morgner
*/
public class RawReportTarget implements ReportTarget
{
private ReportJob reportJob;
public RawReportTarget(final ReportJob job)
{
this.reportJob = job;
}
public ReportJob getReportJob()
{
return reportJob;
}
public void startReport(final ReportStructureRoot report)
throws DataSourceException, ReportProcessingException
{
}
public void startElement(final AttributeMap attrs)
throws DataSourceException, ReportProcessingException
{
}
public void processContent(final DataFlags value)
throws DataSourceException, ReportProcessingException
{
}
public void endElement(final AttributeMap attrs)
throws DataSourceException, ReportProcessingException
{
}
public void endReport(ReportStructureRoot report)
throws DataSourceException, ReportProcessingException
{
}
public NamespaceDefinition getNamespaceByUri(String uri)
{
return null;
}
public void processText(String text)
throws DataSourceException, ReportProcessingException
{
}
public void commit()
{
}
public String getExportDescriptor()
{
return "raw";
}
}
pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/flow/raw/RawReportProcessor.java 0000644 0001750 0001750 00000003622 11305540676 031004 0 ustar rene rene /**
* ========================================
* JFreeReport : a free Java report library
* ========================================
*
* Project Info: http://reporting.pentaho.org/
*
* (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors.
*
* This library is free software; you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation;
* either version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* ------------
* $Id: RawReportProcessor.java 10756 2009-12-02 15:58:24Z tmorgner $
* ------------
* (C) Copyright 2000-2005, by Object Refinery Limited.
* (C) Copyright 2005-2007, by Pentaho Corporation.
*/
package org.jfree.report.flow.raw;
import org.jfree.report.flow.ReportJob;
import org.jfree.report.flow.ReportTarget;
import org.jfree.report.flow.SinglePassReportProcessor;
/**
* The Raw report processor defines the base for all non-layouting output
* methods. As no layouting is involved, this output method is lightning
* fast.
*
* @author Thomas Morgner
*/
public class RawReportProcessor extends SinglePassReportProcessor
{
public RawReportProcessor()
{
}
protected ReportTarget createReportTarget(ReportJob job)
{
return new RawReportTarget(job);
}
}
pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/flow/ReportJob.java 0000644 0001750 0001750 00000004324 11305540676 026274 0 ustar rene rene /**
* ========================================
* JFreeReport : a free Java report library
* ========================================
*
* Project Info: http://reporting.pentaho.org/
*
* (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors.
*
* This library is free software; you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation;
* either version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* ------------
* $Id: ReportJob.java 10756 2009-12-02 15:58:24Z tmorgner $
* ------------
* (C) Copyright 2000-2005, by Object Refinery Limited.
* (C) Copyright 2005-2007, by Pentaho Corporation.
*/
package org.jfree.report.flow;
import java.io.Serializable;
import org.jfree.report.ReportDataFactory;
import org.jfree.report.i18n.ResourceBundleFactory;
import org.jfree.report.util.ReportParameters;
import org.pentaho.reporting.libraries.base.config.ModifiableConfiguration;
/**
* A report job holds all properties that are required to successfully execute
* a report process. A report job does not hold output target specific
* parameters like target file names etc.
*/
public interface ReportJob extends Serializable, Cloneable
{
ModifiableConfiguration getConfiguration();
ReportParameters getParameters();
ReportStructureRoot getReportStructureRoot();
ReportDataFactory getDataFactory();
ReportJob derive();
void close();
ResourceBundleFactory getResourceBundleFactory();
String getName();
// PageFormat getPageFormat();
//
// void setPageFormat(PageFormat pageFormat);
}
pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/flow/streaming/ 0000755 0001750 0001750 00000000000 11305540676 025511 5 ustar rene rene ././@LongLink 0000000 0000000 0000000 00000000151 00000000000 011562 L ustar root root pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/flow/streaming/StreamingReportProcessor.java pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/flow/streaming/StreamingReportProcessor.0000644 0001750 0001750 00000007055 11305540676 032546 0 ustar rene rene /**
* ========================================
* JFreeReport : a free Java report library
* ========================================
*
* Project Info: http://reporting.pentaho.org/
*
* (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors.
*
* This library is free software; you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation;
* either version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* ------------
* $Id: StreamingReportProcessor.java 10756 2009-12-02 15:58:24Z tmorgner $
* ------------
* (C) Copyright 2000-2005, by Object Refinery Limited.
* (C) Copyright 2005-2007, by Pentaho Corporation.
*/
package org.jfree.report.flow.streaming;
import org.jfree.layouting.DefaultLayoutProcess;
import org.jfree.layouting.LayoutProcess;
import org.jfree.layouting.output.OutputProcessor;
import org.jfree.report.DataSourceException;
import org.jfree.report.ReportDataFactoryException;
import org.jfree.report.ReportProcessingException;
import org.jfree.report.flow.AbstractReportProcessor;
import org.jfree.report.flow.LibLayoutReportTarget;
import org.jfree.report.flow.ReportJob;
import org.pentaho.reporting.libraries.resourceloader.ResourceKey;
import org.pentaho.reporting.libraries.resourceloader.ResourceManager;
/**
* This is written to use LibLayout. It will never work with other report
* targets.
*
* @author Thomas Morgner
*/
public class StreamingReportProcessor extends AbstractReportProcessor
{
private OutputProcessor outputProcessor;
public StreamingReportProcessor()
{
}
public OutputProcessor getOutputProcessor()
{
return outputProcessor;
}
public void setOutputProcessor(final OutputProcessor outputProcessor)
{
this.outputProcessor = outputProcessor;
}
public void processReport(final ReportJob job)
throws ReportDataFactoryException, DataSourceException, ReportProcessingException
{
if (job == null)
{
throw new NullPointerException();
}
synchronized (job)
{
// first, compute the globals
processReportRun(job, createTarget(job));
// second, paginate (this splits the stream into flows)
processReportRun(job, createTarget(job));
// third, generate the content.
processReportRun(job, createTarget(job));
}
}
protected LibLayoutReportTarget createTarget(final ReportJob job)
throws ReportProcessingException
{
if (outputProcessor == null)
{
throw new IllegalStateException(
"OutputProcessor is invalid.");
}
final LayoutProcess layoutProcess =
new DefaultLayoutProcess(outputProcessor);
final ResourceManager resourceManager = job.getReportStructureRoot().getResourceManager();
final ResourceKey resourceKey = job.getReportStructureRoot().getBaseResource();
return new LibLayoutReportTarget
(job, resourceKey, resourceManager, layoutProcess);
}
}
pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/flow/ReportTargetState.java 0000644 0001750 0001750 00000003273 11305540700 027777 0 ustar rene rene /**
* ========================================
* JFreeReport : a free Java report library
* ========================================
*
* Project Info: http://reporting.pentaho.org/
*
* (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors.
*
* This library is free software; you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation;
* either version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* ------------
* $Id: ReportTargetState.java 10756 2009-12-02 15:58:24Z tmorgner $
* ------------
* (C) Copyright 2000-2005, by Object Refinery Limited.
* (C) Copyright 2005-2007, by Pentaho Corporation.
*/
package org.jfree.report.flow;
import java.io.Serializable;
import org.jfree.layouting.StateException;
import org.jfree.layouting.output.OutputProcessor;
/**
* Creation-Date: 11.11.2006, 19:03:09
*
* @author Thomas Morgner
*/
public interface ReportTargetState extends Serializable
{
public ReportTarget restore(OutputProcessor out) throws StateException;
}
pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/flow/AbstractReportProcessor.java 0000644 0001750 0001750 00000010154 11305540676 031223 0 ustar rene rene /**
* ========================================
* JFreeReport : a free Java report library
* ========================================
*
* Project Info: http://reporting.pentaho.org/
*
* (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors.
*
* This library is free software; you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation;
* either version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* ------------
* $Id: AbstractReportProcessor.java 10756 2009-12-02 15:58:24Z tmorgner $
* ------------
* (C) Copyright 2000-2005, by Object Refinery Limited.
* (C) Copyright 2005-2007, by Pentaho Corporation.
*/
package org.jfree.report.flow;
import org.jfree.report.DataSourceException;
import org.jfree.report.ReportDataFactoryException;
import org.jfree.report.ReportProcessingException;
import org.jfree.report.data.ReportContextImpl;
import org.jfree.report.flow.layoutprocessor.DefaultLayoutControllerFactory;
import org.jfree.report.flow.layoutprocessor.LayoutController;
import org.jfree.report.flow.layoutprocessor.LayoutControllerFactory;
import org.pentaho.reporting.libraries.formula.DefaultFormulaContext;
/**
* Creation-Date: 10.11.2006, 16:07:26
*
* @author Thomas Morgner
*/
public abstract class AbstractReportProcessor implements ReportProcessor
{
protected AbstractReportProcessor()
{
}
protected void processReportRun
(final ReportJob job,
final ReportTarget target)
throws ReportDataFactoryException,
DataSourceException, ReportProcessingException
{
synchronized (job)
{
final ReportContext context = createReportContext(job, target);
final LayoutControllerFactory layoutFactory =
context.getLayoutControllerFactory();
// we have the data and we have our position inside the report.
// lets generate something ...
final FlowController flowController = createFlowControler(context, job);
LayoutController layoutController =
layoutFactory.create(flowController, job.getReportStructureRoot(), null);
while (layoutController.isAdvanceable())
{
layoutController = layoutController.advance(target);
while (layoutController.isAdvanceable() == false &&
layoutController.getParent() != null)
{
final LayoutController parent = layoutController.getParent();
target.commit();
layoutController = parent.join(layoutController.getFlowController());
}
}
target.commit();
}
}
protected ReportContext createReportContext (final ReportJob job,
final ReportTarget target)
{
final ReportContextImpl context = new ReportContextImpl();
context.setExportDescriptor(target.getExportDescriptor());
final DefaultLayoutControllerFactory lcf = new DefaultLayoutControllerFactory();
lcf.initialize(job);
context.setLayoutControllerFactory(lcf);
final DefaultFormulaContext formulaContext = new DefaultFormulaContext();
context.setFormulaContext(formulaContext);
context.setResourceBundleFactory(job.getResourceBundleFactory());
context.setReportStructureRoot(job.getReportStructureRoot());
return context;
}
protected FlowController createFlowControler(final ReportContext context,
final ReportJob job)
throws DataSourceException
{
return new DefaultFlowController(context, job);
}
}
pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/flow/ParameterMapping.java 0000644 0001750 0001750 00000003551 11305540676 027623 0 ustar rene rene /**
* ========================================
* JFreeReport : a free Java report library
* ========================================
*
* Project Info: http://reporting.pentaho.org/
*
* (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors.
*
* This library is free software; you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation;
* either version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* ------------
* $Id: ParameterMapping.java 10756 2009-12-02 15:58:24Z tmorgner $
* ------------
* (C) Copyright 2000-2005, by Object Refinery Limited.
* (C) Copyright 2005-2007, by Pentaho Corporation.
*/
package org.jfree.report.flow;
import java.io.Serializable;
/**
* Creation-Date: Dec 6, 2006, 3:25:22 PM
*
* @author Thomas Morgner
*/
public class ParameterMapping implements Serializable
{
private static final long serialVersionUID = -3666118451657430360L;
private String name;
private String alias;
public ParameterMapping(final String name, final String alias)
{
this.name = name;
this.alias = alias;
}
public String getName()
{
return name;
}
public String getAlias()
{
return alias;
}
}
pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/flow/ReportTargetUtil.java 0000644 0001750 0001750 00000005445 11305540676 027653 0 ustar rene rene /**
* ========================================
* JFreeReport : a free Java report library
* ========================================
*
* Project Info: http://reporting.pentaho.org/
*
* (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors.
*
* This library is free software; you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation;
* either version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* ------------
* $Id: ReportTargetUtil.java 10756 2009-12-02 15:58:24Z tmorgner $
* ------------
* (C) Copyright 2000-2005, by Object Refinery Limited.
* (C) Copyright 2005-2007, by Pentaho Corporation.
*/
package org.jfree.report.flow;
import org.jfree.layouting.util.AttributeMap;
import org.jfree.report.JFreeReportInfo;
import org.jfree.report.structure.Element;
import org.pentaho.reporting.libraries.base.util.ObjectUtilities;
/**
* Todo: Document me!
*
* @author Thomas Morgner
* @since 20.03.2007
*/
public class ReportTargetUtil
{
private ReportTargetUtil()
{
}
public static String getNamespaceFromAttribute(final AttributeMap attrs)
{
final Object attribute = attrs.getAttribute
(JFreeReportInfo.REPORT_NAMESPACE, Element.NAMESPACE_ATTRIBUTE);
if (attribute instanceof String)
{
return (String) attribute;
}
return JFreeReportInfo.REPORT_NAMESPACE;
}
public static String getElemenTypeFromAttribute(final AttributeMap attrs)
{
final Object attribute = attrs.getAttribute
(JFreeReportInfo.REPORT_NAMESPACE, Element.TYPE_ATTRIBUTE);
if (attribute instanceof String)
{
return (String) attribute;
}
return "element";
}
public static boolean isElementOfType(final String uri,
final String tagName,
final AttributeMap attrs)
{
final String namespace = getNamespaceFromAttribute(attrs);
if (ObjectUtilities.equal(namespace, uri) == false)
{
return false;
}
final String elementTagName = getElemenTypeFromAttribute(attrs);
return ObjectUtilities.equal(tagName, elementTagName);
}
}
pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/flow/paginating/ 0000755 0001750 0001750 00000000000 11305540676 025641 5 ustar rene rene pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/flow/paginating/PageStateList.java 0000644 0001750 0001750 00000024634 11305540676 031226 0 ustar rene rene /**
* ========================================
* JFreeReport : a free Java report library
* ========================================
*
* Project Info: http://reporting.pentaho.org/
*
* (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors.
*
* This library is free software; you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation;
* either version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* ------------
* $Id: PageStateList.java 10756 2009-12-02 15:58:24Z tmorgner $
* ------------
* (C) Copyright 2000-2005, by Object Refinery Limited.
* (C) Copyright 2005-2007, by Pentaho Corporation.
*/
package org.jfree.report.flow.paginating;
import java.util.ArrayList;
import org.jfree.layouting.StateException;
import org.jfree.report.DataSourceException;
import org.jfree.report.ReportDataFactoryException;
import org.jfree.report.ReportProcessingException;
import org.jfree.report.util.WeakReferenceList;
/**
* The ReportState list stores a report states for the beginning of every page. The list
* is filled on repagination and read when a report or a page of the report is printed.
*
* Important: This list stores page start report states, not arbitary report states. These
* ReportStates are special: they can be reproduced by calling processPage on the report.
*
* Internally this list is organized as a list of WeakReferenceLists, where every
* WeakReferenceList stores a certain number of page states. The first 20 states are
* stored in an ordinary list with strong-references, so these states never get
* GarbageCollected (and so they must never be restored by reprocessing them). The next
* 100 states are stored in 4-element ReferenceLists, so if a reference is lost, only 4
* states have to be reprocessed. All other states are stored in 10-element lists.
*
* @author Thomas Morgner
*/
public class PageStateList
{
/**
* The position of the master element in the list. A greater value will reduce the
* not-freeable memory used by the list, but restoring a single page will require more
* time.
*/
/**
* The maxmimum masterposition size.
*/
private static final int MASTERPOSITIONS_MAX = 10;
/**
* The medium masterposition size.
*/
private static final int MASTERPOSITIONS_MED = 4;
/**
* The max index that will be stored in the primary list.
*/
private static final int PRIMARY_MAX = 20;
/**
* The max index that will be stored in the master4 list.
*/
private static final int MASTER4_MAX = 120;
/**
* Internal WeakReferenceList that is capable to restore its elements. The elements in
* this list are page start report states.
*/
private static final class MasterList extends WeakReferenceList
{
/**
* The master list.
*/
private final PageStateList master;
/**
* Creates a new master list.
*
* @param list the list.
* @param maxChildCount the maximum number of elements in this list.
*/
private MasterList (final PageStateList list, final int maxChildCount)
{
super(maxChildCount);
this.master = list;
}
/**
* Function to restore the state of a child after the child was garbage collected.
*
* @param index the index.
* @return the restored ReportState of the given index, or null, if the state could
* not be restored.
*/
protected Object restoreChild (final int index)
{
final PageState master = (PageState) getMaster();
if (master == null)
{
return null;
}
final int max = getChildPos(index);
try
{
return this.restoreState(max, master);
}
catch (Exception rpe)
{
return null;
}
}
/**
* Internal handler function restore a state. Count denotes the number of pages
* required to be processed to restore the page, when the reportstate master is used
* as source element.
*
* @param count the count.
* @param rootstate the root state.
* @return the report state.
*
* @throws ReportProcessingException if there was a problem processing the report.
*/
private PageState restoreState (final int count, final PageState rootstate)
throws ReportProcessingException, StateException,
ReportDataFactoryException, DataSourceException
{
if (rootstate == null)
{
throw new NullPointerException("Master is null");
}
PageState state = rootstate;
for (int i = 0; i <= count; i++)
{
final PaginatingReportProcessor pageProcess = master.getPageProcess();
state = pageProcess.processPage(state);
set(state, i + 1);
// todo: How to prevent endless loops. Should we prevent them at all?
}
return state;
}
}
/**
* The list of master states. This is a list of WeakReferenceLists. These
* WeakReferenceLists contain their master state as first child. The weakReferenceLists
* have a maxSize of 10, so every 10th state will protected from being
* garbageCollected.
*/
private ArrayList masterStates10; // all states > 120
/**
* The list of master states. This is a list of WeakReferenceLists. These
* WeakReferenceLists contain their master state as first child. The weakReferenceLists
* have a maxSize of 4, so every 4th state will protected from being garbageCollected.
*/
private ArrayList masterStates4; // all states from 20 - 120
/**
* The list of primary states. This is a list of ReportStates and is used to store the
* first 20 elements of this state list.
*/
private ArrayList primaryStates; // all states from 0 - 20
/**
* The number of elements in this list.
*/
private int size;
private PaginatingReportProcessor pageProcess;
/**
* Creates a new reportstatelist. The list will be filled using the specified report and
* output target. Filling of the list is done elsewhere.
*
* @param proc the reportprocessor used to restore lost states (null not permitted).
* @throws NullPointerException if the report processor is null
.
*/
public PageStateList (final PaginatingReportProcessor proc)
{
if (proc == null)
{
throw new NullPointerException("ReportProcessor null");
}
this.pageProcess = proc;
primaryStates = new ArrayList();
masterStates4 = new ArrayList();
masterStates10 = new ArrayList();
}
/**
* Returns the index of the WeakReferenceList in the master list.
*
* @param pos the position.
* @param maxListSize the maximum list size.
* @return the position within the masterStateList.
*/
private int getMasterPos (final int pos, final int maxListSize)
{
//return (int) Math.floor(pos / maxListSize);
return (pos / maxListSize);
}
protected PaginatingReportProcessor getPageProcess ()
{
return pageProcess;
}
/**
* Returns the number of elements in this list.
*
* @return the number of elements in the list.
*/
public int size ()
{
return this.size;
}
/**
* Adds this report state to the end of the list.
*
* @param state the report state.
*/
public void add (final PageState state)
{
if (state == null)
{
throw new NullPointerException();
}
// the first 20 Elements are stored directly into an ArrayList
if (size() < PRIMARY_MAX)
{
primaryStates.add(state);
this.size++;
}
// the next 100 Elements are stored into a list of 4-element weakReference
//list. So if an Element gets lost (GCd), only 4 states need to be replayed.
else if (size() < MASTER4_MAX)
{
final int secPos = size() - PRIMARY_MAX;
final int masterPos = getMasterPos(secPos, MASTERPOSITIONS_MED);
if (masterPos >= masterStates4.size())
{
final MasterList master = new MasterList(this, MASTERPOSITIONS_MED);
masterStates4.add(master);
master.add(state);
}
else
{
final MasterList master = (MasterList) masterStates4.get(masterPos);
master.add(state);
}
this.size++;
}
// all other Elements are stored into a list of 10-element weakReference
//list. So if an Element gets lost (GCd), 10 states need to be replayed.
else
{
final int thirdPos = size() - MASTER4_MAX;
final int masterPos = getMasterPos(thirdPos, MASTERPOSITIONS_MAX);
if (masterPos >= masterStates10.size())
{
final MasterList master = new MasterList(this, MASTERPOSITIONS_MAX);
masterStates10.add(master);
master.add(state);
}
else
{
final MasterList master = (MasterList) masterStates10.get(masterPos);
master.add(state);
}
this.size++;
}
}
/**
* Removes all elements in the list.
*/
public void clear ()
{
masterStates10.clear();
masterStates4.clear();
primaryStates.clear();
this.size = 0;
}
/**
* Retrieves the element on position index
in this list.
*
* @param index the index.
* @return the report state.
*/
public PageState get (int index)
{
if (index >= size() || index < 0)
{
throw new IndexOutOfBoundsException
("Index is invalid. Index was " + index + "; size was " + size());
}
if (index < PRIMARY_MAX)
{
return (PageState) primaryStates.get(index);
}
else if (index < MASTER4_MAX)
{
index -= PRIMARY_MAX;
final MasterList master
= (MasterList) masterStates4.get(getMasterPos(index, MASTERPOSITIONS_MED));
return (PageState) master.get(index);
}
else
{
index -= MASTER4_MAX;
final MasterList master
= (MasterList) masterStates10.get(getMasterPos(index, MASTERPOSITIONS_MAX));
return (PageState) master.get(index);
}
}
}
././@LongLink 0000000 0000000 0000000 00000000153 00000000000 011564 L ustar root root pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/flow/paginating/PaginatingReportProcessor.java pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/flow/paginating/PaginatingReportProcesso0000644 0001750 0001750 00000024666 11305540676 032575 0 ustar rene rene /**
* ========================================
* JFreeReport : a free Java report library
* ========================================
*
* Project Info: http://reporting.pentaho.org/
*
* (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors.
*
* This library is free software; you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation;
* either version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* ------------
* $Id: PaginatingReportProcessor.java 10756 2009-12-02 15:58:24Z tmorgner $
* ------------
* (C) Copyright 2000-2005, by Object Refinery Limited.
* (C) Copyright 2005-2007, by Pentaho Corporation.
*/
package org.jfree.report.flow.paginating;
import org.jfree.layouting.ChainingLayoutProcess;
import org.jfree.layouting.DefaultLayoutProcess;
import org.jfree.layouting.LayoutProcess;
import org.jfree.layouting.StateException;
import org.jfree.layouting.output.pageable.PageableOutputProcessor;
import org.jfree.layouting.util.IntList;
import org.jfree.report.DataSourceException;
import org.jfree.report.ReportDataFactoryException;
import org.jfree.report.ReportProcessingException;
import org.jfree.report.flow.AbstractReportProcessor;
import org.jfree.report.flow.FlowController;
import org.jfree.report.flow.LibLayoutReportTarget;
import org.jfree.report.flow.ReportContext;
import org.jfree.report.flow.ReportJob;
import org.jfree.report.flow.ReportTarget;
import org.jfree.report.flow.ReportTargetState;
import org.jfree.report.flow.layoutprocessor.LayoutController;
import org.jfree.report.flow.layoutprocessor.LayoutControllerFactory;
import org.pentaho.reporting.libraries.resourceloader.ResourceManager;
import org.pentaho.reporting.libraries.resourceloader.ResourceKey;
import org.pentaho.reporting.libraries.base.util.DebugLog;
/**
* Paginating report processors are multi-pass processors.
*
* This is written to use LibLayout. It will never work with other report
* targets.
*
* Be aware that this class is not synchronized.
*
* @author Thomas Morgner
*/
public abstract class PaginatingReportProcessor extends AbstractReportProcessor
{
private PageableOutputProcessor outputProcessor;
private PageStateList stateList;
private IntList physicalMapping;
private IntList logicalMapping;
protected PaginatingReportProcessor(final PageableOutputProcessor outputProcessor)
{
this.outputProcessor = outputProcessor;
}
public PageableOutputProcessor getOutputProcessor()
{
return outputProcessor;
}
protected LibLayoutReportTarget createTarget(final ReportJob job)
{
if (outputProcessor == null)
{
throw new IllegalStateException("OutputProcessor is invalid.");
}
final LayoutProcess layoutProcess =
new ChainingLayoutProcess(new DefaultLayoutProcess(outputProcessor));
final ResourceManager resourceManager = job.getReportStructureRoot().getResourceManager();
final ResourceKey resourceKey = job.getReportStructureRoot().getBaseResource();
return new LibLayoutReportTarget
(job, resourceKey, resourceManager, layoutProcess);
}
// public void processReport(ReportJob job)
// throws ReportDataFactoryException,
// DataSourceException, ReportProcessingException
// {
// prepareReportProcessing(job);
//
// }
protected void prepareReportProcessing(final ReportJob job)
throws ReportDataFactoryException, DataSourceException, ReportProcessingException
{
if (job == null)
{
throw new NullPointerException();
}
final long start = System.currentTimeMillis();
// first, compute the globals
processReportRun(job, createTarget(job));
if (outputProcessor.isGlobalStateComputed() == false)
{
throw new ReportProcessingException
("Pagination has not yet been finished.");
}
// second, paginate
processPaginationRun(job, createTarget(job));
if (outputProcessor.isPaginationFinished() == false)
{
throw new ReportProcessingException
("Pagination has not yet been finished.");
}
if (outputProcessor.isContentGeneratable() == false)
{
throw new ReportProcessingException
("Illegal State.");
}
final long end = System.currentTimeMillis();
System.out.println("Pagination-Time: " + (end - start));
}
protected PageStateList processPaginationRun(final ReportJob job,
final LibLayoutReportTarget target)
throws ReportDataFactoryException,
DataSourceException, ReportProcessingException
{
if (job == null)
{
throw new NullPointerException();
}
stateList = new PageStateList(this);
physicalMapping = new IntList(40);
logicalMapping = new IntList(20);
final ReportContext context = createReportContext(job, target);
final LayoutControllerFactory layoutFactory =
context.getLayoutControllerFactory();
// we have the data and we have our position inside the report.
// lets generate something ...
final FlowController flowController = createFlowControler(context, job);
LayoutController layoutController =
layoutFactory.create(flowController, job.getReportStructureRoot(), null);
try
{
stateList.add(new PageState(target.saveState(), layoutController,
outputProcessor.getPageCursor()));
int logPageCount = outputProcessor.getLogicalPageCount();
int physPageCount = outputProcessor.getPhysicalPageCount();
while (layoutController.isAdvanceable())
{
layoutController = layoutController.advance(target);
target.commit();
while (layoutController.isAdvanceable() == false &&
layoutController.getParent() != null)
{
final LayoutController parent = layoutController.getParent();
layoutController = parent.join(layoutController.getFlowController());
}
// check whether a pagebreak has been encountered.
if (target.isPagebreakEncountered())
{
// So we hit a pagebreak. Store the state for later reuse.
// A single state can refer to more than one physical page.
final int newLogPageCount = outputProcessor.getLogicalPageCount();
final int newPhysPageCount = outputProcessor.getPhysicalPageCount();
final int result = stateList.size() - 1;
for (; physPageCount < newPhysPageCount; physPageCount++)
{
physicalMapping.add(result);
}
for (; logPageCount < newLogPageCount; logPageCount++)
{
logicalMapping.add(result);
}
logPageCount = newLogPageCount;
physPageCount = newPhysPageCount;
final ReportTargetState targetState = target.saveState();
final PageState state =
new PageState (targetState, layoutController,
outputProcessor.getPageCursor());
stateList.add(state);
// This is an assertation that we do not run into invalid states
// later.
if (PaginatingReportProcessor.ASSERTATION)
{
final ReportTarget reportTarget =
targetState.restore(outputProcessor);
}
target.resetPagebreakFlag();
}
}
// And when we reached the end, add the remaining pages ..
final int newLogPageCount = outputProcessor.getLogicalPageCount();
final int newPhysPageCount = outputProcessor.getPhysicalPageCount();
final int result = stateList.size() - 1;
for (; physPageCount < newPhysPageCount; physPageCount++)
{
physicalMapping.add(result);
}
for (; logPageCount < newLogPageCount; logPageCount++)
{
logicalMapping.add(result);
}
}
catch (final StateException e)
{
throw new ReportProcessingException("Argh, Unable to save the state!");
}
DebugLog.log("After pagination we have " + stateList.size() + " states");
return stateList;
}
public boolean isPaginated()
{
return outputProcessor.isPaginationFinished();
}
protected PageState getLogicalPageState (final int page)
{
return stateList.get(logicalMapping.get(page));
}
protected PageState getPhysicalPageState (final int page)
{
return stateList.get(physicalMapping.get(page));
}
public PageState processPage(final PageState previousState)
throws StateException, ReportProcessingException,
ReportDataFactoryException, DataSourceException
{
final ReportTargetState targetState = previousState.getTargetState();
final LibLayoutReportTarget target =
(LibLayoutReportTarget) targetState.restore(outputProcessor);
outputProcessor.setPageCursor(previousState.getPageCursor());
LayoutController position = previousState.getLayoutController();
// we have the data and we have our position inside the report.
// lets generate something ...
while (position.isAdvanceable())
{
position = position.advance(target);
target.commit();
// else check whether this state is finished, and try to join the subflow
// with the parent.
while (position.isAdvanceable() == false &&
position.getParent() != null)
{
final LayoutController parent = position.getParent();
position = parent.join(position.getFlowController());
}
// check whether a pagebreak has been encountered.
if (target.isPagebreakEncountered())
{
// So we hit a pagebreak. Store the state for later reuse.
// A single state can refer to more than one physical page.
final PageState state = new PageState
(target.saveState(), position, outputProcessor.getPageCursor());
target.resetPagebreakFlag();
return state;
}
}
// reached the finish state .. this is bad!
return null;
}
private static final boolean ASSERTATION = true;
}
pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/flow/paginating/PageState.java 0000644 0001750 0001750 00000004347 11305540676 030371 0 ustar rene rene /**
* ========================================
* JFreeReport : a free Java report library
* ========================================
*
* Project Info: http://reporting.pentaho.org/
*
* (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors.
*
* This library is free software; you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation;
* either version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* ------------
* $Id: PageState.java 10756 2009-12-02 15:58:24Z tmorgner $
* ------------
* (C) Copyright 2000-2005, by Object Refinery Limited.
* (C) Copyright 2005-2007, by Pentaho Corporation.
*/
package org.jfree.report.flow.paginating;
import java.io.Serializable;
import org.jfree.report.flow.ReportTargetState;
import org.jfree.report.flow.layoutprocessor.LayoutController;
/**
* Creation-Date: 11.11.2006, 19:01:53
*
* @author Thomas Morgner
*/
public class PageState implements Serializable
{
private ReportTargetState targetState;
private LayoutController layoutController;
private int pageCursor;
public PageState(final ReportTargetState targetState,
final LayoutController layoutController,
final int pageCursor)
{
this.layoutController = layoutController;
this.pageCursor = pageCursor;
this.targetState = targetState;
}
public int getPageCursor()
{
return pageCursor;
}
public ReportTargetState getTargetState()
{
return targetState;
}
public LayoutController getLayoutController()
{
return layoutController;
}
}
pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/flow/DefaultFlowController.java 0000644 0001750 0001750 00000027222 11305540676 030650 0 ustar rene rene /**
* ========================================
* JFreeReport : a free Java report library
* ========================================
*
* Project Info: http://reporting.pentaho.org/
*
* (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors.
*
* This library is free software; you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation;
* either version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* ------------
* $Id: DefaultFlowController.java 10756 2009-12-02 15:58:24Z tmorgner $
* ------------
* (C) Copyright 2000-2005, by Object Refinery Limited.
* (C) Copyright 2005-2007, by Pentaho Corporation.
*/
package org.jfree.report.flow;
import org.jfree.report.DataSourceException;
import org.jfree.report.ReportDataFactoryException;
import org.jfree.report.data.CachingReportDataFactory;
import org.jfree.report.data.ExpressionDataRow;
import org.jfree.report.data.ExpressionSlot;
import org.jfree.report.data.GlobalMasterRow;
import org.jfree.report.data.ImportedVariablesDataRow;
import org.jfree.report.data.ParameterDataRow;
import org.jfree.report.data.PrecomputedValueRegistry;
import org.jfree.report.data.PrecomputedValueRegistryBuilder;
import org.jfree.report.data.ReportDataRow;
import org.jfree.report.util.IntegerCache;
import org.pentaho.reporting.libraries.base.util.FastStack;
/**
* Creation-Date: 20.02.2006, 15:30:21
*
* @author Thomas Morgner
*/
public class DefaultFlowController implements FlowController
{
private static class ReportDataContext
{
private FastStack markStack;
private boolean advanceRequested;
public ReportDataContext(final FastStack markStack,
boolean advanceRequested)
{
this.advanceRequested = advanceRequested;
this.markStack = markStack;
}
public boolean isAdvanceRequested()
{
return advanceRequested;
}
public FastStack getMarkStack()
{
return markStack;
}
}
private CachingReportDataFactory reportDataFactory;
private GlobalMasterRow dataRow;
private boolean advanceRequested;
private FastStack reportStack;
private FastStack markStack;
private FastStack expressionsStack;
private String exportDescriptor;
private ReportContext reportContext;
private ReportJob job;
private PrecomputedValueRegistry precomputedValueRegistry;
public DefaultFlowController(final ReportContext reportContext,
final ReportJob job)
throws DataSourceException
{
if (job == null)
{
throw new NullPointerException();
}
if (reportContext == null)
{
throw new NullPointerException();
}
this.reportContext = reportContext;
this.job = job;
this.exportDescriptor = reportContext.getExportDescriptor();
this.reportDataFactory = new CachingReportDataFactory(job.getDataFactory());
this.reportStack = new FastStack();
this.markStack = new FastStack();
this.expressionsStack = new FastStack();
this.advanceRequested = false;
this.dataRow = GlobalMasterRow.createReportRow(reportContext);
this.dataRow.setParameterDataRow(new ParameterDataRow(job.getParameters()));
this.precomputedValueRegistry = new PrecomputedValueRegistryBuilder();
}
protected DefaultFlowController(final DefaultFlowController fc,
final GlobalMasterRow dataRow)
{
this.reportContext = fc.reportContext;
this.job = fc.job;
this.exportDescriptor = fc.exportDescriptor;
this.reportDataFactory = fc.reportDataFactory;
this.reportStack = (FastStack) fc.reportStack.clone();
this.markStack = (FastStack) fc.markStack.clone();
this.expressionsStack = (FastStack) fc.expressionsStack.clone();
this.advanceRequested = fc.advanceRequested;
this.dataRow = dataRow;
this.precomputedValueRegistry = fc.precomputedValueRegistry;
}
public FlowController performOperation(FlowControlOperation operation)
throws DataSourceException
{
if (operation == FlowControlOperation.ADVANCE)
{
if (dataRow.isAdvanceable() && advanceRequested == false)
{
DefaultFlowController fc = new DefaultFlowController(this, dataRow);
fc.advanceRequested = true;
return fc;
}
}
else if (operation == FlowControlOperation.MARK)
{
DefaultFlowController fc = new DefaultFlowController(this, dataRow);
fc.markStack.push(dataRow);
return fc;
}
else if (operation == FlowControlOperation.RECALL)
{
if (markStack.isEmpty())
{
return this;
}
DefaultFlowController fc = new DefaultFlowController(this, dataRow);
fc.dataRow = (GlobalMasterRow) fc.markStack.pop();
fc.advanceRequested = false;
return fc;
}
else if (operation == FlowControlOperation.DONE)
{
// do not change the current data row..
DefaultFlowController fc = new DefaultFlowController(this, dataRow);
fc.markStack.pop();
return fc;
}
else if (operation == FlowControlOperation.COMMIT)
{
if (isAdvanceRequested())
{
DefaultFlowController fc = new DefaultFlowController(this, dataRow);
fc.dataRow = dataRow.advance();
fc.advanceRequested = false;
return fc;
}
}
return this;
}
public GlobalMasterRow getMasterRow()
{
return dataRow;
}
public boolean isAdvanceRequested()
{
return advanceRequested;
}
/**
* This should be called only once per report processing. A JFreeReport object
* defines the global master report - all other reports are subreport
* instances.
*
* The global master report receives its parameter set from the
* Job-Definition, while subreports will read their parameters from the
* current datarow state.
*
* @param query
* @return
* @throws ReportDataFactoryException
* @throws DataSourceException
*/
public FlowController performQuery(final String query)
throws ReportDataFactoryException, DataSourceException
{
final GlobalMasterRow masterRow =
GlobalMasterRow.createReportRow(dataRow, reportContext);
masterRow.setParameterDataRow(new ParameterDataRow
(getReportJob().getParameters()));
masterRow.setReportDataRow(ReportDataRow.createDataRow
(reportDataFactory, query, dataRow.getGlobalView()));
final DefaultFlowController fc = new DefaultFlowController(this, masterRow);
fc.reportStack.push(new ReportDataContext(fc.markStack, advanceRequested));
fc.markStack = new FastStack();
fc.dataRow = masterRow;
return fc;
}
public FlowController performSubReportQuery(final String query,
final ParameterMapping[] inputParameters,
final ParameterMapping[] outputParameters
)
throws ReportDataFactoryException, DataSourceException
{
final GlobalMasterRow outerRow = dataRow.derive();
// create a view for the parameters of the report ...
final GlobalMasterRow masterRow =
GlobalMasterRow.createReportRow(outerRow, reportContext);
masterRow.setParameterDataRow
(new ParameterDataRow(inputParameters, outerRow.getGlobalView()));
// perform the query ...
// add the resultset ...
masterRow.setReportDataRow(ReportDataRow.createDataRow
(reportDataFactory, query, masterRow.getGlobalView()));
if (outputParameters == null)
{
outerRow.setExportedDataRow(new ImportedVariablesDataRow(masterRow));
}
else
{
// check and rebuild the parameter mapping from the inner to the outer
// context. Only deep-traversal expressions will be able to see these
// values (unless they have been defined as local variables).
outerRow.setExportedDataRow(new ImportedVariablesDataRow
(masterRow, outputParameters));
}
DefaultFlowController fc = new DefaultFlowController(this, masterRow);
fc.reportStack.push(new ReportDataContext(fc.markStack, advanceRequested));
fc.markStack = new FastStack();
fc.dataRow = masterRow;
return fc;
}
public FlowController activateExpressions(final ExpressionSlot[] expressions)
throws DataSourceException
{
if (expressions.length == 0)
{
DefaultFlowController fc = new DefaultFlowController(this, dataRow);
fc.expressionsStack.push(IntegerCache.getInteger(0));
return fc;
}
final GlobalMasterRow dataRow = this.dataRow.derive();
final ExpressionDataRow edr = dataRow.getExpressionDataRow();
edr.pushExpressions(expressions);
DefaultFlowController fc = new DefaultFlowController(this, dataRow);
final Integer exCount = IntegerCache.getInteger(expressions.length);
fc.expressionsStack.push(exCount);
return fc;
}
public FlowController deactivateExpressions() throws DataSourceException
{
final Integer counter = (Integer) this.expressionsStack.peek();
final int counterRaw = counter.intValue();
if (counterRaw == 0)
{
DefaultFlowController fc = new DefaultFlowController(this, dataRow);
fc.expressionsStack.pop();
return fc;
}
final GlobalMasterRow dataRow = this.dataRow.derive();
final ExpressionDataRow edr = dataRow.getExpressionDataRow();
DefaultFlowController fc = new DefaultFlowController(this, dataRow);
fc.expressionsStack.pop();
edr.popExpressions(counterRaw);
return fc;
}
public FlowController performReturnFromQuery() throws DataSourceException
{
DefaultFlowController fc = new DefaultFlowController(this, dataRow);
final ReportDataRow reportDataRow = dataRow.getReportDataRow();
if (reportDataRow == null)
{
return this;
}
// We dont close the report data, as some previously saved states may
// still reference it. (The caching report data factory takes care of
// that later.)
ReportDataContext context = (ReportDataContext) fc.reportStack.pop();
fc.dataRow = dataRow.getParentDataRow();
fc.dataRow = fc.dataRow.derive();
fc.dataRow.setExportedDataRow(null);
fc.markStack = context.getMarkStack();
fc.advanceRequested = context.isAdvanceRequested();
return fc;
}
public ReportJob getReportJob()
{
return job;
}
public String getExportDescriptor()
{
return exportDescriptor;
}
public ReportContext getReportContext()
{
return reportContext;
}
/**
* Returns the current expression slots of all currently active expressions.
*
* @return
* @throws org.jfree.report.DataSourceException
*
*/
public ExpressionSlot[] getActiveExpressions() throws DataSourceException
{
return dataRow.getExpressionDataRow().getSlots();
}
public FlowController createPrecomputeInstance() throws DataSourceException
{
final DefaultFlowController precompute = new DefaultFlowController(this, dataRow.derive());
precompute.precomputedValueRegistry = new PrecomputedValueRegistryBuilder();
return precompute;
}
public PrecomputedValueRegistry getPrecomputedValueRegistry()
{
return precomputedValueRegistry;
}
}
pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/flow/flowing/ 0000755 0001750 0001750 00000000000 11305540676 025165 5 ustar rene rene pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/flow/flowing/FlowReportProcessor.java 0000644 0001750 0001750 00000007535 11305540676 032045 0 ustar rene rene /**
* ========================================
* JFreeReport : a free Java report library
* ========================================
*
* Project Info: http://reporting.pentaho.org/
*
* (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors.
*
* This library is free software; you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation;
* either version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* ------------
* $Id: FlowReportProcessor.java 10756 2009-12-02 15:58:24Z tmorgner $
* ------------
* (C) Copyright 2000-2005, by Object Refinery Limited.
* (C) Copyright 2005-2007, by Pentaho Corporation.
*/
package org.jfree.report.flow.flowing;
import org.jfree.layouting.ChainingLayoutProcess;
import org.jfree.layouting.DefaultLayoutProcess;
import org.jfree.layouting.LayoutProcess;
import org.jfree.layouting.output.OutputProcessor;
import org.jfree.report.DataSourceException;
import org.jfree.report.ReportDataFactoryException;
import org.jfree.report.ReportProcessingException;
import org.jfree.report.flow.AbstractReportProcessor;
import org.jfree.report.flow.LibLayoutReportTarget;
import org.jfree.report.flow.ReportJob;
import org.pentaho.reporting.libraries.resourceloader.ResourceKey;
import org.pentaho.reporting.libraries.resourceloader.ResourceManager;
/**
* This is written to use LibLayout. It will never work with other report
* targets.
*
* @author Thomas Morgner
*/
public class FlowReportProcessor extends AbstractReportProcessor
{
private OutputProcessor outputProcessor;
public FlowReportProcessor()
{
}
public OutputProcessor getOutputProcessor()
{
return outputProcessor;
}
public void setOutputProcessor(final OutputProcessor outputProcessor)
{
this.outputProcessor = outputProcessor;
}
protected LibLayoutReportTarget createTarget(final ReportJob job)
{
if (outputProcessor == null)
{
throw new IllegalStateException(
"OutputProcessor is invalid.");
}
final LayoutProcess layoutProcess =
new ChainingLayoutProcess(new DefaultLayoutProcess(outputProcessor));
final ResourceManager resourceManager = job.getReportStructureRoot().getResourceManager();
final ResourceKey resourceKey = job.getReportStructureRoot().getBaseResource();
return new LibLayoutReportTarget
(job, resourceKey, resourceManager, layoutProcess);
}
/**
* Bootstraps the local report processing. This way of executing the report
* must be supported by *all* report processor implementations. It should
* fully process the complete report.
*
* @param job
* @throws ReportDataFactoryException
*/
public void processReport (final ReportJob job)
throws ReportDataFactoryException, DataSourceException,
ReportProcessingException
{
if (job == null)
{
throw new NullPointerException();
}
synchronized (job)
{
// first, compute the globals
processReportRun(job, createTarget(job));
// second, paginate (this splits the stream into flows)
processReportRun(job, createTarget(job));
// third, generate the content.
processReportRun(job, createTarget(job));
}
}
}
pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/flow/DefaultReportJob.java 0000644 0001750 0001750 00000010344 11305540700 027564 0 ustar rene rene /**
* ========================================
* JFreeReport : a free Java report library
* ========================================
*
* Project Info: http://reporting.pentaho.org/
*
* (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors.
*
* This library is free software; you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation;
* either version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* ------------
* $Id: DefaultReportJob.java 10756 2009-12-02 15:58:24Z tmorgner $
* ------------
* (C) Copyright 2000-2005, by Object Refinery Limited.
* (C) Copyright 2005-2007, by Pentaho Corporation.
*/
package org.jfree.report.flow;
import org.jfree.report.ReportDataFactory;
import org.jfree.report.i18n.DefaultResourceBundleFactory;
import org.jfree.report.i18n.ResourceBundleFactory;
import org.jfree.report.util.ReportParameters;
import org.pentaho.reporting.libraries.base.config.ModifiableConfiguration;
import org.pentaho.reporting.libraries.base.config.HierarchicalConfiguration;
/**
* Creation-Date: 22.02.2006, 12:47:53
*
* @author Thomas Morgner
*/
public class DefaultReportJob
implements ReportJob
{
private ReportStructureRoot report;
private ReportDataFactory dataFactory;
private ReportParameters parameters;
private ModifiableConfiguration configuration;
private ResourceBundleFactory resourceBundleFactory;
private String name;
//private PageFormat pageFormat;
public DefaultReportJob(final ReportStructureRoot report)
{
this.resourceBundleFactory = new DefaultResourceBundleFactory();
this.report = report;
final ReportDataFactory dataFactory = report.getDataFactory();
if (dataFactory != null)
{
this.dataFactory = dataFactory.derive();
}
this.parameters = new ReportParameters(report.getInputParameters());
this.configuration = new HierarchicalConfiguration(report.getConfiguration());
}
public ModifiableConfiguration getConfiguration()
{
return configuration;
}
public ReportParameters getParameters()
{
return parameters;
}
public ReportStructureRoot getReportStructureRoot()
{
return report;
}
public ReportDataFactory getDataFactory()
{
return dataFactory;
}
public void setDataFactory(final ReportDataFactory dataFactory)
{
this.dataFactory = dataFactory;
}
public Object clone() throws CloneNotSupportedException
{
DefaultReportJob job = (DefaultReportJob) super.clone();
if (dataFactory != null)
{
job.dataFactory = dataFactory.derive();
}
job.parameters = (ReportParameters) parameters.clone();
job.configuration = (ModifiableConfiguration) configuration.clone();
return job;
}
public ReportJob derive()
{
try
{
return (ReportJob) clone();
}
catch (CloneNotSupportedException e)
{
throw new IllegalStateException
("A report job should always be cloneable.");
}
}
public synchronized void close()
{
if (dataFactory != null)
{
dataFactory.close();
}
}
public ResourceBundleFactory getResourceBundleFactory()
{
return resourceBundleFactory;
}
public void setResourceBundleFactory(ResourceBundleFactory resourceBundleFactory)
{
this.resourceBundleFactory = resourceBundleFactory;
}
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
//
// public PageFormat getPageFormat()
// {
// return pageFormat;
// }
//
// public void setPageFormat(PageFormat pageFormat)
// {
// this.pageFormat = pageFormat;
// }
}
pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/flow/ReportContext.java 0000644 0001750 0001750 00000004605 11305540676 027210 0 ustar rene rene /**
* ========================================
* JFreeReport : a free Java report library
* ========================================
*
* Project Info: http://reporting.pentaho.org/
*
* (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors.
*
* This library is free software; you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation;
* either version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* ------------
* $Id: ReportContext.java 10756 2009-12-02 15:58:24Z tmorgner $
* ------------
* (C) Copyright 2000-2005, by Object Refinery Limited.
* (C) Copyright 2005-2007, by Pentaho Corporation.
*/
package org.jfree.report.flow;
import org.jfree.report.flow.layoutprocessor.LayoutControllerFactory;
import org.jfree.report.i18n.ResourceBundleFactory;
import org.pentaho.reporting.libraries.formula.FormulaContext;
/**
* THe global report context. This context acts as global structure that holds
* all processing factories and allows to store global attributes. The
* attribute collection is a global collection, all layout controller have
* shared access to the same collection.
*
* Each report run (prepare, paginate, content-generate) uses its own context
* implementation - attributes are not shared or preserved among the different
* runs.
*
* @author Thomas Morgner
*/
public interface ReportContext
{
public FormulaContext getFormulaContext();
public LayoutControllerFactory getLayoutControllerFactory();
public String getExportDescriptor();
public ResourceBundleFactory getResourceBundleFactory();
public ReportStructureRoot getReportStructureRoot();
public void setAttribute (Object key, Object value);
public Object getAttribute (Object key);
}
pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/flow/LayoutExpressionRuntime.java 0000644 0001750 0001750 00000007026 11305540676 031271 0 ustar rene rene /**
* ========================================
* JFreeReport : a free Java report library
* ========================================
*
* Project Info: http://reporting.pentaho.org/
*
* (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors.
*
* This library is free software; you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation;
* either version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* ------------
* $Id: LayoutExpressionRuntime.java 10756 2009-12-02 15:58:24Z tmorgner $
* ------------
* (C) Copyright 2000-2005, by Object Refinery Limited.
* (C) Copyright 2005-2007, by Pentaho Corporation.
*/
package org.jfree.report.flow;
import org.jfree.report.DataRow;
import org.jfree.report.ReportData;
import org.jfree.report.expressions.ExpressionRuntime;
import org.jfree.report.i18n.ResourceBundleFactory;
import org.pentaho.reporting.libraries.base.config.Configuration;
/**
* Creation-Date: 04.03.2006, 16:41:49
*
* @author Thomas Morgner
*/
public class LayoutExpressionRuntime implements ExpressionRuntime
{
private DataRow dataRow;
private Configuration configuration;
private ReportData reportData;
private Object declaringParent;
private int currentRow;
private ReportContext reportContext;
public LayoutExpressionRuntime()
{
}
public void setCurrentRow(final int currentRow)
{
this.currentRow = currentRow;
}
public void setDataRow(final DataRow dataRow)
{
this.dataRow = dataRow;
}
public void setConfiguration(final Configuration configuration)
{
this.configuration = configuration;
}
public void setData(final ReportData reportData)
{
this.reportData = reportData;
}
public void setDeclaringParent(final Object declaringParent)
{
this.declaringParent = declaringParent;
}
/**
* Returns the datarow.
*
* @return
*/
public DataRow getDataRow()
{
return dataRow;
}
public Configuration getConfiguration()
{
return configuration;
}
public ResourceBundleFactory getResourceBundleFactory()
{
return reportContext.getResourceBundleFactory();
}
/**
* Returns the report data used in this section. If subreports are used, this
* does not reflect the complete report data.
*
* All access to the report data must be properly synchronized. Failure to do
* so may result in funny results. Do not assume that the report data will be
* initialized on the current cursor positon.
*
* @return
*/
public ReportData getData()
{
return reportData;
}
public Object getDeclaringParent()
{
return declaringParent;
}
public int getCurrentRow()
{
return currentRow;
}
public ReportContext getReportContext()
{
return reportContext;
}
public void setReportContext (final ReportContext reportContext)
{
this.reportContext = reportContext;
}
}
pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/flow/StatefullReportTarget.java 0000644 0001750 0001750 00000003146 11305540676 030675 0 ustar rene rene /**
* ========================================
* JFreeReport : a free Java report library
* ========================================
*
* Project Info: http://reporting.pentaho.org/
*
* (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors.
*
* This library is free software; you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation;
* either version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* ------------
* $Id: StatefullReportTarget.java 10756 2009-12-02 15:58:24Z tmorgner $
* ------------
* (C) Copyright 2000-2005, by Object Refinery Limited.
* (C) Copyright 2005-2007, by Pentaho Corporation.
*/
package org.jfree.report.flow;
import org.jfree.layouting.StateException;
/**
* Creation-Date: 11.11.2006, 19:02:57
*
* @author Thomas Morgner
*/
public interface StatefullReportTarget extends ReportTarget
{
public ReportTargetState saveState() throws StateException;
}
pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/flow/AbstractReportTarget.java 0000644 0001750 0001750 00000005527 11305540676 030502 0 ustar rene rene /**
* ========================================
* JFreeReport : a free Java report library
* ========================================
*
* Project Info: http://reporting.pentaho.org/
*
* (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors.
*
* This library is free software; you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation;
* either version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* ------------
* $Id: AbstractReportTarget.java 10756 2009-12-02 15:58:24Z tmorgner $
* ------------
* (C) Copyright 2000-2005, by Object Refinery Limited.
* (C) Copyright 2005-2007, by Pentaho Corporation.
*/
package org.jfree.report.flow;
import org.jfree.layouting.namespace.NamespaceDefinition;
import org.jfree.layouting.namespace.Namespaces;
import org.pentaho.reporting.libraries.resourceloader.ResourceKey;
import org.pentaho.reporting.libraries.resourceloader.ResourceManager;
/**
* Creation-Date: 03.07.2006, 16:31:12
*
* @author Thomas Morgner
*/
public abstract class AbstractReportTarget implements ReportTarget
{
private ResourceManager resourceManager;
private ResourceKey baseResource;
private ReportJob reportJob;
protected AbstractReportTarget(final ReportJob reportJob,
final ResourceManager resourceManager,
final ResourceKey baseResource)
{
if (reportJob == null)
{
throw new NullPointerException();
}
this.baseResource = baseResource;
this.reportJob = reportJob;
if (resourceManager == null)
{
this.resourceManager = new ResourceManager();
this.resourceManager.registerDefaults();
}
else
{
this.resourceManager = resourceManager;
}
}
protected NamespaceDefinition[] createDefaultNameSpaces()
{
return Namespaces.createFromConfig
(reportJob.getConfiguration(), "org.jfree.report.namespaces.",
getResourceManager());
}
protected ResourceManager getResourceManager()
{
return resourceManager;
}
protected ResourceKey getBaseResource()
{
return baseResource;
}
public ReportJob getReportJob()
{
return reportJob;
}
}
pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/TableReportDataFactory.java 0000644 0001750 0001750 00000006507 11305540676 027771 0 ustar rene rene /**
* ========================================
* JFreeReport : a free Java report library
* ========================================
*
* Project Info: http://reporting.pentaho.org/
*
* (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors.
*
* This library is free software; you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation;
* either version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* ------------
* $Id: TableReportDataFactory.java 10756 2009-12-02 15:58:24Z tmorgner $
* ------------
* (C) Copyright 2000-2005, by Object Refinery Limited.
* (C) Copyright 2005-2007, by Pentaho Corporation.
*/
package org.jfree.report;
import java.util.HashMap;
import javax.swing.table.TableModel;
/**
* Creation-Date: 21.02.2006, 17:59:32
*
* @author Thomas Morgner
*/
public class TableReportDataFactory implements ReportDataFactory, Cloneable
{
private HashMap tables;
public TableReportDataFactory()
{
this.tables = new HashMap();
}
public TableReportDataFactory(String name, TableModel tableModel)
{
this();
addTable(name, tableModel);
}
public void addTable(String name, TableModel tableModel)
{
tables.put(name, tableModel);
}
public void removeTable(String name)
{
tables.remove(name);
}
/**
* Queries a datasource. The string 'query' defines the name of the query. The
* Parameterset given here may contain more data than actually needed.
*
* The dataset may change between two calls, do not assume anything!
*
* @param query the name of the table.
* @param parameters are ignored for this factory.
* @return the report data or null.
*/
public ReportData queryData(final String query, final DataSet parameters)
throws ReportDataFactoryException
{
TableModel model = (TableModel) tables.get(query);
if (model == null)
{
return null;
}
return new TableReportData(model);
}
public void open()
{
}
public void close()
{
}
/**
* Derives a freshly initialized report data factory, which is independend of
* the original data factory. Opening or Closing one data factory must not
* affect the other factories.
*
* @return
*/
public ReportDataFactory derive()
{
try
{
return (ReportDataFactory) clone();
}
catch (CloneNotSupportedException e)
{
throw new IllegalStateException("Clone should not fail.");
}
}
public Object clone () throws CloneNotSupportedException
{
TableReportDataFactory dataFactory = (TableReportDataFactory) super.clone();
dataFactory.tables = (HashMap) tables.clone();
return dataFactory;
}
}
pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/expressions/ 0000755 0001750 0001750 00000000000 11305540700 025117 5 ustar rene rene pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/expressions/AbstractExpression.java 0000644 0001750 0001750 00000012554 11305540700 031614 0 ustar rene rene /**
* ========================================
* JFreeReport : a free Java report library
* ========================================
*
* Project Info: http://reporting.pentaho.org/
*
* (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors.
*
* This library is free software; you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation;
* either version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* ------------
* $Id: AbstractExpression.java 10756 2009-12-02 15:58:24Z tmorgner $
* ------------
* (C) Copyright 2000-2005, by Object Refinery Limited.
* (C) Copyright 2005-2007, by Pentaho Corporation.
*/
package org.jfree.report.expressions;
import java.util.Locale;
import org.jfree.report.DataRow;
import org.jfree.report.flow.ReportContext;
import org.jfree.report.flow.ReportStructureRoot;
import org.jfree.report.i18n.ResourceBundleFactory;
import org.jfree.report.structure.Element;
import org.pentaho.reporting.libraries.base.config.Configuration;
/**
* A baseclass for simple, non-positionally parametrized expressions.
*
* @author Thomas Morgner
*/
public abstract class AbstractExpression implements Expression
{
private transient ExpressionRuntime runtime;
private String name;
private boolean deepTraversing;
private boolean precompute;
private boolean preserve;
protected AbstractExpression()
{
}
/**
* Returns the name of the expression. An expression without a name cannot be
* referenced from outside the element.
*
* @return the function name.
*/
public String getName()
{
return name;
}
/**
* Sets the name of the expression.
*
* @param name the name.
*/
public void setName(final String name)
{
this.name = name;
}
/**
* Clones the expression, expression should be reinitialized after the
* cloning. Expression maintain no state, cloning is done at the beginning * of the report processing to disconnect the used expression from any other * object space. * * @return A clone of this expression. * @throws CloneNotSupportedException this should never happen. */ public Object clone() throws CloneNotSupportedException { return (AbstractExpression) super.clone(); } /** * Return a new instance of this expression. The copy is initialized and uses * the same parameters as the original, but does not share any objects. * * @return a copy of this function. */ public Expression getInstance() { try { final AbstractExpression abstractExpression = (AbstractExpression) clone(); abstractExpression.runtime = null; return abstractExpression; } catch (CloneNotSupportedException cne) { return null; } } /** * Defines the DataRow used in this expression. The dataRow is set when the * report processing starts and can be used to access the values of functions, * expressions and the reports datasource. * * @param runtime the runtime information for the expression */ public void setRuntime(final ExpressionRuntime runtime) { this.runtime = runtime; } public ExpressionRuntime getRuntime() { return runtime; } /** * Returns the current {@link DataRow}. * * @return the data row. */ protected DataRow getDataRow() { if (runtime == null) { return null; } return runtime.getDataRow(); } protected ResourceBundleFactory getResourceBundleFactory() { if (runtime == null) { return null; } return runtime.getResourceBundleFactory(); } protected Configuration getReportConfiguration() { if (runtime == null) { return null; } return runtime.getConfiguration(); } protected Locale getParentLocale () { if (runtime == null) { return null; } final Object declaringParent = runtime.getDeclaringParent(); if (declaringParent instanceof Element) { final Element declaringElement = (Element) declaringParent; return declaringElement.getLocale(); } final ReportContext reportContext = runtime.getReportContext(); final ReportStructureRoot reportStructureRoot = reportContext.getReportStructureRoot(); return reportStructureRoot.getLocale(); } public boolean isPrecompute() { return precompute; } public void setPrecompute(final boolean precompute) { this.precompute = precompute; } public boolean isDeepTraversing() { return deepTraversing; } public void setDeepTraversing(final boolean deepTraversing) { this.deepTraversing = deepTraversing; } public boolean isPreserve() { return preserve; } public void setPreserve(final boolean preserve) { this.preserve = preserve; } } pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/expressions/ExpressionException.java 0000644 0001750 0001750 00000003676 11305540676 032030 0 ustar rene rene /** * ======================================== * JFreeReport : a free Java report library * ======================================== * * Project Info: http://reporting.pentaho.org/ * * (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors. * * This library is free software; you can redistribute it and/or modify it under the terms * of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License along with this * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307, USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------ * $Id: ExpressionException.java 10756 2009-12-02 15:58:24Z tmorgner $ * ------------ * (C) Copyright 2000-2005, by Object Refinery Limited. * (C) Copyright 2005-2007, by Pentaho Corporation. */ package org.jfree.report.expressions; import org.jfree.report.DataSourceException; /** * Creation-Date: 08.10.2006, 16:12:43 * * @author Thomas Morgner */ public class ExpressionException extends DataSourceException { /** * Creates an exception. * * @param message the exception message. */ public ExpressionException(final String message) { super(message); } /** * Creates an exception. * * @param message the exception message. * @param ex the parent exception. */ public ExpressionException(final String message, final Exception ex) { super(message, ex); } } pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/expressions/ExpressionRuntime.java 0000644 0001750 0001750 00000004675 11305540676 031515 0 ustar rene rene /** * ======================================== * JFreeReport : a free Java report library * ======================================== * * Project Info: http://reporting.pentaho.org/ * * (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors. * * This library is free software; you can redistribute it and/or modify it under the terms * of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License along with this * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307, USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------ * $Id: ExpressionRuntime.java 10756 2009-12-02 15:58:24Z tmorgner $ * ------------ * (C) Copyright 2000-2005, by Object Refinery Limited. * (C) Copyright 2005-2007, by Pentaho Corporation. */ package org.jfree.report.expressions; import org.jfree.report.DataRow; import org.jfree.report.ReportData; import org.jfree.report.flow.ReportContext; import org.jfree.report.i18n.ResourceBundleFactory; import org.pentaho.reporting.libraries.base.config.Configuration; /** * Creation-Date: 24.01.2006, 16:58:34 * * @author Thomas Morgner */ public interface ExpressionRuntime { /** * Returns the datarow. * * @return */ public DataRow getDataRow(); public Configuration getConfiguration(); public ResourceBundleFactory getResourceBundleFactory(); /** * Returns the report data used in this section. If subreports are used, * this does not reflect the complete report data. *
* All access to the report data must be properly synchronized. Failure to * do so may result in funny results. Do not assume that the report data * will be initialized on the current cursor positon. * * @return * @see ExpressionRuntime#getCurrentRow() */ public ReportData getData(); public int getCurrentRow(); public Object getDeclaringParent(); public ReportContext getReportContext(); } pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/expressions/FormulaFunction.java 0000644 0001750 0001750 00000017542 11305540676 031122 0 ustar rene rene /** * ======================================== * JFreeReport : a free Java report library * ======================================== * * Project Info: http://reporting.pentaho.org/ * * (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors. * * This library is free software; you can redistribute it and/or modify it under the terms * of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License along with this * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307, USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------ * $Id: FormulaFunction.java 10756 2009-12-02 15:58:24Z tmorgner $ * ------------ * (C) Copyright 2000-2005, by Object Refinery Limited. * (C) Copyright 2005-2007, by Pentaho Corporation. */ package org.jfree.report.expressions; import org.jfree.report.DataSourceException; import org.jfree.report.flow.ReportContext; import org.pentaho.reporting.libraries.formula.Formula; import org.pentaho.reporting.libraries.formula.FormulaContext; import org.pentaho.reporting.libraries.formula.parser.ParseException; import org.pentaho.reporting.libraries.base.util.DebugLog; /** * Creation-Date: 04.11.2006, 19:24:04 * * @author Thomas Morgner */ public class FormulaFunction extends AbstractExpression implements Function { private String formulaNamespace; private String formulaExpression; private String formula; private String initialNamespace; private String initialExpression; private String initial; private transient Formula compiledFormula; private boolean initialized; public FormulaFunction() { } private synchronized FormulaContext getFormulaContext() { final ReportContext globalContext = getRuntime().getReportContext(); return globalContext.getFormulaContext(); } public String getInitial() { return initial; } public String getInitialExpression() { return initialExpression; } public String getInitialNamespace() { return initialNamespace; } public void setInitial(final String initial) { this.initial = initial; if (initial == null) { initialNamespace = null; initialExpression = null; } else { final int separator = initial.indexOf(':'); if (separator <= 0 || ((separator + 1) == initial.length())) { if (formula.startsWith("=")) { initialNamespace = "report"; initialExpression = initial.substring(1); } else { // error: invalid formula. initialNamespace = null; initialExpression = null; } } else { initialNamespace = initial.substring(0, separator); initialExpression = initial.substring(separator + 1); } } } public String getFormula() { return formula; } public String getFormulaNamespace() { return formulaNamespace; } public String getFormulaExpression() { return formulaExpression; } public void setFormula(final String formula) { this.formula = formula; if (formula == null) { formulaNamespace = null; formulaExpression = null; } else { final int separator = formula.indexOf(':'); if (separator <= 0 || ((separator + 1) == formula.length())) { if (formula.startsWith("=")) { formulaNamespace = "report"; formulaExpression = formula.substring(1); } else { // error: invalid formula. formulaNamespace = null; formulaExpression = null; } } else { formulaNamespace = formula.substring(0, separator); formulaExpression = formula.substring(separator + 1); } } this.compiledFormula = null; } /** * When the advance method is called, the function is asked to perform the * next step of its computation. *
* The original function must not be altered during that step (or more * correctly, calling advance on the original expression again must not return * a different result). * * @return a copy of the function containing the new state. */ public Function advance() throws DataSourceException { try { return (Function) clone(); } catch (CloneNotSupportedException e) { throw new DataSourceException("Unable to derive a new instance"); } } private Object computeInitialValue() { try { if (initial != null) { final Formula initFormula = new Formula(initialExpression); final ReportFormulaContext context = new ReportFormulaContext(getFormulaContext(), getDataRow()); context.setDeclaringElement(getRuntime().getDeclaringParent()); try { initFormula.initialize(context); return initFormula.evaluate(); } finally { context.setDeclaringElement(null); context.setDataRow(null); } } // if the code above did not trigger, compute a regular thing .. return computeRegularValue(); } catch (Exception e) { DebugLog.log("Failed to compute the initial value."); return null; } } private Object computeRegularValue() { try { if (compiledFormula == null) { compiledFormula = new Formula(formulaExpression); } final ReportFormulaContext context = new ReportFormulaContext(getFormulaContext(), getDataRow()); context.setDeclaringElement(getRuntime().getDeclaringParent()); try { compiledFormula.initialize(context); return compiledFormula.evaluate(); } finally { context.setDeclaringElement(null); context.setDataRow(null); } } catch (Exception e) { DebugLog.log("Failed to compute the regular value.", e); return null; } } /** * Return the current expression value.The value depends (obviously) on * the expression implementation. * * @return the value of the function. */ public Object computeValue() throws DataSourceException { try { if (initialized == false) { initialized = true; return computeInitialValue(); } return computeRegularValue(); } catch (Exception e) { return null; } } /** * Clones the expression, expression should be reinitialized after the * cloning.
Expression maintain no state, cloning is done at the beginning * of the report processing to disconnect the used expression from any other * object space. * * @return A clone of this expression. * @throws CloneNotSupportedException this should never happen. */ public Object clone() throws CloneNotSupportedException { final FormulaFunction o = (FormulaFunction) super.clone(); if (compiledFormula != null) { o.compiledFormula = (Formula) compiledFormula.clone(); } return o; } /** * Returns the compiled formula. The formula is not connected to a formula * context. * * @return the formula. * @throws ParseException if the formula contains syntax errors. */ public Formula getCompiledFormula() throws ParseException { if (compiledFormula == null) { compiledFormula = new Formula(formulaExpression); } return compiledFormula; } } pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/expressions/ProxyExpressionRuntime.java 0000644 0001750 0001750 00000005701 11305540676 032546 0 ustar rene rene /** * ======================================== * JFreeReport : a free Java report library * ======================================== * * Project Info: http://reporting.pentaho.org/ * * (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors. * * This library is free software; you can redistribute it and/or modify it under the terms * of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License along with this * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307, USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------ * $Id: ProxyExpressionRuntime.java 10756 2009-12-02 15:58:24Z tmorgner $ * ------------ * (C) Copyright 2000-2005, by Object Refinery Limited. * (C) Copyright 2005-2007, by Pentaho Corporation. */ package org.jfree.report.expressions; import org.jfree.report.DataRow; import org.jfree.report.ReportData; import org.jfree.report.flow.ReportContext; import org.jfree.report.i18n.ResourceBundleFactory; import org.pentaho.reporting.libraries.base.config.Configuration; /** * Creation-Date: 22.04.2006, 14:17:54 * * @author Thomas Morgner */ public class ProxyExpressionRuntime implements ExpressionRuntime { private ExpressionRuntime parent; public ProxyExpressionRuntime(final ExpressionRuntime parent) { if (parent == null) { throw new NullPointerException(); } this.parent = parent; } /** * Returns the datarow. * * @return */ public DataRow getDataRow() { return parent.getDataRow(); } public Configuration getConfiguration() { return parent.getConfiguration(); } public ResourceBundleFactory getResourceBundleFactory() { return parent.getResourceBundleFactory(); } /** * Returns the report data used in this section. If subreports are used, this * does not reflect the complete report data. *
* All access to the report data must be properly synchronized. Failure to do * so may result in funny results. Do not assume that the report data will be * initialized on the current cursor positon. * * @return */ public ReportData getData() { return parent.getData(); } public int getCurrentRow() { return parent.getCurrentRow(); } public Object getDeclaringParent() { return parent.getDeclaringParent(); } public ReportContext getReportContext() { return parent.getReportContext(); } } pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/expressions/Expression.java 0000644 0001750 0001750 00000013224 11305540676 030137 0 ustar rene rene /** * ======================================== * JFreeReport : a free Java report library * ======================================== * * Project Info: http://reporting.pentaho.org/ * * (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors. * * This library is free software; you can redistribute it and/or modify it under the terms * of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License along with this * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307, USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------ * $Id: Expression.java 10756 2009-12-02 15:58:24Z tmorgner $ * ------------ * (C) Copyright 2000-2005, by Object Refinery Limited. * (C) Copyright 2005-2007, by Pentaho Corporation. */ package org.jfree.report.expressions; import java.io.Serializable; import org.jfree.report.DataSourceException; /** * An expression is a lightweight computation that does not maintain a state. * * Expressions are used to calculate values within a single row of a report. * Expressions can use a dataRow to access other fields, expressions or * functions within the current row in the report. * * Statefull computations can be implemented using functions. * * @author Thomas Morgner * @see Function */ public interface Expression extends Cloneable, Serializable { /** * Returns the name of the expression. An expression without a name cannot be * referenced from outside the element. * * @return the function name. */ public String getName(); /** * Sets the name of the expression. * * @param name the name. */ public void setName(String name); /** * Return the current expression value.The value depends (obviously) on * the expression implementation. * * @return the value of the function. */ public Object computeValue() throws DataSourceException; /** * Clones the expression, expression should be reinitialized after the * cloning.
Expression maintain no state, cloning is done at the beginning * of the report processing to disconnect the used expression from any other * object space. * * @return A clone of this expression. * @throws CloneNotSupportedException this should never happen. */ public Object clone() throws CloneNotSupportedException; /** * Return a new instance of this expression. The copy is initialized and uses * the same parameters as the original, but does not share any objects. * * @return a copy of this function. */ public Expression getInstance(); /** * Defines the DataRow used in this expression. The dataRow is set when the * report processing starts and can be used to access the values of functions, * expressions and the reports datasource. * * @param runtime the runtime information for the expression */ public void setRuntime(ExpressionRuntime runtime); /** * A deep-traversing expression declares that it should receive updates from * all subreports. This mode should be activated if the expression's result * depends on values contained in the subreport. * * @return true, if the expression is deep-traversing, false otherwise. */ public boolean isDeepTraversing (); /** * Defines, whether the expression is deep-traversing. * * @param deepTraversing true, if the expression is deep-traversing, false * otherwise. */ public void setDeepTraversing (boolean deepTraversing); /** * Returns, whether the expression will be precomputed. For precomputed * expressions a parallel evaluation process is started and the result to * which the expression evaluates before it gets out of scope will be used * whenever an other expression queries this expression's value. * * @return true, if the expression is precomputed, false otherwise. */ public boolean isPrecompute(); /** * Defines, whether the expression will be precomputed. For precomputed * expressions a parallel evaluation process is started and the result to * which the expression evaluates before it gets out of scope will be used * whenever an other expression queries this expression's value. * * @param precompute true, if the expression is precomputed, false otherwise. */ public void setPrecompute(boolean precompute); /** * Checks, whether the expression's result should be preserved in the * precomputed value registry. This way, the last value for that expression * can be retrieved after the report has been finished. * * The preserve-function will only preserve the last value that has been * evaluated before the expression went out of scope. * * @return true, if the expression's results should be preserved, * false otherwise. */ public boolean isPreserve(); /** * Defines, whether the expression's result should be preserved in the * precomputed value registry. This way, the last value for that expression * can be retrieved after the report has been finished. * * @param preserve true, if the expression's results should be preserved, * false otherwise. */ public void setPreserve(boolean preserve); } ././@LongLink 0000000 0000000 0000000 00000000151 00000000000 011562 L ustar root root pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/expressions/ColumnAggregationExpression.java pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/expressions/ColumnAggregationExpression.0000644 0001750 0001750 00000003625 11305540676 032627 0 ustar rene rene /** * ======================================== * JFreeReport : a free Java report library * ======================================== * * Project Info: http://reporting.pentaho.org/ * * (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors. * * This library is free software; you can redistribute it and/or modify it under the terms * of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License along with this * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307, USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------ * $Id: ColumnAggregationExpression.java 10756 2009-12-02 15:58:24Z tmorgner $ * ------------ * (C) Copyright 2000-2005, by Object Refinery Limited. * (C) Copyright 2005-2007, by Pentaho Corporation. */ package org.jfree.report.expressions; import org.jfree.report.DataSourceException; /** * Creation-Date: 04.01.2006, 17:23:01 * * @author Thomas Morgner */ public abstract class ColumnAggregationExpression extends AbstractExpression { protected ColumnAggregationExpression() { } protected abstract int getFieldListParameterPosition(); protected Object[] getFieldValues() throws DataSourceException { return getFieldValues(Object.class); } protected Object[] getFieldValues(Class type) throws DataSourceException { return null; // todo } } pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/expressions/FormulaExpression.java 0000644 0001750 0001750 00000012157 11305540676 031471 0 ustar rene rene /** * ======================================== * JFreeReport : a free Java report library * ======================================== * * Project Info: http://reporting.pentaho.org/ * * (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors. * * This library is free software; you can redistribute it and/or modify it under the terms * of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License along with this * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307, USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------ * $Id: FormulaExpression.java 10756 2009-12-02 15:58:24Z tmorgner $ * ------------ * (C) Copyright 2000-2005, by Object Refinery Limited. * (C) Copyright 2005-2007, by Pentaho Corporation. */ package org.jfree.report.expressions; import org.jfree.report.DataSourceException; import org.jfree.report.flow.ReportContext; import org.pentaho.reporting.libraries.formula.parser.ParseException; import org.pentaho.reporting.libraries.formula.Formula; import org.pentaho.reporting.libraries.formula.FormulaContext; import org.pentaho.reporting.libraries.base.util.DebugLog; /** * Creation-Date: 04.11.2006, 19:24:04 * * @author Thomas Morgner */ public class FormulaExpression extends AbstractExpression { private transient Formula compiledFormula; private String formulaNamespace; private String formulaExpression; private String formula; public FormulaExpression() { } private synchronized FormulaContext getFormulaContext() { final ReportContext globalContext = getRuntime().getReportContext(); return globalContext.getFormulaContext(); } public String getFormula() { return formula; } public String getFormulaNamespace() { return formulaNamespace; } public String getFormulaExpression() { return formulaExpression; } public void setFormula(final String formula) { this.formula = formula; if (formula == null) { formulaNamespace = null; formulaExpression = null; } else { final int separator = formula.indexOf(':'); if (separator <= 0 || ((separator + 1) == formula.length())) { if (formula.startsWith("=")) { formulaNamespace = "report"; formulaExpression = formula.substring(1); } else { // error: invalid formula. formulaNamespace = null; formulaExpression = null; } } else { formulaNamespace = formula.substring(0, separator); formulaExpression = formula.substring(separator + 1); } } this.compiledFormula = null; } private Object computeRegularValue() { try { if (compiledFormula == null) { compiledFormula = new Formula(formulaExpression); } final ReportFormulaContext context = new ReportFormulaContext(getFormulaContext(), getDataRow()); try { compiledFormula.initialize(context); return compiledFormula.evaluate(); } finally { context.setDataRow(null); } } catch (Exception e) { DebugLog.log("Failed to compute the regular value.", e); return null; } } /** * Returns the compiled formula. The formula is not connected to a formula * context. * * @return the formula. * @throws ParseException if the formula contains syntax errors. */ public Formula getCompiledFormula() throws ParseException { if (compiledFormula == null) { compiledFormula = new Formula(formulaExpression); } return compiledFormula; } /** * Return the current expression value.
The value depends (obviously) on * the expression implementation. * * @return the value of the function. */ public Object computeValue() throws DataSourceException { try { return computeRegularValue(); } catch (Exception e) { return null; } } /** * Clones the expression, expression should be reinitialized after the * cloning.
Expression maintain no state, cloning is done at the beginning * of the report processing to disconnect the used expression from any other * object space. * * @return A clone of this expression. * @throws CloneNotSupportedException this should never happen. */ public Object clone() throws CloneNotSupportedException { final FormulaExpression o = (FormulaExpression) super.clone(); if (compiledFormula != null) { o.compiledFormula = (Formula) compiledFormula.clone(); } return o; } } pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/expressions/ReportFormulaContext.java 0000644 0001750 0001750 00000012151 11305540676 032144 0 ustar rene rene /** * ======================================== * JFreeReport : a free Java report library * ======================================== * * Project Info: http://reporting.pentaho.org/ * * (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors. * * This library is free software; you can redistribute it and/or modify it under the terms * of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License along with this * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307, USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------ * $Id: ReportFormulaContext.java 10756 2009-12-02 15:58:24Z tmorgner $ * ------------ * (C) Copyright 2000-2005, by Object Refinery Limited. * (C) Copyright 2005-2007, by Pentaho Corporation. */ package org.jfree.report.expressions; import org.jfree.report.DataFlags; import org.jfree.report.DataRow; import org.jfree.report.DataSourceException; import org.pentaho.reporting.libraries.base.config.Configuration; import org.pentaho.reporting.libraries.base.util.DebugLog; import org.pentaho.reporting.libraries.formula.ContextEvaluationException; import org.pentaho.reporting.libraries.formula.FormulaContext; import org.pentaho.reporting.libraries.formula.LibFormulaErrorValue; import org.pentaho.reporting.libraries.formula.LocalizationContext; import org.pentaho.reporting.libraries.formula.function.FunctionRegistry; import org.pentaho.reporting.libraries.formula.operators.OperatorFactory; import org.pentaho.reporting.libraries.formula.typing.Type; import org.pentaho.reporting.libraries.formula.typing.TypeRegistry; import org.pentaho.reporting.libraries.formula.typing.coretypes.AnyType; import org.pentaho.reporting.libraries.formula.typing.coretypes.DateTimeType; import org.pentaho.reporting.libraries.formula.typing.coretypes.NumberType; import org.pentaho.reporting.libraries.formula.typing.coretypes.TextType; /** * Creation-Date: 29.11.2006, 17:54:33 * * @author Thomas Morgner */ public class ReportFormulaContext implements FormulaContext { private FormulaContext backend; private DataRow dataRow; private Object declaringElement; public ReportFormulaContext(FormulaContext backend, DataRow dataRow) { this.backend = backend; this.dataRow = dataRow; } public LocalizationContext getLocalizationContext() { return backend.getLocalizationContext(); } public Configuration getConfiguration() { return backend.getConfiguration(); } public FunctionRegistry getFunctionRegistry() { return backend.getFunctionRegistry(); } public TypeRegistry getTypeRegistry() { return backend.getTypeRegistry(); } public OperatorFactory getOperatorFactory() { return backend.getOperatorFactory(); } public boolean isReferenceDirty(Object name) throws ContextEvaluationException { try { final DataFlags flags = dataRow.getFlags(String.valueOf(name)); if (flags == null) { throw new ContextEvaluationException (new LibFormulaErrorValue(LibFormulaErrorValue.ERROR_REFERENCE_NOT_RESOLVABLE)); } return flags.isChanged(); } catch (Exception e) { throw new ContextEvaluationException (new LibFormulaErrorValue(LibFormulaErrorValue.ERROR_REFERENCE_NOT_RESOLVABLE)); } } public Type resolveReferenceType(Object name) { try { final DataFlags flags = dataRow.getFlags(String.valueOf(name)); if (flags != null) { if (flags.isDate()) { return DateTimeType.DATE_TYPE; } if (flags.isNumeric()) { return NumberType.GENERIC_NUMBER; } return TextType.TYPE; } } catch (DataSourceException ex) { } return AnyType.TYPE; } public Object resolveReference(Object name) throws ContextEvaluationException { if (name == null) { throw new NullPointerException(); } try { return dataRow.get(String.valueOf(name)); } catch (DataSourceException e) { DebugLog.log("Error while resolving formula reference: ", e); throw new ContextEvaluationException(new LibFormulaErrorValue (LibFormulaErrorValue.ERROR_REFERENCE_NOT_RESOLVABLE)); } } public DataRow getDataRow() { return dataRow; } public void setDataRow(final DataRow dataRow) { this.dataRow = dataRow; } public Object getDeclaringElement() { return declaringElement; } public void setDeclaringElement(final Object declaringElement) { this.declaringElement = declaringElement; } } pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/expressions/sys/ 0000755 0001750 0001750 00000000000 11305540676 025751 5 ustar rene rene ././@LongLink 0000000 0000000 0000000 00000000150 00000000000 011561 L ustar root root pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/expressions/sys/IsExportTypeExpression.java pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/expressions/sys/IsExportTypeExpression.j0000644 0001750 0001750 00000004646 11305540676 032635 0 ustar rene rene /** * ======================================== * JFreeReport : a free Java report library * ======================================== * * Project Info: http://reporting.pentaho.org/ * * (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors. * * This library is free software; you can redistribute it and/or modify it under the terms * of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License along with this * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307, USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------ * $Id: IsExportTypeExpression.java 10756 2009-12-02 15:58:24Z tmorgner $ * ------------ * (C) Copyright 2000-2005, by Object Refinery Limited. * (C) Copyright 2005-2007, by Pentaho Corporation. */ package org.jfree.report.expressions.sys; import org.jfree.report.expressions.AbstractExpression; import org.jfree.report.expressions.ExpressionException; import org.jfree.report.flow.ReportContext; /** * Tests, whether a certain export type is currently used. * * @author Thomas Morgner */ public class IsExportTypeExpression extends AbstractExpression { private String exportType; public IsExportTypeExpression() { } public String getExportType() { return exportType; } public void setExportType(final String exportType) { this.exportType = exportType; } /** * Return the current expression value.
The value depends (obviously) on * the expression implementation. * * @return the value of the function. */ public Object computeValue() throws ExpressionException { if (exportType == null) { return Boolean.FALSE; } final ReportContext reportContext = getRuntime().getReportContext(); if (reportContext.getExportDescriptor().startsWith(exportType)) { return Boolean.TRUE; } return Boolean.FALSE; } } pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/expressions/sys/IsNullExpression.java 0000644 0001750 0001750 00000004152 11305540676 032104 0 ustar rene rene /** * ======================================== * JFreeReport : a free Java report library * ======================================== * * Project Info: http://reporting.pentaho.org/ * * (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors. * * This library is free software; you can redistribute it and/or modify it under the terms * of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License along with this * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307, USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------ * $Id: IsNullExpression.java 10756 2009-12-02 15:58:24Z tmorgner $ * ------------ * (C) Copyright 2000-2005, by Object Refinery Limited. * (C) Copyright 2005-2007, by Pentaho Corporation. */ package org.jfree.report.expressions.sys; import org.jfree.report.DataSourceException; import org.jfree.report.expressions.AbstractExpression; /** * Creation-Date: 27.01.2006, 20:42:19 * * @author Thomas Morgner */ public class IsNullExpression extends AbstractExpression { private Object value; public IsNullExpression() { } public Object getValue() { return value; } public void setValue(final Object value) { this.value = value; } /** * Return the current expression value.
The value depends (obviously) on * the expression implementation. * * @return the value of the function. */ public Object computeValue() throws DataSourceException { if (value == null) { return Boolean.TRUE; } return Boolean.FALSE; } } ././@LongLink 0000000 0000000 0000000 00000000147 00000000000 011567 L ustar root root pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/expressions/sys/IsEndOfDataExpression.java pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/expressions/sys/IsEndOfDataExpression.ja0000644 0001750 0001750 00000004144 11305540676 032431 0 ustar rene rene /** * ======================================== * JFreeReport : a free Java report library * ======================================== * * Project Info: http://reporting.pentaho.org/ * * (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors. * * This library is free software; you can redistribute it and/or modify it under the terms * of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License along with this * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307, USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------ * $Id: IsEndOfDataExpression.java 10756 2009-12-02 15:58:24Z tmorgner $ * ------------ * (C) Copyright 2000-2005, by Object Refinery Limited. * (C) Copyright 2005-2007, by Pentaho Corporation. */ package org.jfree.report.expressions.sys; import org.jfree.report.DataSourceException; import org.jfree.report.ReportData; import org.jfree.report.expressions.AbstractExpression; /** * Creation-Date: 19.02.2006, 19:15:45 * * @author Thomas Morgner */ public class IsEndOfDataExpression extends AbstractExpression { public IsEndOfDataExpression() { } /** * Return the current expression value.
The value depends (obviously) on * the expression implementation. * * @return the value of the function. */ public Object computeValue() throws DataSourceException { ReportData data = getRuntime().getData(); synchronized(data) { if (data.isAdvanceable()) { return Boolean.TRUE; } return Boolean.FALSE; } } } pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/expressions/sys/IsEmptyExpression.java 0000644 0001750 0001750 00000004732 11305540676 032274 0 ustar rene rene /** * ======================================== * JFreeReport : a free Java report library * ======================================== * * Project Info: http://reporting.pentaho.org/ * * (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors. * * This library is free software; you can redistribute it and/or modify it under the terms * of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License along with this * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307, USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------ * $Id: IsEmptyExpression.java 10756 2009-12-02 15:58:24Z tmorgner $ * ------------ * (C) Copyright 2000-2005, by Object Refinery Limited. * (C) Copyright 2005-2007, by Pentaho Corporation. */ package org.jfree.report.expressions.sys; import org.jfree.report.DataSourceException; import org.jfree.report.expressions.AbstractExpression; /** * Creation-Date: 27.01.2006, 20:42:19 * * @author Thomas Morgner */ public class IsEmptyExpression extends AbstractExpression { private Object value; public IsEmptyExpression() { } public Object getValue() { return value; } public void setValue(final Object value) { this.value = value; } /** * Return the current expression value.
The value depends (obviously) on * the expression implementation. * * @return the value of the function. */ public Object computeValue() throws DataSourceException { if (value == null) { return Boolean.TRUE; } if (value instanceof String) { String s = (String) value; if (s.trim().length() == 0) { return Boolean.TRUE; } return Boolean.FALSE; } if (value instanceof Number) { Number n = (Number) value; if (n.intValue() == 0) { return Boolean.TRUE; } return Boolean.FALSE; } return Boolean.FALSE; } } ././@LongLink 0000000 0000000 0000000 00000000147 00000000000 011567 L ustar root root pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/expressions/sys/IsEmptyDataExpression.java pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/expressions/sys/IsEmptyDataExpression.ja0000644 0001750 0001750 00000004636 11305540676 032542 0 ustar rene rene /** * ======================================== * JFreeReport : a free Java report library * ======================================== * * Project Info: http://reporting.pentaho.org/ * * (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors. * * This library is free software; you can redistribute it and/or modify it under the terms * of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License along with this * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307, USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------ * $Id: IsEmptyDataExpression.java 10756 2009-12-02 15:58:24Z tmorgner $ * ------------ * (C) Copyright 2000-2005, by Object Refinery Limited. * (C) Copyright 2005-2007, by Pentaho Corporation. */ package org.jfree.report.expressions.sys; import org.jfree.report.DataSourceException; import org.jfree.report.ReportData; import org.jfree.report.expressions.AbstractExpression; import org.jfree.report.expressions.ExpressionRuntime; /** * Creation-Date: 31.01.2006, 18:55:09 * * @author Thomas Morgner */ public class IsEmptyDataExpression extends AbstractExpression { public IsEmptyDataExpression() { } /** * Return the current expression value.
The value depends (obviously) on * the expression implementation. * * @return the value of the function. */ public Object computeValue() throws DataSourceException { final ExpressionRuntime runtime = getRuntime(); if (runtime == null) { return null; } final ReportData data = runtime.getData(); if (data == null) { return null; } synchronized(data) { if (data.getCursorPosition() > 0) { return Boolean.FALSE; } if (data.isAdvanceable() == false) { return Boolean.TRUE; } return Boolean.FALSE; } } } pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/expressions/sys/GetValueExpression.java 0000644 0001750 0001750 00000004223 11305540676 032411 0 ustar rene rene /** * ======================================== * JFreeReport : a free Java report library * ======================================== * * Project Info: http://reporting.pentaho.org/ * * (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors. * * This library is free software; you can redistribute it and/or modify it under the terms * of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License along with this * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307, USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------ * $Id: GetValueExpression.java 10756 2009-12-02 15:58:24Z tmorgner $ * ------------ * (C) Copyright 2000-2005, by Object Refinery Limited. * (C) Copyright 2005-2007, by Pentaho Corporation. */ package org.jfree.report.expressions.sys; import org.jfree.report.DataSourceException; import org.jfree.report.expressions.AbstractExpression; /** * Creation-Date: 02.12.2006, 22:07:57 * * @author Thomas Morgner */ public class GetValueExpression extends AbstractExpression { private String field; public GetValueExpression() { } public GetValueExpression(final String field) { this.field = field; } public String getField() { return field; } public void setField(final String field) { this.field = field; } /** * Return the current expression value.
The value depends (obviously) on * the expression implementation. * * @return the value of the function. */ public Object computeValue() throws DataSourceException { return getDataRow().get(getField()); } } pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/expressions/sys/GroupByExpression.java 0000644 0001750 0001750 00000007050 11305540676 032265 0 ustar rene rene /** * ======================================== * JFreeReport : a free Java report library * ======================================== * * Project Info: http://reporting.pentaho.org/ * * (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors. * * This library is free software; you can redistribute it and/or modify it under the terms * of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License along with this * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307, USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------ * $Id: GroupByExpression.java 10756 2009-12-02 15:58:24Z tmorgner $ * ------------ * (C) Copyright 2000-2005, by Object Refinery Limited. * (C) Copyright 2005-2007, by Pentaho Corporation. */ package org.jfree.report.expressions.sys; import java.util.ArrayList; import java.util.Arrays; import org.jfree.report.DataFlags; import org.jfree.report.DataRow; import org.jfree.report.DataSourceException; import org.jfree.report.expressions.AbstractExpression; /** * Creation-Date: 08.10.2006, 16:28:37 * * @author Thomas Morgner */ public class GroupByExpression extends AbstractExpression { private ArrayList fields; private transient String[] fieldsCached; public GroupByExpression() { this.fields = new ArrayList(); } /** * Return the current expression value.
The value depends (obviously) on * the expression implementation. * * @return the value of the function. */ public Object computeValue() throws DataSourceException { final DataRow dr = getDataRow(); final String[] columns = getField(); for (int i = 0; i < columns.length; i++) { String column = columns[i]; DataFlags df = dr.getFlags(column); if (df == null) { // invalid column or invalid implementation ... continue; } if (df.isChanged()) { //Log.debug ("Field: " + df.getName() + " has changed to " + df.getValue()); return Boolean.TRUE; } } return Boolean.FALSE; } public void setField (final int index, final String field) { if (fields.size() == index) { fields.add(field); } else { fields.set(index, field); } fieldsCached = null; } public String getField (final int index) { return (String) fields.get(index); } public int getFieldCount () { return fields.size(); } public String[] getField () { if (fieldsCached == null) { fieldsCached = (String[]) fields.toArray(new String[fields.size()]); } return (String[]) fieldsCached.clone(); } public void setField (final String[] fields) { this.fields.clear(); this.fields.addAll(Arrays.asList(fields)); this.fieldsCached = (String[]) fields.clone(); } public Object clone() throws CloneNotSupportedException { GroupByExpression co = (GroupByExpression) super.clone(); co.fields = (ArrayList) fields.clone(); co.fieldsCached = fieldsCached; return co; } } pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/expressions/formula/ 0000755 0001750 0001750 00000000000 11305540676 026600 5 ustar rene rene pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/expressions/formula/sys/ 0000755 0001750 0001750 00000000000 11305540700 027402 5 ustar rene rene ././@LongLink 0000000 0000000 0000000 00000000161 00000000000 011563 L ustar root root pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/expressions/formula/sys/AttrFunctionDescription.java pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/expressions/formula/sys/AttrFunctionDesc0000644 0001750 0001750 00000006205 11305540676 032563 0 ustar rene rene /** * ======================================== * JFreeReport : a free Java report library * ======================================== * * Project Info: http://reporting.pentaho.org/ * * (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors. * * This library is free software; you can redistribute it and/or modify it under the terms * of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License along with this * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307, USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------ * $Id: AttrFunctionDescription.java 10756 2009-12-02 15:58:24Z tmorgner $ * ------------ * (C) Copyright 2000-2005, by Object Refinery Limited. * (C) Copyright 2005-2007, by Pentaho Corporation. */ package org.jfree.report.expressions.formula.sys; import org.pentaho.reporting.libraries.formula.function.AbstractFunctionDescription; import org.pentaho.reporting.libraries.formula.function.FunctionCategory; import org.pentaho.reporting.libraries.formula.function.userdefined.UserDefinedFunctionCategory; import org.pentaho.reporting.libraries.formula.typing.Type; import org.pentaho.reporting.libraries.formula.typing.coretypes.TextType; import org.pentaho.reporting.libraries.formula.typing.coretypes.AnyType; /** * Creation-Date: 29.11.2006, 18:04:18 * * @author Thomas Morgner */ public class AttrFunctionDescription extends AbstractFunctionDescription { public AttrFunctionDescription() { super("ATTR", "org.jfree.report.expressions.formula.sys.Attr-Function"); } public int getParameterCount() { return 1; } public boolean isInfiniteParameterCount() { return false; } public Type getParameterType(int position) { return TextType.TYPE; } public Type getValueType() { return AnyType.TYPE; } /** * Defines, whether the parameter at the given position is mandatory. A * mandatory parameter must be filled in, while optional parameters need not * to be filled in. * * @return */ public boolean isParameterMandatory(int position) { if (position == 0) { return true; } return false; } /** * Returns the default value for an optional parameter. If the value returned * here is null, then this either means, that the parameter is mandatory or * that the default value is computed by the expression itself. * * @param position * @return */ public Object getDefaultValue(int position) { return null; } public FunctionCategory getCategory() { return UserDefinedFunctionCategory.CATEGORY; } } ././@LongLink 0000000 0000000 0000000 00000000155 00000000000 011566 L ustar root root pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/expressions/formula/sys/Attr-Function.properties pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/expressions/formula/sys/Attr-Function.pr0000644 0001750 0001750 00000000376 11305540700 032450 0 ustar rene rene display-name=ATTR description=Queries an static attribute from the declaring parent. parameter.0.description=Attribute Namespace parameter.0.display-name=Attribute Namespace parameter.1.description=Attribute Name parameter.1.display-name=Attribute Name ././@LongLink 0000000 0000000 0000000 00000000146 00000000000 011566 L ustar root root pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/expressions/formula/sys/AttrFunction.java pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/expressions/formula/sys/AttrFunction.jav0000644 0001750 0001750 00000007315 11305540676 032546 0 ustar rene rene /** * ======================================== * JFreeReport : a free Java report library * ======================================== * * Project Info: http://reporting.pentaho.org/ * * (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors. * * This library is free software; you can redistribute it and/or modify it under the terms * of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License along with this * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307, USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------ * $Id: AttrFunction.java 10756 2009-12-02 15:58:24Z tmorgner $ * ------------ * (C) Copyright 2000-2005, by Object Refinery Limited. * (C) Copyright 2005-2007, by Pentaho Corporation. */ package org.jfree.report.expressions.formula.sys; import org.jfree.report.expressions.ReportFormulaContext; import org.jfree.report.structure.Element; import org.pentaho.reporting.libraries.formula.function.Function; import org.pentaho.reporting.libraries.formula.function.ParameterCallback; import org.pentaho.reporting.libraries.formula.lvalues.TypeValuePair; import org.pentaho.reporting.libraries.formula.FormulaContext; import org.pentaho.reporting.libraries.formula.LibFormulaErrorValue; import org.pentaho.reporting.libraries.formula.EvaluationException; import org.pentaho.reporting.libraries.formula.typing.coretypes.ErrorType; import org.pentaho.reporting.libraries.formula.typing.coretypes.AnyType; /** * Creation-Date: 24.11.2006, 13:02:41 * * @author Thomas Morgner */ public class AttrFunction implements Function { public AttrFunction() { } public String getCanonicalName() { return "ATTR"; } public TypeValuePair evaluate(FormulaContext context, ParameterCallback parameters) throws EvaluationException { // we expect strings and will check, whether the reference for theses // strings is dirty. if (context instanceof ReportFormulaContext == false) { return new TypeValuePair(ErrorType.TYPE, new LibFormulaErrorValue (LibFormulaErrorValue.ERROR_REFERENCE_NOT_RESOLVABLE)); } final ReportFormulaContext reportFormulaContext = (ReportFormulaContext) context; Object declaringElement = reportFormulaContext.getDeclaringElement(); if (declaringElement instanceof Element == false) { return new TypeValuePair(ErrorType.TYPE, new LibFormulaErrorValue (LibFormulaErrorValue.ERROR_REFERENCE_NOT_RESOLVABLE)); } final Element element = (Element) declaringElement; if (parameters.getParameterCount() == 1) { final String value = (String) parameters.getValue(0); return new TypeValuePair(AnyType.TYPE, element.getAttribute(value)); } else if (parameters.getParameterCount() == 2) { final String namespace = (String) parameters.getValue(0); final String attrName = (String) parameters.getValue(1); return new TypeValuePair(AnyType.TYPE, element.getAttribute(namespace, attrName)); } return new TypeValuePair(ErrorType.TYPE, new LibFormulaErrorValue (LibFormulaErrorValue.ERROR_INVALID_ARGUMENT)); } } pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/expressions/Function.java 0000644 0001750 0001750 00000004305 11305540700 027551 0 ustar rene rene /** * ======================================== * JFreeReport : a free Java report library * ======================================== * * Project Info: http://reporting.pentaho.org/ * * (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors. * * This library is free software; you can redistribute it and/or modify it under the terms * of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License along with this * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307, USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------ * $Id: Function.java 10756 2009-12-02 15:58:24Z tmorgner $ * ------------ * (C) Copyright 2000-2005, by Object Refinery Limited. * (C) Copyright 2005-2007, by Pentaho Corporation. */ package org.jfree.report.expressions; import org.jfree.report.DataSourceException; /** * The interface for report functions. A report function separates the business * logic from presentation of the result. *
* Since JFreeReport 0.9 functions are considered immutable. During the * advancement process, the function returns a new instance with the updated * state. * * @author Thomas Morgner */ public interface Function extends Expression { /** * When the advance method is called, the function is asked to perform the * next step of its computation. * * The original function must not be altered during that step (or more * correctly, calling advance on the original expression again must not return * a different result). * * @return a copy of the function containing the new state. */ public Function advance() throws DataSourceException; } pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/DataSourceException.java 0000644 0001750 0001750 00000004076 11305540676 027334 0 ustar rene rene /** * ======================================== * JFreeReport : a free Java report library * ======================================== * * Project Info: http://reporting.pentaho.org/ * * (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors. * * This library is free software; you can redistribute it and/or modify it under the terms * of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License along with this * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307, USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------ * $Id: DataSourceException.java 10756 2009-12-02 15:58:24Z tmorgner $ * ------------ * (C) Copyright 2000-2005, by Object Refinery Limited. * (C) Copyright 2005-2007, by Pentaho Corporation. */ package org.jfree.report; import org.pentaho.reporting.libraries.base.util.StackableException; /** * Creation-Date: 19.02.2006, 16:58:35 * * @author Thomas Morgner */ public class DataSourceException extends StackableException { /** Creates a StackableRuntimeException with no message and no parent. */ public DataSourceException() { } /** * Creates an exception. * * @param message the exception message. * @param ex the parent exception. */ public DataSourceException(final String message, final Exception ex) { super(message, ex); } /** * Creates an exception. * * @param message the exception message. */ public DataSourceException(final String message) { super(message); } } pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/util/ 0000755 0001750 0001750 00000000000 11305540700 023512 5 ustar rene rene pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/util/ScalingDrawable.java 0000644 0001750 0001750 00000006426 11305540700 027407 0 ustar rene rene /** * ======================================== * JFreeReport : a free Java report library * ======================================== * * Project Info: http://reporting.pentaho.org/ * * (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors. * * This library is free software; you can redistribute it and/or modify it under the terms * of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License along with this * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307, USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------ * $Id: ScalingDrawable.java 10756 2009-12-02 15:58:24Z tmorgner $ * ------------ * (C) Copyright 2000-2005, by Object Refinery Limited. * (C) Copyright 2005-2007, by Pentaho Corporation. */ package org.jfree.report.util; import java.awt.Graphics2D; import java.awt.geom.Rectangle2D; import org.pentaho.reporting.libraries.resourceloader.factory.drawable.DrawableWrapper; /** * Creation-Date: 20.01.2006, 19:46:10 * * @author Thomas Morgner */ public class ScalingDrawable extends DrawableWrapper { /** * The horizontal scale factor. */ private float scaleX; /** * The vertical scale factor. */ private float scaleY; /** * Default constructor. Initializes the scaling to 1. * @param drawable the drawable object */ public ScalingDrawable(final Object drawable) { super(drawable); scaleX = 1; scaleY = 1; } /** * Returns the vertical scale factor. * * @return the scale factor. */ public float getScaleY() { return scaleY; } /** * Defines the vertical scale factor. * * @param scaleY the scale factor. */ public void setScaleY(final float scaleY) { this.scaleY = scaleY; } /** * Returns the horizontal scale factor. * * @return the scale factor. */ public float getScaleX() { return scaleX; } /** * Defines the horizontal scale factor. * * @param scaleX the scale factor. */ public void setScaleX(final float scaleX) { this.scaleX = scaleX; } /** * Draws the object. * * @param g2 the graphics device. * @param area the area inside which the object should be drawn. */ public void draw(final Graphics2D g2, final Rectangle2D area) { final Object drawable = getBackend(); if (drawable == null) { return; } final Graphics2D derived = (Graphics2D) g2.create(); derived.scale(scaleX, scaleY); final Rectangle2D scaledArea = (Rectangle2D) area.clone(); scaledArea.setRect(scaledArea.getX() * scaleX, scaledArea.getY() * scaleY, scaledArea.getWidth() * scaleX, scaledArea.getHeight() * scaleY); super.draw(derived, scaledArea); derived.dispose(); } } pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/util/ScalingExtendedDrawable.java 0000644 0001750 0001750 00000006456 11305540676 031107 0 ustar rene rene /** * ======================================== * JFreeReport : a free Java report library * ======================================== * * Project Info: http://reporting.pentaho.org/ * * (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors. * * This library is free software; you can redistribute it and/or modify it under the terms * of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License along with this * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307, USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------ * $Id: ScalingExtendedDrawable.java 10756 2009-12-02 15:58:24Z tmorgner $ * ------------ * (C) Copyright 2000-2005, by Object Refinery Limited. * (C) Copyright 2005-2007, by Pentaho Corporation. */ package org.jfree.report.util; import java.awt.Graphics2D; import java.awt.geom.Rectangle2D; import org.pentaho.reporting.libraries.resourceloader.factory.drawable.DrawableWrapper; /** * Creation-Date: 20.01.2006, 19:46:10 * * @author Thomas Morgner */ public class ScalingExtendedDrawable extends DrawableWrapper { /** * The horizontal scale factor. */ private float scaleX; /** * The vertical scale factor. */ private float scaleY; /** * Default constructor. Initializes the scaling to 1. * @param drawable the drawable object */ public ScalingExtendedDrawable(final Object drawable) { super(drawable); scaleX = 1; scaleY = 1; } /** * Returns the vertical scale factor. * * @return the scale factor. */ public float getScaleY() { return scaleY; } /** * Defines the vertical scale factor. * * @param scaleY the scale factor. */ public void setScaleY(final float scaleY) { this.scaleY = scaleY; } /** * Returns the horizontal scale factor. * * @return the scale factor. */ public float getScaleX() { return scaleX; } /** * Defines the horizontal scale factor. * * @param scaleX the scale factor. */ public void setScaleX(final float scaleX) { this.scaleX = scaleX; } /** * Draws the object. * * @param g2 the graphics device. * @param area the area inside which the object should be drawn. */ public void draw(final Graphics2D g2, final Rectangle2D area) { final Object drawable = getBackend(); if (drawable == null) { return; } final Graphics2D derived = (Graphics2D) g2.create(); derived.scale(scaleX, scaleY); final Rectangle2D scaledArea = (Rectangle2D) area.clone(); scaledArea.setRect(scaledArea.getX() * scaleX, scaledArea.getY() * scaleY, scaledArea.getWidth() * scaleX, scaledArea.getHeight() * scaleY); super.draw(derived, scaledArea); derived.dispose(); } } pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/util/ReportParameters.java 0000644 0001750 0001750 00000012226 11305540676 027673 0 ustar rene rene /** * ======================================== * JFreeReport : a free Java report library * ======================================== * * Project Info: http://reporting.pentaho.org/ * * (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors. * * This library is free software; you can redistribute it and/or modify it under the terms * of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License along with this * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307, USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------ * $Id: ReportParameters.java 10756 2009-12-02 15:58:24Z tmorgner $ * ------------ * (C) Copyright 2000-2005, by Object Refinery Limited. * (C) Copyright 2005-2007, by Pentaho Corporation. */ package org.jfree.report.util; import java.io.Serializable; import java.util.HashMap; /** * The report parameters collection is a map with string keys. The parameters * can be used in a query and will appear as part of the datarow. * * @author Thomas Morgner */ public final class ReportParameters implements Serializable, Cloneable { /** * Storage for the properties. */ private HashMap properties; /** * Copy constructor. * * @param props an existing ReportProperties instance. */ public ReportParameters (final ReportParameters props) { this.properties = new HashMap(props.properties); } /** * Default constructor. */ public ReportParameters () { this.properties = new HashMap(); } /** * Adds a property to this properties collection. If a property with the given name * exist, the property will be replaced with the new value. If the value is null, the * property will be removed. * * @param key the property key. * @param value the property value. */ public void put (final String key, final Object value) { if (key == null) { throw new NullPointerException ("ReportProperties.put (..): Parameter 'key' must not be null"); } if (value == null) { this.properties.remove(key); } else { this.properties.put(key, value); } } /** * Retrieves the value stored for a key in this properties collection. * * @param key the property key. * @return The stored value, ornull
if the key does not exist in this
* collection.
*/
public Object get (final String key)
{
if (key == null)
{
throw new NullPointerException
("ReportProperties.get (..): Parameter 'key' must not be null");
}
return this.properties.get(key);
}
/**
* Retrieves the value stored for a key in this properties collection, and returning the
* default value if the key was not stored in this properties collection.
*
* @param key the property key.
* @param defaultValue the default value to be returned when the key is not stored in
* this properties collection.
* @return The stored value, or the default value if the key does not exist in this
* collection.
*/
public Object get (final String key, final Object defaultValue)
{
if (key == null)
{
throw new NullPointerException
("ReportProperties.get (..): Parameter 'key' must not be null");
}
final Object o = this.properties.get(key);
if (o == null)
{
return defaultValue;
}
return o;
}
/**
* Returns all property keys as array.
*
* @return an enumeration of the property keys.
*/
public String[] keys ()
{
return (String[]) this.properties.keySet().toArray(new String[properties.size()]);
}
/**
* Removes all properties stored in this collection.
*/
public void clear ()
{
this.properties.clear();
}
/**
* Checks whether the given key is stored in this collection of ReportProperties.
*
* @param key the property key.
* @return true, if the given key is known.
*/
public boolean containsKey (final String key)
{
if (key == null)
{
throw new NullPointerException
("ReportProperties.containsKey (..): Parameter key must not be null");
}
return this.properties.containsKey(key);
}
/**
* Clones the properties.
*
* @return a copy of this ReportProperties object.
*
* @throws CloneNotSupportedException this should never happen.
*/
public Object clone ()
throws CloneNotSupportedException
{
final ReportParameters p = (ReportParameters) super.clone();
p.properties = (HashMap) this.properties.clone();
return p;
}
public int size()
{
return properties.size();
}
}
pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/util/beans/ 0000755 0001750 0001750 00000000000 11305540700 024602 5 ustar rene rene pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/util/beans/BeanPropertyLookupParser.java0000644 0001750 0001750 00000005656 11305540676 032456 0 ustar rene rene /**
* ========================================
* JFreeReport : a free Java report library
* ========================================
*
* Project Info: http://reporting.pentaho.org/
*
* (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors.
*
* This library is free software; you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation;
* either version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* ------------
* $Id: BeanPropertyLookupParser.java 10756 2009-12-02 15:58:24Z tmorgner $
* ------------
* (C) Copyright 2000-2005, by Object Refinery Limited.
* (C) Copyright 2005-2007, by Pentaho Corporation.
*/
package org.jfree.report.util.beans;
import org.jfree.report.util.CSVTokenizer;
import org.jfree.report.util.PropertyLookupParser;
public abstract class BeanPropertyLookupParser extends PropertyLookupParser
{
public BeanPropertyLookupParser ()
{
}
/**
*
* @param name
* @return
*/
protected abstract Object performInitialLookup (String name);
protected String lookupVariable (final String entity)
{
// first, split the entity into separate strings (separator is '.').
final CSVTokenizer tokenizer = new CSVTokenizer(entity, ".");
if (tokenizer.hasMoreTokens())
{
final String name = tokenizer.nextToken();
final Object base = performInitialLookup(name);
try
{
if (tokenizer.hasMoreTokens())
{
return continueLookupVariable(tokenizer, base);
}
else
{
return ConverterRegistry.toAttributeValue(base);
}
}
catch (BeanException e)
{
return entity;
}
}
return entity;
}
private static String continueLookupVariable (final CSVTokenizer tokenizer,
final Object parent)
throws BeanException
{
if (tokenizer.hasMoreTokens())
{
final String name = tokenizer.nextToken();
final Object base = ConverterRegistry.toPropertyValue(name, parent.getClass());
if (tokenizer.hasMoreTokens())
{
return continueLookupVariable(tokenizer, base);
}
else
{
return ConverterRegistry.toAttributeValue(base);
}
}
return null;
}
}
pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/util/beans/FloatValueConverter.java 0000644 0001750 0001750 00000004337 11305540676 031422 0 ustar rene rene /**
* ========================================
* JFreeReport : a free Java report library
* ========================================
*
* Project Info: http://reporting.pentaho.org/
*
* (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors.
*
* This library is free software; you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation;
* either version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* ------------
* $Id: FloatValueConverter.java 10756 2009-12-02 15:58:24Z tmorgner $
* ------------
* (C) Copyright 2000-2005, by Object Refinery Limited.
* (C) Copyright 2005-2007, by Pentaho Corporation.
*/
package org.jfree.report.util.beans;
/**
* A class that handles the conversion of {@link Float} attributes to and from their
* {@link String} representation.
*
* @author Thomas Morgner
*/
public class FloatValueConverter implements ValueConverter
{
/**
* Creates a new value converter.
*/
public FloatValueConverter ()
{
super();
}
/**
* Converts the attribute to a string.
*
* @param o the attribute ({@link Float} expected).
* @return A string representing the {@link Float} value.
*/
public String toAttributeValue (final Object o)
{
if (o instanceof Float)
{
return o.toString();
}
throw new ClassCastException("Give me a real type.");
}
/**
* Converts a string to a {@link Float}.
*
* @param s the string.
* @return a {@link Float}.
*/
public Object toPropertyValue (final String s)
{
return new Float(s);
}
}
pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/util/beans/TimeZoneValueConverter.java 0000644 0001750 0001750 00000004270 11305540676 032103 0 ustar rene rene /**
* ========================================
* JFreeReport : a free Java report library
* ========================================
*
* Project Info: http://reporting.pentaho.org/
*
* (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors.
*
* This library is free software; you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation;
* either version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* ------------
* $Id: TimeZoneValueConverter.java 10756 2009-12-02 15:58:24Z tmorgner $
* ------------
* (C) Copyright 2000-2005, by Object Refinery Limited.
* (C) Copyright 2005-2007, by Pentaho Corporation.
*/
package org.jfree.report.util.beans;
import java.util.TimeZone;
/**
* Creation-Date: 24.01.2006, 19:19:03
*
* @author Thomas Morgner
*/
public class TimeZoneValueConverter implements ValueConverter
{
public TimeZoneValueConverter()
{
}
/**
* Converts an object to an attribute value.
*
* @param o the object.
* @return the attribute value.
* @throws BeanException if there was an error during the conversion.
*/
public String toAttributeValue(Object o) throws BeanException
{
TimeZone tz = (TimeZone) o;
return tz.getID();
}
/**
* Converts a string to a property value.
*
* @param s the string.
* @return a property value.
* @throws BeanException if there was an error during the conversion.
*/
public Object toPropertyValue(String s) throws BeanException
{
return TimeZone.getTimeZone(s);
}
}
pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/util/beans/GenericValueConverter.java 0000644 0001750 0001750 00000006602 11305540676 031726 0 ustar rene rene /**
* ========================================
* JFreeReport : a free Java report library
* ========================================
*
* Project Info: http://reporting.pentaho.org/
*
* (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors.
*
* This library is free software; you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation;
* either version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* ------------
* $Id: GenericValueConverter.java 10756 2009-12-02 15:58:24Z tmorgner $
* ------------
* (C) Copyright 2000-2005, by Object Refinery Limited.
* (C) Copyright 2005-2007, by Pentaho Corporation.
*/
package org.jfree.report.util.beans;
import java.beans.IntrospectionException;
import java.beans.PropertyDescriptor;
import java.beans.PropertyEditor;
/**
* A class that handles the conversion of {@link Integer} attributes to and from their
* {@link String} representation.
*
* @author Thomas Morgner
*/
public class GenericValueConverter implements ValueConverter
{
private PropertyDescriptor propertyDescriptor;
private PropertyEditor propertyEditor;
/**
* Creates a new value converter.
*/
public GenericValueConverter (final PropertyDescriptor pd)
throws IntrospectionException
{
if (pd == null)
{
throw new NullPointerException("PropertyDescriptor must not be null.");
}
if (pd.getPropertyEditorClass() == null)
{
throw new IntrospectionException("Property has no editor.");
}
this.propertyDescriptor = pd;
this.propertyEditor = createPropertyEditor(pd);
}
private PropertyEditor createPropertyEditor (final PropertyDescriptor pi)
throws IntrospectionException
{
final Class c = pi.getPropertyEditorClass();
try
{
return (PropertyEditor) c.newInstance();
}
catch (Exception e)
{
throw new IntrospectionException("Unable to create PropertyEditor.");
}
}
/**
* Converts the attribute to a string.
*
* @param o the attribute ({@link Integer} expected).
* @return A string representing the {@link Integer} value.
* @throws BeanException if there was an error during the conversion.
*/
public String toAttributeValue (final Object o) throws BeanException
{
if (BeanUtility.getPropertyType(propertyDescriptor).isInstance(o) == false)
{
throw new ClassCastException("Give me a real type.");
}
propertyEditor.setValue(o);
return propertyEditor.getAsText();
}
/**
* Converts a string to a {@link Integer}.
*
* @param s the string.
* @return a {@link Integer}.
*/
public Object toPropertyValue (final String s)
{
propertyEditor.setAsText(s);
return propertyEditor.getValue();
}
}
pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/util/beans/CharacterValueConverter.java 0000644 0001750 0001750 00000004556 11305540676 032254 0 ustar rene rene /**
* ========================================
* JFreeReport : a free Java report library
* ========================================
*
* Project Info: http://reporting.pentaho.org/
*
* (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors.
*
* This library is free software; you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation;
* either version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* ------------
* $Id: CharacterValueConverter.java 10756 2009-12-02 15:58:24Z tmorgner $
* ------------
* (C) Copyright 2000-2005, by Object Refinery Limited.
* (C) Copyright 2005-2007, by Pentaho Corporation.
*/
package org.jfree.report.util.beans;
/**
* A class that handles the conversion of {@link Character} attributes to and from their
* {@link String} representation.
*
* @author Thomas Morgner
*/
public class CharacterValueConverter implements ValueConverter
{
/**
* Creates a new value converter.
*/
public CharacterValueConverter ()
{
super();
}
/**
* Converts the attribute to a string.
*
* @param o the attribute ({@link Character} expected).
* @return A string representing the {@link Character} value.
*/
public String toAttributeValue (final Object o)
{
if (o instanceof Character)
{
return o.toString();
}
throw new ClassCastException("Give me a real type.");
}
/**
* Converts a string to a {@link Character}.
*
* @param s the string.
* @return a {@link Character}.
*/
public Object toPropertyValue (final String s)
{
if (s.length() == 0)
{
throw new RuntimeException("Ugly, no char set!");
}
return new Character(s.charAt(0));
}
}
pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/util/beans/BigDecimalValueConverter.java0000644 0001750 0001750 00000004454 11305540700 032321 0 ustar rene rene /**
* ========================================
* JFreeReport : a free Java report library
* ========================================
*
* Project Info: http://reporting.pentaho.org/
*
* (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors.
*
* This library is free software; you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation;
* either version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* ------------
* $Id: BigDecimalValueConverter.java 10756 2009-12-02 15:58:24Z tmorgner $
* ------------
* (C) Copyright 2000-2005, by Object Refinery Limited.
* (C) Copyright 2005-2007, by Pentaho Corporation.
*/
package org.jfree.report.util.beans;
import java.math.BigDecimal;
/**
* A class that handles the conversion of {@link BigDecimal} attributes to and from their
* {@link String} representation.
*
* @author Thomas Morgner
*/
public class BigDecimalValueConverter implements ValueConverter
{
/**
* Creates a new value converter.
*/
public BigDecimalValueConverter ()
{
super();
}
/**
* Converts the attribute to a string.
*
* @param o the attribute ({@link BigDecimal} expected).
* @return A string representing the {@link BigDecimal} value.
*/
public String toAttributeValue (final Object o)
{
if (o instanceof Integer)
{
return o.toString();
}
throw new ClassCastException("Give me a real type.");
}
/**
* Converts a string to a {@link BigDecimal}.
*
* @param s the string.
* @return a {@link BigDecimal}.
*/
public Object toPropertyValue (final String s)
{
return new BigDecimal(s);
}
}
pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/util/beans/BeanException.java 0000644 0001750 0001750 00000004161 11305540676 030207 0 ustar rene rene /**
* ========================================
* JFreeReport : a free Java report library
* ========================================
*
* Project Info: http://reporting.pentaho.org/
*
* (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors.
*
* This library is free software; you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation;
* either version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* ------------
* $Id: BeanException.java 10756 2009-12-02 15:58:24Z tmorgner $
* ------------
* (C) Copyright 2000-2005, by Object Refinery Limited.
* (C) Copyright 2005-2007, by Pentaho Corporation.
*/
package org.jfree.report.util.beans;
import org.pentaho.reporting.libraries.base.util.StackableException;
/**
* The BeanException class signals errors when setting or reading bean
* properties.
*
* @author Thomas Morgner
*/
public class BeanException extends StackableException
{
/**
* DefaultConstructor.
*/
public BeanException ()
{
}
/**
* Creates a new BeanException with the given message and parent exception.
*
* @param message the message text
* @param ex the parent exception
*/
public BeanException (final String message, final Exception ex)
{
super(message, ex);
}
/**
* Creates a new BeanException with the given message.
*
* @param message the message.
*/
public BeanException (final String message)
{
super(message);
}
}
pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/util/beans/BigIntegerValueConverter.java0000644 0001750 0001750 00000004536 11305540676 032375 0 ustar rene rene /**
* ========================================
* JFreeReport : a free Java report library
* ========================================
*
* Project Info: http://reporting.pentaho.org/
*
* (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors.
*
* This library is free software; you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation;
* either version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* ------------
* $Id: BigIntegerValueConverter.java 10756 2009-12-02 15:58:24Z tmorgner $
* ------------
* (C) Copyright 2000-2005, by Object Refinery Limited.
* (C) Copyright 2005-2007, by Pentaho Corporation.
*/
package org.jfree.report.util.beans;
import java.math.BigInteger;
/**
* A class that handles the conversion of {@link java.math.BigInteger} attributes to and
* from their {@link String} representation.
*
* @author Thomas Morgner
*/
public class BigIntegerValueConverter implements ValueConverter
{
/**
* Creates a new value converter.
*/
public BigIntegerValueConverter ()
{
super();
}
/**
* Converts the attribute to a string.
*
* @param o the attribute ({@link java.math.BigInteger} expected).
* @return A string representing the {@link java.math.BigInteger} value.
*/
public String toAttributeValue (final Object o)
{
if (o instanceof Integer)
{
return o.toString();
}
throw new ClassCastException("Give me a real type.");
}
/**
* Converts a string to a {@link java.math.BigInteger}.
*
* @param s the string.
* @return a {@link java.math.BigInteger}.
*/
public Object toPropertyValue (final String s)
{
return new BigInteger(s);
}
}
pentaho-reporting-flow-engine-0.9.4/source/org/jfree/report/util/beans/package.html 0000644 0001750 0001750 00000000143 11305540676 027075 0 ustar rene rene