Logo
Distributed Genetic Programming Framework
print print

File org.jfree.chart.servlet.ChartDeleter.java

Here you can find all the information about the file org.jfree.chart.servlet.ChartDeleter.java. You may explore it here or download it onto your local disk.
/* ===========================================================
 * JFreeChart : a free chart library for the Java(tm) platform
 * ===========================================================
 *
 * (C) Copyright 2000-2005, by Object Refinery Limited and Contributors.
 *
 * Project Info:  http://www.jfree.org/jfreechart/index.html
 *
 * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 
 * USA.  
 *
 * [Java is a trademark or registered trademark of Sun Microsystems, Inc. 
 * in the United States and other countries.]
 *
 * -----------------
 * ChartDeleter.java
 * -----------------
  * (C) Copyright 2002-2004, by Richard Atkinson and Contributors.
 *
 * Original Author:  Richard Atkinson;
 * Contributor(s):   -;
 *
 * $Id: ChartDeleter.java,v 1.2.2.1 2005/10/25 20:58:06 mungady Exp $
 *
 * Changes
 * -------
 * 19-Aug-2002 : Version 1;
 * 17-Oct-2002 : Fixed errors reported by Checkstyle (DG);
 *
 */

package org.jfree.chart.servlet;

import java.io.File;
import java.util.Iterator;
import java.util.List;

import javax.servlet.http.HttpSessionBindingEvent;
import javax.servlet.http.HttpSessionBindingListener;

/**
 * Used for deleting charts from the temporary directory when the users session
 * expires.
 *
 * @author Richard Atkinson
 */

public class ChartDeleter implements HttpSessionBindingListener {

    /** The chart names. */
    private List chartNames = new java.util.ArrayList();

    /**
     * Blank constructor.
     */

    public ChartDeleter() {
        super();
    }

    /**
     * Add a chart to be deleted when the session expires
     *
     * @param filename  the name of the chart in the temporary directory to be 
     *                  deleted.
     */

    public void addChart(String filename) {
        this.chartNames.add(filename);
    }

    /**
     * Checks to see if a chart is in the list of charts to be deleted
     *
     * @param filename  the name of the chart in the temporary directory.
     *
     * @return A boolean value indicating whether the chart is present in the 
     *         list.
     */

    public boolean isChartAvailable(String filename) {
        return (this.chartNames.contains(filename));
    }

    /**
     * Binding this object to the session has no additional effects.
     *
     * @param event  the session bind event.
     */

    public void valueBound(HttpSessionBindingEvent event) {
        return;
    }

    /**
     * When this object is unbound from the session (including upon session
     * expiry) the files that have been added to the ArrayList are iterated
     * and deleted.
     *
     * @param event  the session unbind event.
     */

    public void valueUnbound(HttpSessionBindingEvent event) {

        Iterator iter = this.chartNames.listIterator();
        while (iter.hasNext()) {
            String filename = (String) iter.next();
            File file = new File(
                System.getProperty("java.io.tmpdir"), filename
            );
            if (file.exists()) {
                file.delete();
            }
        }
        return;

    }

}

File Information:

file name:ChartDeleter.java
package:org.jfree.chart.servlet
qualified name:org.jfree.chart.servlet.ChartDeleter.java
file type:Java Source File
download location:download http://dgpf.sourceforge.net/source/org/jfree/chart/servlet/ChartDeleter.java
size:3.789 KB (3880 B)
uploaded: 2015-07-22 04:11:05 GMT+0000
last update: 2006-08-25 12:16:44 GMT+0000
last access: 2017-11-23 07:28:30 GMT+0000

statistics online since 2006-01-02.   RSS Feed
Contact us by sending an email to tweise@gmx.de to receive further information, to report errors, or to join our project.
All content on this site (http://dgpf.sourceforge.net/) is LGPL-licensed.
http://dgpf.sourceforge.net/scripts/source/source.php last modified at 2015-07-22 04:10:53 GMT+0000 served at 2017-11-23 07:28:30 GMT+0000.
Valid CSS Valid XHTML 1.1
Valid RSS SourceForge.net Logo