java/cewolf-1.0/src/main/java/de/laures/cewolf/DatasetProducer.java
changeset 1 639991d0808a
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/java/cewolf-1.0/src/main/java/de/laures/cewolf/DatasetProducer.java	Sat Feb 28 21:31:02 2009 +0100
     1.3 @@ -0,0 +1,87 @@
     1.4 +/* ================================================================
     1.5 + * Cewolf : Chart enabling Web Objects Framework
     1.6 + * ================================================================
     1.7 + *
     1.8 + * Project Info:  http://cewolf.sourceforge.net
     1.9 + * Project Lead:  Guido Laures (guido@laures.de);
    1.10 + *
    1.11 + * (C) Copyright 2002, by Guido Laures
    1.12 + *
    1.13 + * This library is free software; you can redistribute it and/or modify it under the terms
    1.14 + * of the GNU Lesser General Public License as published by the Free Software Foundation;
    1.15 + * either version 2.1 of the License, or (at your option) any later version.
    1.16 + *
    1.17 + * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
    1.18 + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    1.19 + * See the GNU Lesser General Public License for more details.
    1.20 + *
    1.21 + * You should have received a copy of the GNU Lesser General Public License along with this
    1.22 + * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
    1.23 + * Boston, MA 02111-1307, USA.
    1.24 + */
    1.25 +
    1.26 +package de.laures.cewolf;
    1.27 +
    1.28 +import java.io.Serializable;
    1.29 +import java.util.Date;
    1.30 +import java.util.Map;
    1.31 +
    1.32 +/**
    1.33 + * Produces a {@link org.jfree.data.Dataset} which will be rendered 
    1.34 + * as a chart 	afterwards.
    1.35 + * @see org.jfree.data.Dataset
    1.36 + * @author  Guido Laures
    1.37 + * @since 0.1
    1.38 + */
    1.39 +public interface DatasetProducer extends Serializable {
    1.40 +    
    1.41 +    /**
    1.42 +     * By default the the name of the JSP attribute 
    1.43 +     * holding the producer instance is passed to the 
    1.44 +     * produceDataset method as a prameter.
    1.45 +     */
    1.46 +    public static final String PRODUCER_ATTRIBUTE_NAME = "de.laures.cewolf.DatasetProducer.id";
    1.47 +	
    1.48 +    /**
    1.49 +     * Produces a {@link org.jfree.data.Dataset} object.
    1.50 +     * @param params additional params for the dataset production. All elements
    1.51 +     * of this HashMap are of type <code>java.io.Serializable</code>. This is
    1.52 +     * necessary to ensure the the serialization of the dataset producer into
    1.53 +     * the http session. To provide a producer with additional production
    1.54 +     * parameters the &lt;param&gt; tag is used (see tag library documentation).
    1.55 +     * It is recommended to synchronize implementations of this method to avoid
    1.56 +     * concurrency problems.
    1.57 +     * @return an object of type <code>org.jfree.data.Dataset</code>.
    1.58 +     * @throws DatasetProduceException if an error occured during production
    1.59 +     * @since 0.2
    1.60 +     */
    1.61 +    Object produceDataset(Map params) throws DatasetProduceException;
    1.62 +	
    1.63 +	/**
    1.64 +	 * This method is called by the Cewolf framework to check if a formerly
    1.65 +	 * produced data can be reused. If the data which had already been used
    1.66 +	 * for chart rendering is still valid this method should return <code>true</code>.
    1.67 +	 * If possible the Cewolf framework will try to reuse the rendered chart
    1.68 +	 * image. If this is not possible because of some circumstances (e.g. the chart
    1.69 +	 * had been removed from the image cache) the produceDataset method is called afterwards.
    1.70 +	 * Therefore there is no guarantee that the dataset production is always 
    1.71 +	 * avoided if this method returns <code>true</true>.
    1.72 +	 * @param params the production parameters of the already produced data
    1.73 +	 * @param since the point in time when the already produced data had been produced
    1.74 +	 * @return <code>true</code> if the data which had been produced with the 
    1.75 +	 * passed in parameters has expired since its creation, <code>false</code> 
    1.76 +	 * otherwise
    1.77 +	 * @since 0.9
    1.78 +	 */
    1.79 +	boolean hasExpired(Map params, Date since);
    1.80 +	
    1.81 +	/**
    1.82 +	 * Tis method returns a unique ID for a DatasetProducer from this class.
    1.83 +	 * Producers with the same ID are supposed to produce the same data when
    1.84 +	 * called with the same paramters.
    1.85 +	 * @return the unique ID for instances of this poducer class
    1.86 +	 * @since 0.9
    1.87 +	 */
    1.88 +	String getProducerId();
    1.89 +
    1.90 +}