|
From: <de...@us...> - 2004-01-06 14:11:51
|
Update of /cvsroot/babeldoc/babeldoc/modules/conversion/src/com/babeldoc/conversion/excel
In directory sc8-pr-cvs1:/tmp/cvs-serv1406/modules/conversion/src/com/babeldoc/conversion/excel
Modified Files:
Tag: V1-2
ExcelConversionClient.java
Log Message:
xls2xml conversion client has two new options:
-o --output - output file name
-l --locale - locale that should be used for formating numbers
Index: ExcelConversionClient.java
===================================================================
RCS file: /cvsroot/babeldoc/babeldoc/modules/conversion/src/com/babeldoc/conversion/excel/ExcelConversionClient.java,v
retrieving revision 1.2
retrieving revision 1.2.4.1
diff -C2 -d -r1.2 -r1.2.4.1
*** ExcelConversionClient.java 7 Aug 2003 21:09:02 -0000 1.2
--- ExcelConversionClient.java 6 Jan 2004 14:11:48 -0000 1.2.4.1
***************
*** 1,151 ****
! /* ====================================================================
! * The Apache Software License, Version 1.1
! *
! * Copyright (c) 2000 The Apache Software Foundation. All rights
! * reserved.
! *
! * Redistribution and use in source and binary forms, with or without
! * modification, are permitted provided that the following conditions
! * are met:
! *
! * 1. Redistributions of source code must retain the above copyright
! * notice, this list of conditions and the following disclaimer.
! *
! * 2. Redistributions in binary form must reproduce the above copyright
! * notice, this list of conditions and the following disclaimer in
! * the documentation and/or other materials provided with the
! * distribution.
! *
! * 3. The end-user documentation included with the redistribution,
! * if any, must include the following acknowledgment:
! * "This product includes software developed by the
! * Apache Software Foundation (http://www.apache.org/)."
! * Alternately, this acknowledgment may appear in the software itself,
! * if and wherever such third-party acknowledgments normally appear.
! *
! * 4. The names "Apache" and "Apache Software Foundation" must
! * not be used to endorse or promote products derived from this
! * software without prior written permission. For written
! * permission, please contact ap...@ap....
! *
! * 5. Products derived from this software may not be called "Apache",
! * nor may "Apache" appear in their name, without prior written
! * permission of the Apache Software Foundation.
! *
! * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
! * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
! * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
! * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
! * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
! * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
! * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
! * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
! * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
! * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
! * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
! * SUCH DAMAGE.
! * ====================================================================
! *
! * This software consists of voluntary contributions made by many
! * individuals on behalf of the Apache Software Foundation. For more
! * information on the Apache Software Foundation, please see
! * <http://www.apache.org/>.
! *
! * Portions of this software are based upon public domain software
! * originally written at the National Center for Supercomputing Applications,
! * University of Illinois, Urbana-Champaign.
! * ====================================================================
! *
! * Babeldoc: The Universal Document Processor
! *
! * $Header$
! * $DateTime$
! * $Author$
! *
! */
! package com.babeldoc.conversion.excel;
!
! import com.babeldoc.conversion.ConversionException;
! import com.babeldoc.conversion.ConversionHelper;
! import com.babeldoc.core.BabeldocCommand;
! import com.babeldoc.core.I18n;
! import com.babeldoc.core.LogService;
! import com.babeldoc.core.ResourceLoader;
! import org.apache.commons.cli.CommandLine;
! import org.apache.commons.cli.OptionBuilder;
! import org.apache.commons.cli.Options;
!
! import java.io.IOException;
! import java.io.InputStream;
!
! /**
! * Class to access the Apache POI library to toXml Excel files to XML.
! *
! * @author dejank
! */
! public class ExcelConversionClient
! extends BabeldocCommand {
!
! /**
! * Construct this object and call the super with the argument for setting up
! * the conversion client.
! *
! * @param args
! */
! public ExcelConversionClient(String[] args) {
! super("conversion", I18n.get("conversion.009"), args);
! }
!
! /**
! * Main method.
! *
! * @param commandline DOCUMENT ME!
! */
! public void execute(CommandLine commandline) {
! InputStream in = null;
!
! if (commandline.hasOption('f')) {
! String inFile = commandline.getOptionValue('f');
!
! try {
! in = ResourceLoader.getResourceStream(inFile);
! } catch (IOException e) {
! LogService.getInstance().logError(I18n.get(
! "conversion.exception.io.infile", inFile), e);
!
! return;
! }
! }
!
! if (in != null) {
! try {
! ConversionHelper.render(new ExcelConverter().toXml(in), System.out, null);
! } catch (ConversionException e) {
! LogService.getInstance().logError(e);
! }
! } else {
! System.err.println(I18n.get("conversion.008"));
! }
! }
!
! /**
! * setup the options on the command line.
! *
! * @param options the options to access
! */
! public void setupCommandLine(Options options) {
! super.setupCommandLine(options);
! options.addOption(OptionBuilder.isRequired().hasArg(true)
! .withDescription(I18n.get("conversion.010"))
! .withLongOpt("file").create('f'));
! }
!
! /**
! * Main
! *
! * @param args the arguments
! */
! public static void main(String[] args) {
! new ExcelConversionClient(args);
! }
! }
--- 1,175 ----
! /*
! * ==================================================================== The
! * Apache Software License, Version 1.1
! *
! * Copyright (c) 2000 The Apache Software Foundation. All rights reserved.
! *
! * Redistribution and use in source and binary forms, with or without
! * modification, are permitted provided that the following conditions are met:
! * 1. Redistributions of source code must retain the above copyright notice,
! * this list of conditions and the following disclaimer.
! * 2. Redistributions in binary form must reproduce the above copyright
! * notice, this list of conditions and the following disclaimer in the
! * documentation and/or other materials provided with the distribution.
! * 3. The end-user documentation included with the redistribution, if any,
! * must include the following acknowledgment: "This product includes software
! * developed by the Apache Software Foundation (http://www.apache.org/)."
! * Alternately, this acknowledgment may appear in the software itself, if and
! * wherever such third-party acknowledgments normally appear.
! * 4. The names "Apache" and "Apache Software Foundation" must not be used to
! * endorse or promote products derived from this software without prior written
! * permission. For written permission, please contact ap...@ap....
! * 5. Products derived from this software may not be called "Apache", nor may
! * "Apache" appear in their name, without prior written permission of the
! * Apache Software Foundation.
! *
! * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
! * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
! * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
! * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
! * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
! * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
! * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
! * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
! * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
! * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
! * ====================================================================
! *
! * This software consists of voluntary contributions made by many individuals
! * on behalf of the Apache Software Foundation. For more information on the
! * Apache Software Foundation, please see <http://www.apache.org/> .
! *
! * Portions of this software are based upon public domain software originally
! * written at the National Center for Supercomputing Applications, University
! * of Illinois, Urbana-Champaign.
! * ====================================================================
! *
! * Babeldoc: The Universal Document Processor
! *
! * $Header:
! * /cvsroot/babeldoc/babeldoc/modules/conversion/src/com/babeldoc/conversion/excel/ExcelConversionClient.java,v
! * 1.2 2003/08/07 21:09:02 triphop Exp $ $DateTime$ $Author$
! *
! */
! package com.babeldoc.conversion.excel;
!
! import com.babeldoc.conversion.ConversionException;
! import com.babeldoc.conversion.ConversionHelper;
! import com.babeldoc.core.BabeldocCommand;
! import com.babeldoc.core.I18n;
! import com.babeldoc.core.LogService;
! import com.babeldoc.core.ResourceLoader;
! import org.apache.commons.cli.CommandLine;
! import org.apache.commons.cli.OptionBuilder;
! import org.apache.commons.cli.Options;
!
! import java.io.FileOutputStream;
! import java.io.IOException;
! import java.io.InputStream;
! import java.io.OutputStream;
!
! /**
! * Class to access the Apache POI library to toXml Excel files to XML.
! *
! * @author dejank
! */
! public class ExcelConversionClient extends BabeldocCommand {
!
! /**
! * Construct this object and call the super with the argument for setting up
! * the conversion client.
! *
! * @param args
! */
! public ExcelConversionClient(String[] args) {
! super("conversion", I18n.get("conversion.009"), args);
! }
!
! /**
! * Main method.
! *
! * @param commandline
! * DOCUMENT ME!
! */
! public void execute(CommandLine commandline) {
! InputStream in = null;
!
! if (commandline.hasOption('f')) {
! String inFile = commandline.getOptionValue('f');
!
! try {
! in = ResourceLoader.getResourceStream(inFile);
! } catch (IOException e) {
! LogService.getInstance().logError(
! I18n.get("conversion.exception.io.infile", inFile), e);
!
! return;
! }
! }
! OutputStream os = null;
! if (commandline.hasOption('o')) {
! try {
! String outFile = commandline.getOptionValue('o');
! os = new FileOutputStream(outFile);
! } catch (IOException ioe) {
! LogService.getInstance().logError(
! "Error creating output file. Switching to System.out", ioe);
! }
! }
! if (os == null) {
! os = System.out;
! }
! if (in != null) {
! try {
! ExcelConverter converter = new ExcelConverter();
! if (commandline.hasOption('l')) {
! System.out.println("Setting locale "
! + commandline.getOptionValue('l'));
! converter.setLocale(commandline.getOptionValue('l'));
! }
! ConversionHelper.render(converter.toXml(in), os, null);
! } catch (ConversionException e) {
! LogService.getInstance().logError(e);
! } finally {
! if (os != System.out) {
! try {
! os.close();
! } catch (IOException e) {
!
! }
! }
! }
! } else {
! System.err.println(I18n.get("conversion.008"));
! }
! }
!
! /**
! * setup the options on the command line.
! *
! * @param options
! * the options to access
! */
! public void setupCommandLine(Options options) {
! super.setupCommandLine(options);
! options.addOption(OptionBuilder.isRequired().hasArg(true).withDescription(
! I18n.get("conversion.excel.client.file")).withLongOpt("file").create(
! 'f'));
! options.addOption(OptionBuilder.hasArg(true).withDescription(
! I18n.get("conversion.excel.client.output")).withLongOpt("output")
! .create('o'));
! options.addOption(OptionBuilder.hasArg(true).withDescription(
! I18n.get("conversion.excel.client.locale")).withLongOpt("locale")
! .create('l'));
! }
!
! /**
! * Main
! *
! * @param args
! * the arguments
! */
! public static void main(String[] args) {
! new ExcelConversionClient(args);
! }
! }
|