Coverage details for net.sourceforge.demetrix.rio.Excel2Maxima

LineHitsSource
1 /*******************************************************************************
2  * Demetrix process modelling system
3  *
4  * Copyright (c) 2003, 2004 Dimitri A. Pissarenko
5  *
6  * This file is part of Demetrix.
7  *
8  * Demetrix is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2.1 of the License, or
11  * (at your option) any later version.
12  *
13  * Demetrix is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with Demetrix; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21  *
22  * For further information you may
23  *
24  * - send an e-mail in Russian, German or English to dimitri.pissarenko@gmx.net
25  * - look at http://sourceforge.net/projects/demetrix/
26  * - look at http://demetrix.sourceforge.net/
27  * - look at http://members.inode.at/d.pissarenko/
28  *
29  *****************************************************************************/
30 /*
31  * Created on 24.01.2004
32  */
33 package net.sourceforge.demetrix.rio;
34  
35 import java.io.File;
36 import java.io.FileInputStream;
37 import java.io.IOException;
38  
39 import org.apache.log4j.Logger;
40 import org.apache.poi.hssf.usermodel.HSSFSheet;
41 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
42  
43 import net.sourceforge.demetrix.Demetrix;
44 import net.sourceforge.demetrix.util.LoggerSetupHelper;
45  
46 /**
47  * @author Dimitri Pissarenko
48  *
49  */
500public class Excel2Maxima {
51     public final static int INPUT_FILE_POSITION=0;
52     public final static int OUTPUT_FILE_POSITION=1;
53     
54     public static boolean ersatzMain(String[] args)
55     {
564        Logger logger=null;
574        File inputFile=null;
584        LoggerSetupHelper.setupLogger();
594        HSSFSheet sheet=null;
604        FileInputStream fileInputStream=null;
61  
621        logger=Logger.getLogger(Excel2Maxima.class);
63         
644        if ((args==null) || (args.length!=1))
65         {
66             logger.error("usage: java -jar excel2Maxima-" + Demetrix.PRODUCT_VERSION + ".jar inputFile");
674            return false;
68         }
690        inputFile=new File(args[INPUT_FILE_POSITION]);
700        if (!inputFile.getName().toLowerCase().endsWith(".xls"))
71         {
72             logger.error("input file \"" + inputFile + "\" is not a Microsoft(R) Excel(tm) file");
730            return false;
74             
75         }
760        if (!inputFile.canRead())
77         {
78             logger.error("can't read input file \"" + inputFile + "\"");
790            return false;
80         }
81  
82         try
83         {
840            fileInputStream=new FileInputStream(inputFile);
850            sheet=(new HSSFWorkbook(fileInputStream)).getSheetAt(0);
86         
870            System.out.print((new Excel2MaximaConverter()).convertToMaxima(sheet));
88                                     
89         }
900        catch (IOException exception)
91         {
92             logger.error("can't read input file \"" + inputFile + "\"", exception);
930            return false;
940        }
950        return true;
96     }
97         
98     public static void main(String[] args) {
990        boolean runSuccessful=false;
1000        runSuccessful=ersatzMain(args);
1010        if (runSuccessful)
102         {
1030            System.exit(0);
104         }
105         else
106         {
1070            System.exit(1);
108         }
109         
1100    }
111 }

this report was generated by version 1.0.5 of jcoverage.
visit www.jcoverage.com for updates.

copyright © 2003, jcoverage ltd. all rights reserved.
Java is a trademark of Sun Microsystems, Inc. in the United States and other countries.