| Line | Hits | Source |
|---|---|---|
| 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 | */ | |
| 50 | 0 | public 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 | { | |
| 56 | 4 | Logger logger=null; |
| 57 | 4 | File inputFile=null; |
| 58 | 4 | LoggerSetupHelper.setupLogger(); |
| 59 | 4 | HSSFSheet sheet=null; |
| 60 | 4 | FileInputStream fileInputStream=null; |
| 61 | ||
| 62 | 1 | logger=Logger.getLogger(Excel2Maxima.class); |
| 63 | ||
| 64 | 4 | if ((args==null) || (args.length!=1)) |
| 65 | { | |
| 66 | logger.error("usage: java -jar excel2Maxima-" + Demetrix.PRODUCT_VERSION + ".jar inputFile"); | |
| 67 | 4 | return false; |
| 68 | } | |
| 69 | 0 | inputFile=new File(args[INPUT_FILE_POSITION]); |
| 70 | 0 | if (!inputFile.getName().toLowerCase().endsWith(".xls")) |
| 71 | { | |
| 72 | logger.error("input file \"" + inputFile + "\" is not a Microsoft(R) Excel(tm) file"); | |
| 73 | 0 | return false; |
| 74 | ||
| 75 | } | |
| 76 | 0 | if (!inputFile.canRead()) |
| 77 | { | |
| 78 | logger.error("can't read input file \"" + inputFile + "\""); | |
| 79 | 0 | return false; |
| 80 | } | |
| 81 | ||
| 82 | try | |
| 83 | { | |
| 84 | 0 | fileInputStream=new FileInputStream(inputFile); |
| 85 | 0 | sheet=(new HSSFWorkbook(fileInputStream)).getSheetAt(0); |
| 86 | ||
| 87 | 0 | System.out.print((new Excel2MaximaConverter()).convertToMaxima(sheet)); |
| 88 | ||
| 89 | } | |
| 90 | 0 | catch (IOException exception) |
| 91 | { | |
| 92 | logger.error("can't read input file \"" + inputFile + "\"", exception); | |
| 93 | 0 | return false; |
| 94 | 0 | } |
| 95 | 0 | return true; |
| 96 | } | |
| 97 | ||
| 98 | public static void main(String[] args) { | |
| 99 | 0 | boolean runSuccessful=false; |
| 100 | 0 | runSuccessful=ersatzMain(args); |
| 101 | 0 | if (runSuccessful) |
| 102 | { | |
| 103 | 0 | System.exit(0); |
| 104 | } | |
| 105 | else | |
| 106 | { | |
| 107 | 0 | System.exit(1); |
| 108 | } | |
| 109 | ||
| 110 | 0 | } |
| 111 | } |
|
this report was generated by version 1.0.5 of jcoverage. |
copyright © 2003, jcoverage ltd. all rights reserved. |