Package

Source Code of BeanShellApp

/*
* ============================================================================
*                   GNU Lesser General Public License
* ============================================================================
*
* JasperReports - Free Java report-generating library.
* Copyright (C) 2001-2005 Teodor Danciu teodord@users.sourceforge.net
*
* 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.
*
* Teodor Danciu
* 173, Calea Calarasilor, Bl. 42, Sc. 1, Ap. 18
* Postal code 030615, Sector 3
* Bucharest, ROMANIA
* Email: teodord@users.sourceforge.net
*/

import java.io.File;

import net.sf.jasperreports.engine.JREmptyDataSource;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperExportManager;
import net.sf.jasperreports.engine.JasperFillManager;


/**
* @author Teodor Danciu (teodord@users.sourceforge.net)
* @version $Id: BeanShellApp.java,v 1.1 2005/05/23 08:26:24 sherifo Exp $
*/
public class BeanShellApp
{


  /**
   *
   */
  private static final String TASK_FILL = "fill";
  private static final String TASK_PDF = "pdf";
 
 
  /**
   *
   */
  public static void main(String[] args)
  {
    String fileName = null;
    String taskName = null;

    if(args.length == 0)
    {
      usage();
      return;
    }
       
    int k = 0;
    while ( args.length > k )
    {
      if ( args[k].startsWith("-T") )
        taskName = args[k].substring(2);
      if ( args[k].startsWith("-F") )
        fileName = args[k].substring(2);
     
      k++; 
    }

    try
    {
      long start = System.currentTimeMillis();
      if (TASK_FILL.equals(taskName))
      {
        JasperFillManager.fillReportToFile(fileName, null, new JREmptyDataSource());
        System.err.println("Filling time : " + (System.currentTimeMillis() - start));
        System.exit(0);
      }
      else if (TASK_PDF.equals(taskName))
      {
        JasperExportManager.exportReportToPdfFile(fileName);
        System.err.println("PDF creation time : " + (System.currentTimeMillis() - start));
        System.exit(0);
      }
      else
      {
        usage();
        System.exit(0);
      }
    }
    catch (JRException e)
    {
      e.printStackTrace();
      System.exit(1);
    }
    catch (Exception e)
    {
      e.printStackTrace();
      System.exit(1);
    }
  }


  /**
   *
   */
  private static void usage()
  {
    System.out.println( "BeanShellApp usage:" );
    System.out.println( "\tjava BeanShellApp -Ttask -Ffile" );
    System.out.println( "\tTasks : fill | pdf" );
  }


}
TOP

Related Classes of BeanShellApp

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.