You can subscribe to this list here.
| 2003 |
Jan
|
Feb
(14) |
Mar
(107) |
Apr
(211) |
May
(93) |
Jun
(158) |
Jul
(159) |
Aug
(368) |
Sep
(188) |
Oct
(151) |
Nov
(115) |
Dec
(98) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2004 |
Jan
(25) |
Feb
|
Mar
(33) |
Apr
(28) |
May
(116) |
Jun
(2) |
Jul
(117) |
Aug
(19) |
Sep
(9) |
Oct
(2) |
Nov
|
Dec
(4) |
| 2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
(9) |
Dec
|
| 2006 |
Jan
|
Feb
|
Mar
(22) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2007 |
Jan
|
Feb
|
Mar
(6) |
Apr
|
May
|
Jun
|
Jul
|
Aug
(267) |
Sep
|
Oct
|
Nov
(6) |
Dec
(512) |
| 2008 |
Jan
(187) |
Feb
|
Mar
|
Apr
|
May
|
Jun
(3) |
Jul
(6) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
|
Dec
|
| 2012 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
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);
! }
! }
|
|
From: <de...@us...> - 2004-01-06 14:10:02
|
Update of /cvsroot/babeldoc/babeldoc/modules/conversion/src/com/babeldoc/conversion/excel
In directory sc8-pr-cvs1:/tmp/cvs-serv942/modules/conversion/src/com/babeldoc/conversion/excel
Modified Files:
Tag: V1-2
ExcelConverter.java
Log Message:
- Excel converter now can read cells with formulas
- Numbers are parsed using format specified in Excel cells and given locale. Locale can be specified as config option in XlsToXml pipeline stage
Index: ExcelConverter.java
===================================================================
RCS file: /cvsroot/babeldoc/babeldoc/modules/conversion/src/com/babeldoc/conversion/excel/ExcelConverter.java,v
retrieving revision 1.1
retrieving revision 1.1.4.1
diff -C2 -d -r1.1 -r1.1.4.1
*** ExcelConverter.java 19 Jul 2003 13:16:47 -0000 1.1
--- ExcelConverter.java 6 Jan 2004 14:09:58 -0000 1.1.4.1
***************
*** 1,187 ****
! /* ====================================================================
! * 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 org.apache.poi.hssf.usermodel.HSSFCell;
! import org.apache.poi.hssf.usermodel.HSSFRow;
! import org.apache.poi.hssf.usermodel.HSSFSheet;
! import org.apache.poi.hssf.usermodel.HSSFWorkbook;
! import org.apache.poi.poifs.filesystem.POIFSFileSystem;
! import org.dom4j.Document;
! import org.dom4j.DocumentHelper;
! import org.dom4j.Element;
!
! import java.io.IOException;
! import java.io.InputStream;
!
! /**
! * Simple class to toXml an input stream of an excel file to an
! * xml output stream
! *
! * @author dejank
! */
! public class ExcelConverter {
!
! /**
! * Convert a input stream of excel file as input to an xml document.
! *
! * @param in excel file stream
! * @return the document
! * @throws com.babeldoc.conversion.ConversionException
! */
! public Document toXml(InputStream in)
! throws ConversionException {
!
! POIFSFileSystem fs;
! try {
! fs = new POIFSFileSystem(in);
! HSSFWorkbook wb = new HSSFWorkbook(fs);
!
! HSSFSheet sheet = null;
! HSSFRow row = null;
! HSSFCell cell = null;
!
! Document document = DocumentHelper.createDocument();
! //
! Element root = document.addElement("workbook");
!
! int numberOfSheets = wb.getNumberOfSheets();
! root.addAttribute("number-of-sheets",
! String.valueOf(numberOfSheets));
!
! for (int i = 0; i < numberOfSheets; i++) {
! Element sheetElement = root.addElement("sheet");
! sheet = wb.getSheetAt(i);
! String sheetName = wb.getSheetName(i);
! sheetElement.addAttribute("sheet-name", sheetName);
! sheetElement.addAttribute("sheet-number",
! (new Integer(i)).toString());
!
! int rowCount = 0;
! int firstRowNum = sheet.getFirstRowNum();
! int lastRowNum = sheet.getLastRowNum();
!
! for (int m = firstRowNum; m <= lastRowNum; m++) {
! row = sheet.getRow(m);
! if (row == null)
! continue;
! Element rowElement = sheetElement.addElement("row");
! rowElement.addAttribute("row-number",
! (new Integer(m)).toString());
! rowCount++;
! int firstCellNum = row.getFirstCellNum();
! int lastCellNum = row.getLastCellNum();
! int cellCount = 0;
! for (int p = firstCellNum; p <= lastCellNum; p++) {
! cell = row.getCell((short) p);
! // if (cell == null || cell.getCellType() == HSSFCell.CELL_TYPE_BLANK) continue;
! if (cell == null)
! continue;
!
! cellCount++;
! Element cellElement = rowElement.addElement("cell");
! cellElement.addAttribute("cell-number", String.valueOf(cellCount));
! cellElement.addAttribute("cell-colnum",
! String.valueOf(cell.getCellNum()));
!
! int cellType = cell.getCellType();
! switch (cellType) {
! case HSSFCell.CELL_TYPE_NUMERIC :
! cellElement.addAttribute("type", "Numeric");
! cellElement.addText(
! String.valueOf(cell.getNumericCellValue()));
! break;
! case HSSFCell.CELL_TYPE_STRING :
! cellElement.addAttribute("type", "String");
! cellElement.addText(cell.getStringCellValue());
! break;
! case HSSFCell.CELL_TYPE_BOOLEAN :
! cellElement.addAttribute("type", "Boolean");
! cellElement.addText(
! String.valueOf(cell.getBooleanCellValue()));
! break;
! case HSSFCell.CELL_TYPE_BLANK :
! cellElement.addAttribute("type", "N/A");
! break;
! default :
! break;
! }
! }
! rowElement.addAttribute(
! "number-of-cells",
! String.valueOf(cellCount));
! }
! sheetElement.addAttribute(
! "number-of-rows",
! String.valueOf(rowCount));
! }
! return document;
! } catch(IOException iox) {
! throw new ConversionException("", iox);
! }
! }
! }
--- 1,254 ----
! /* ====================================================================
! * 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.core.LogService;
!
! import org.apache.poi.hssf.model.Workbook;
! import org.apache.poi.hssf.usermodel.HSSFCell;
! import org.apache.poi.hssf.usermodel.HSSFDataFormat;
! import org.apache.poi.hssf.usermodel.HSSFRow;
! import org.apache.poi.hssf.usermodel.HSSFSheet;
! import org.apache.poi.hssf.usermodel.HSSFWorkbook;
! import org.apache.poi.poifs.filesystem.POIFSFileSystem;
! import org.dom4j.Document;
! import org.dom4j.DocumentHelper;
! import org.dom4j.Element;
!
! import java.io.IOException;
! import java.io.InputStream;
! import java.text.DecimalFormat;
! import java.text.DecimalFormatSymbols;
! import java.text.NumberFormat;
! import java.text.SimpleDateFormat;
! import java.util.Date;
! import java.util.HashMap;
! import java.util.Iterator;
! import java.util.Locale;
!
! /**
! * Simple class to toXml an input stream of an excel file to an
! * xml output stream
! *
! * @author dejank
! */
! public class ExcelConverter {
!
! /**
! * Convert a input stream of excel file as input to an xml document.
! *
! * @param in excel file stream
! * @return the document
! * @throws com.babeldoc.conversion.ConversionException
! */
! private HashMap workBookAttributes = new HashMap();
! private String locale = null;
!
! public Document toXml(InputStream in)
! throws ConversionException {
!
! POIFSFileSystem fs;
! try {
! fs = new POIFSFileSystem(in);
! HSSFWorkbook wb = new HSSFWorkbook(fs);
!
! HSSFSheet sheet = null;
! HSSFRow row = null;
! HSSFCell cell = null;
! HSSFDataFormat dataFormat = wb.createDataFormat();
! Document document = DocumentHelper.createDocument();
! DecimalFormat formatter;
! if (locale == null) {
! formatter = (DecimalFormat) NumberFormat.getInstance();
! } else {
! formatter = (DecimalFormat) NumberFormat.getInstance(new Locale(locale));
! }
! Element root = document.addElement("workbook");
!
! int numberOfSheets = wb.getNumberOfSheets();
! root.addAttribute("number-of-sheets",
! String.valueOf(numberOfSheets));
!
! //this code is used for specifying additional attributes to
! //resulting XML document.
! if (workBookAttributes != null) {
! Iterator iter = workBookAttributes.keySet().iterator();
! while (iter.hasNext()) {
! String name = (String) iter.next();
! String value = (String) workBookAttributes.get(name);
! root.addAttribute(name, value);
! }
! }
!
! for (int i = 0; i < numberOfSheets; i++) {
! Element sheetElement = root.addElement("sheet");
! sheet = wb.getSheetAt(i);
! String sheetName = wb.getSheetName(i);
! sheetElement.addAttribute("sheet-name", sheetName);
! sheetElement.addAttribute("sheet-number",
! (new Integer(i)).toString());
!
! int rowCount = 0;
! int firstRowNum = sheet.getFirstRowNum();
! int lastRowNum = sheet.getLastRowNum();
!
! for (int m = firstRowNum; m <= lastRowNum; m++) {
! row = sheet.getRow(m);
! if (row == null)
! continue;
! Element rowElement = sheetElement.addElement("row");
! rowElement.addAttribute("row-number",
! (new Integer(m)).toString());
! rowCount++;
! int firstCellNum = row.getFirstCellNum();
! int lastCellNum = row.getLastCellNum();
! int cellCount = 0;
! for (int p = firstCellNum; p <= lastCellNum; p++) {
! cell = row.getCell((short) p);
! // if (cell == null || cell.getCellType() == HSSFCell.CELL_TYPE_BLANK) continue;
! if (cell == null)
! continue;
!
! cellCount++;
! Element cellElement = rowElement.addElement("cell");
! cellElement.addAttribute("cell-number", String.valueOf(cellCount));
! cellElement.addAttribute("cell-colnum",
! String.valueOf(cell.getCellNum()));
!
! int cellType = cell.getCellType();
! switch (cellType) {
! case HSSFCell.CELL_TYPE_NUMERIC:
! case HSSFCell.CELL_TYPE_FORMULA :
!
! double value = cell.getNumericCellValue();
!
! try {
!
! String format = dataFormat.getFormat(cell.getCellStyle().getDataFormat());
! formatter.applyPattern(format);
! cellElement.addText(formatter.format(value));
! } catch (Exception e) {
! //set the value without formatting
! LogService.getInstance(this.getClass().getName()).logWarn("Error trying to format number" + e);
! cellElement.addText(String.valueOf(value));
! }
! cellElement.addAttribute("type", "Numeric");
! //cellElement.addText(String.valueOf(value));
! break;
! case HSSFCell.CELL_TYPE_STRING :
! cellElement.addAttribute("type", "String");
! cellElement.addText(cell.getStringCellValue());
! break;
! case HSSFCell.CELL_TYPE_BOOLEAN :
! cellElement.addAttribute("type", "Boolean");
! cellElement.addText(
! String.valueOf(cell.getBooleanCellValue()));
! break;
! case HSSFCell.CELL_TYPE_BLANK :
! cellElement.addAttribute("type", "N/A");
! break;
! default :
! break;
! }
! }
! rowElement.addAttribute(
! "number-of-cells",
! String.valueOf(cellCount));
! }
! sheetElement.addAttribute(
! "number-of-rows",
! String.valueOf(rowCount));
! }
! return document;
! } catch(IOException iox) {
! throw new ConversionException("", iox);
! }
! }
!
!
! /**
! * @return Returns the workBookAttributes.
! */
! public HashMap getWorkBookAttributes() {
! return workBookAttributes;
! }
! /**
! * @param workBookAttributes The workBookAttributes to set.
! */
! public void setWorkBookAttributes(HashMap workBookAttributes) {
! this.workBookAttributes = workBookAttributes;
! }
!
!
!
! /**
! * @param locale The locale to set.
! */
! public void setLocale(String locale) {
! this.locale = locale;
! }
! }
|
|
From: <de...@us...> - 2004-01-06 14:10:02
|
Update of /cvsroot/babeldoc/babeldoc/modules/conversion/src/com/babeldoc/conversion/pipeline/stage
In directory sc8-pr-cvs1:/tmp/cvs-serv942/modules/conversion/src/com/babeldoc/conversion/pipeline/stage
Modified Files:
Tag: V1-2
XlsToXmlPipelineStage.java
Log Message:
- Excel converter now can read cells with formulas
- Numbers are parsed using format specified in Excel cells and given locale. Locale can be specified as config option in XlsToXml pipeline stage
Index: XlsToXmlPipelineStage.java
===================================================================
RCS file: /cvsroot/babeldoc/babeldoc/modules/conversion/src/com/babeldoc/conversion/pipeline/stage/XlsToXmlPipelineStage.java,v
retrieving revision 1.5
retrieving revision 1.5.4.1
diff -C2 -d -r1.5 -r1.5.4.1
*** XlsToXmlPipelineStage.java 7 Aug 2003 21:09:02 -0000 1.5
--- XlsToXmlPipelineStage.java 6 Jan 2004 14:09:59 -0000 1.5.4.1
***************
*** 74,79 ****
--- 74,81 ----
import com.babeldoc.core.I18n;
+ import java.text.SimpleDateFormat;
import java.util.Collection;
import java.util.ArrayList;
+ import java.util.Date;
/**
***************
*** 87,92 ****
public class XlsToXmlPipelineStage extends PipelineStage {
! public static String DATE_FORMAT = "dd.mm.yyyy";
public static final String ENCODING = "encoding";
/**
--- 89,96 ----
public class XlsToXmlPipelineStage extends PipelineStage {
! public static String DATE_FORMAT = "dd.MM.yyyy";
public static final String ENCODING = "encoding";
+ protected static final String ATTRIBUTES = "attributes";
+ protected static final String LOCALE = "locale";
/**
***************
*** 110,114 ****
IConfigOptionType.STRING, null, false,
I18n.get("conversion.pipeline.stage.XlsToXml.encoding")));
!
return options;
}
--- 114,120 ----
IConfigOptionType.STRING, null, false,
I18n.get("conversion.pipeline.stage.XlsToXml.encoding")));
! options.add(new ConfigOption(ATTRIBUTES, IConfigOptionType.MULTI, null, false, "Attributes"));
! options.add(new ConfigOption(LOCALE, IConfigOptionType.STRING, null, false,
! I18n.get("conversion.pipeline.stage.XlsToXml.locale")));
return options;
}
***************
*** 129,133 ****
try {
! PipelineDocument doc = ConversionHelper.render(new ExcelConverter().toXml(this.getDocument().getInputStream()),
this.getDocument(), encoding);
doc.setBinary(false);
--- 135,144 ----
try {
!
! ExcelConverter converter = new ExcelConverter();
! //we should make this more configurable later...
! converter.getWorkBookAttributes().put("date", new SimpleDateFormat(DATE_FORMAT).format(new Date()));
! //this.getInfo().getOptions().
! PipelineDocument doc = ConversionHelper.render(converter.toXml(this.getDocument().getInputStream()),
this.getDocument(), encoding);
doc.setBinary(false);
|
|
From: <de...@us...> - 2004-01-06 14:10:02
|
Update of /cvsroot/babeldoc/babeldoc/modules/conversion/config/i18n
In directory sc8-pr-cvs1:/tmp/cvs-serv942/modules/conversion/config/i18n
Modified Files:
Tag: V1-2
messages.properties
Log Message:
- Excel converter now can read cells with formulas
- Numbers are parsed using format specified in Excel cells and given locale. Locale can be specified as config option in XlsToXml pipeline stage
Index: messages.properties
===================================================================
RCS file: /cvsroot/babeldoc/babeldoc/modules/conversion/config/i18n/messages.properties,v
retrieving revision 1.5
retrieving revision 1.5.4.1
diff -C2 -d -r1.5 -r1.5.4.1
*** messages.properties 7 Aug 2003 21:09:01 -0000 1.5
--- messages.properties 6 Jan 2004 14:09:58 -0000 1.5.4.1
***************
*** 9,13 ****
conversion.008=Incorrect number of arguments
conversion.009=Commandline client to convert flatfiles to xml documents
! conversion.010=file to convert
conversion.011=conversion configuration file
conversion.012=Use xml unmarshaller
--- 9,15 ----
conversion.008=Incorrect number of arguments
conversion.009=Commandline client to convert flatfiles to xml documents
! conversion.excel.client.file=file to convert
! conversion.excel.client.output=output file
! conversion.excel.client.locale=format date and numbers with this locale
conversion.011=conversion configuration file
conversion.012=Use xml unmarshaller
***************
*** 26,27 ****
--- 28,32 ----
conversion.pipeline.stage.XlsToXml.encoding=Encoding string for the output XML. By default it is UTF-8.
conversion.pipeline.stage.XlsToXml.error=Error converting XLS file to XML
+ conversion.pipeline.stage.XlsToXml.locale=Locale which should be used for formatting numbers and dates from Excel workbook. If not specified, default Locale will be used.
+
+ conversion.excel.client.locale=Locale which should be used for formatting numbers and dates from Excel workbook. If not specified, default Locale will be used.
|
|
From: Michael A. <mic...@ze...> - 2003-12-30 21:49:57
|
Hi, Bruce,
I haven't yet put it into my working set. I'll probably get a chance as
soon as I'm back from Cape Town. In fact, I'm going to have to do it
then, because I need it soon after that.
Cheers...
MikeA
On Mon, 2003-12-29 at 13:08, Bruce McDonald wrote:
> Dejan:
> I kinda liked getDocumentAsString but its not a big deal.
>=20
> All:
>=20
> What do you think of the observer pattern classes I emailed to the list s=
ome=20
> time back for the configuration classes?=20
>=20
> regards,
> Bruce.
>=20
> On Monday 29 December 2003 03:13 am, Dejan Krsmanovic wrote:
> > I would suggest using some shorter name. Something like getContents() a=
s
> > Mitch Christensen proposed. Note that this method will mostly be used i=
n
> > pipeline configurations and I would prefer using:
> >
> > blah.blah=3D${document.contents}
> >
> > then
> >
> > blah.blah=3D${document.documentAsString}
> >
> >
> >
> > Dejan
> >
> > >OK, done and committed to both branches. The new method name is
> > >
> > >getDocumentAsString().
> >
> > -------------------------------------------------------
> > This SF.net email is sponsored by: IBM Linux Tutorials.
> > Become an expert in LINUX or just sharpen your skills. Sign up for IBM=
's
> > Free Linux Tutorials. Learn everything from the bash shell to sys admi=
n.
> > Click now! http://ads.osdn.com/?ad_id=3D1278&alloc_id=3D3371&op=3Dclick
> > _______________________________________________
> > Babeldoc-devel mailing list
> > Bab...@li...
> > https://lists.sourceforge.net/lists/listinfo/babeldoc-devel
>=20
>=20
> -------------------------------------------------------
> This SF.net email is sponsored by: IBM Linux Tutorials.
> Become an expert in LINUX or just sharpen your skills. Sign up for IBM's
> Free Linux Tutorials. Learn everything from the bash shell to sys admin.
> Click now! http://ads.osdn.com/?ad_id=3D1278&alloc_id=3D3371&op=3Dclick
> _______________________________________________
> Babeldoc-devel mailing list
> Bab...@li...
> https://lists.sourceforge.net/lists/listinfo/babeldoc-devel
|
|
From: <de...@us...> - 2003-12-29 15:11:23
|
Update of /cvsroot/babeldoc/babeldoc/modules/conversion/src/com/babeldoc/conversion/pipeline/stage
In directory sc8-pr-cvs1:/tmp/cvs-serv5738/babeldoc/modules/conversion/src/com/babeldoc/conversion/pipeline/stage
Modified Files:
XlsToXmlPipelineStage.java
Log Message:
Added date attribute to ExcelConverter. This is currently hardcoded but I am thinking of finding a way for specifying attributes declaratevly inisde pipeline configuration
Index: XlsToXmlPipelineStage.java
===================================================================
RCS file: /cvsroot/babeldoc/babeldoc/modules/conversion/src/com/babeldoc/conversion/pipeline/stage/XlsToXmlPipelineStage.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** XlsToXmlPipelineStage.java 7 Aug 2003 21:09:02 -0000 1.5
--- XlsToXmlPipelineStage.java 29 Dec 2003 15:11:07 -0000 1.6
***************
*** 74,79 ****
--- 74,81 ----
import com.babeldoc.core.I18n;
+ import java.text.SimpleDateFormat;
import java.util.Collection;
import java.util.ArrayList;
+ import java.util.Date;
/**
***************
*** 87,92 ****
public class XlsToXmlPipelineStage extends PipelineStage {
! public static String DATE_FORMAT = "dd.mm.yyyy";
public static final String ENCODING = "encoding";
/**
--- 89,95 ----
public class XlsToXmlPipelineStage extends PipelineStage {
! public static String DATE_FORMAT = "dd.MM.yyyy";
public static final String ENCODING = "encoding";
+ protected static final String ATTRIBUTES = "attributes";
/**
***************
*** 110,113 ****
--- 113,117 ----
IConfigOptionType.STRING, null, false,
I18n.get("conversion.pipeline.stage.XlsToXml.encoding")));
+ options.add(new ConfigOption(ATTRIBUTES, IConfigOptionType.MULTI, null, false, "Attributes"));
return options;
***************
*** 129,133 ****
try {
! PipelineDocument doc = ConversionHelper.render(new ExcelConverter().toXml(this.getDocument().getInputStream()),
this.getDocument(), encoding);
doc.setBinary(false);
--- 133,142 ----
try {
!
! ExcelConverter converter = new ExcelConverter();
! //we should make this more configurable later...
! converter.getWorkBookAttributes().put("date", new SimpleDateFormat(DATE_FORMAT).format(new Date()));
! //this.getInfo().getOptions().
! PipelineDocument doc = ConversionHelper.render(converter.toXml(this.getDocument().getInputStream()),
this.getDocument(), encoding);
doc.setBinary(false);
|
|
From: <de...@us...> - 2003-12-29 14:53:07
|
Update of /cvsroot/babeldoc/babeldoc/modules/conversion/src/com/babeldoc/conversion/excel In directory sc8-pr-cvs1:/tmp/cvs-serv2613/babeldoc/modules/conversion/src/com/babeldoc/conversion/excel Modified Files: ExcelConverter.java Log Message: Intoducing attributes that can be added to workbook element in resulting xml document Index: ExcelConverter.java =================================================================== RCS file: /cvsroot/babeldoc/babeldoc/modules/conversion/src/com/babeldoc/conversion/excel/ExcelConverter.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ExcelConverter.java 19 Jul 2003 13:16:47 -0000 1.1 --- ExcelConverter.java 29 Dec 2003 14:52:58 -0000 1.2 *************** *** 1,187 **** ! /* ==================================================================== ! * 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 org.apache.poi.hssf.usermodel.HSSFCell; ! import org.apache.poi.hssf.usermodel.HSSFRow; ! import org.apache.poi.hssf.usermodel.HSSFSheet; ! import org.apache.poi.hssf.usermodel.HSSFWorkbook; ! import org.apache.poi.poifs.filesystem.POIFSFileSystem; ! import org.dom4j.Document; ! import org.dom4j.DocumentHelper; ! import org.dom4j.Element; ! ! import java.io.IOException; ! import java.io.InputStream; ! ! /** ! * Simple class to toXml an input stream of an excel file to an ! * xml output stream ! * ! * @author dejank ! */ ! public class ExcelConverter { ! ! /** ! * Convert a input stream of excel file as input to an xml document. ! * ! * @param in excel file stream ! * @return the document ! * @throws com.babeldoc.conversion.ConversionException ! */ ! public Document toXml(InputStream in) ! throws ConversionException { ! ! POIFSFileSystem fs; ! try { ! fs = new POIFSFileSystem(in); ! HSSFWorkbook wb = new HSSFWorkbook(fs); ! ! HSSFSheet sheet = null; ! HSSFRow row = null; ! HSSFCell cell = null; ! ! Document document = DocumentHelper.createDocument(); ! // ! Element root = document.addElement("workbook"); ! ! int numberOfSheets = wb.getNumberOfSheets(); ! root.addAttribute("number-of-sheets", ! String.valueOf(numberOfSheets)); ! ! for (int i = 0; i < numberOfSheets; i++) { ! Element sheetElement = root.addElement("sheet"); ! sheet = wb.getSheetAt(i); ! String sheetName = wb.getSheetName(i); ! sheetElement.addAttribute("sheet-name", sheetName); ! sheetElement.addAttribute("sheet-number", ! (new Integer(i)).toString()); ! ! int rowCount = 0; ! int firstRowNum = sheet.getFirstRowNum(); ! int lastRowNum = sheet.getLastRowNum(); ! ! for (int m = firstRowNum; m <= lastRowNum; m++) { ! row = sheet.getRow(m); ! if (row == null) ! continue; ! Element rowElement = sheetElement.addElement("row"); ! rowElement.addAttribute("row-number", ! (new Integer(m)).toString()); ! rowCount++; ! int firstCellNum = row.getFirstCellNum(); ! int lastCellNum = row.getLastCellNum(); ! int cellCount = 0; ! for (int p = firstCellNum; p <= lastCellNum; p++) { ! cell = row.getCell((short) p); ! // if (cell == null || cell.getCellType() == HSSFCell.CELL_TYPE_BLANK) continue; ! if (cell == null) ! continue; ! ! cellCount++; ! Element cellElement = rowElement.addElement("cell"); ! cellElement.addAttribute("cell-number", String.valueOf(cellCount)); ! cellElement.addAttribute("cell-colnum", ! String.valueOf(cell.getCellNum())); ! ! int cellType = cell.getCellType(); ! switch (cellType) { ! case HSSFCell.CELL_TYPE_NUMERIC : ! cellElement.addAttribute("type", "Numeric"); ! cellElement.addText( ! String.valueOf(cell.getNumericCellValue())); ! break; ! case HSSFCell.CELL_TYPE_STRING : ! cellElement.addAttribute("type", "String"); ! cellElement.addText(cell.getStringCellValue()); ! break; ! case HSSFCell.CELL_TYPE_BOOLEAN : ! cellElement.addAttribute("type", "Boolean"); ! cellElement.addText( ! String.valueOf(cell.getBooleanCellValue())); ! break; ! case HSSFCell.CELL_TYPE_BLANK : ! cellElement.addAttribute("type", "N/A"); ! break; ! default : ! break; ! } ! } ! rowElement.addAttribute( ! "number-of-cells", ! String.valueOf(cellCount)); ! } ! sheetElement.addAttribute( ! "number-of-rows", ! String.valueOf(rowCount)); ! } ! return document; ! } catch(IOException iox) { ! throw new ConversionException("", iox); ! } ! } ! } --- 1,218 ---- ! /* ==================================================================== ! * 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 org.apache.poi.hssf.usermodel.HSSFCell; ! import org.apache.poi.hssf.usermodel.HSSFRow; ! import org.apache.poi.hssf.usermodel.HSSFSheet; ! import org.apache.poi.hssf.usermodel.HSSFWorkbook; ! import org.apache.poi.poifs.filesystem.POIFSFileSystem; ! import org.dom4j.Document; ! import org.dom4j.DocumentHelper; ! import org.dom4j.Element; ! ! import java.io.IOException; ! import java.io.InputStream; ! import java.text.SimpleDateFormat; ! import java.util.Date; ! import java.util.HashMap; ! import java.util.Iterator; ! ! /** ! * Simple class to toXml an input stream of an excel file to an ! * xml output stream ! * ! * @author dejank ! */ ! public class ExcelConverter { ! ! /** ! * Convert a input stream of excel file as input to an xml document. ! * ! * @param in excel file stream ! * @return the document ! * @throws com.babeldoc.conversion.ConversionException ! */ ! private HashMap workBookAttributes = new HashMap(); ! ! public Document toXml(InputStream in) ! throws ConversionException { ! ! POIFSFileSystem fs; ! try { ! fs = new POIFSFileSystem(in); ! HSSFWorkbook wb = new HSSFWorkbook(fs); ! ! HSSFSheet sheet = null; ! HSSFRow row = null; ! HSSFCell cell = null; ! ! Document document = DocumentHelper.createDocument(); ! // ! Element root = document.addElement("workbook"); ! ! int numberOfSheets = wb.getNumberOfSheets(); ! root.addAttribute("number-of-sheets", ! String.valueOf(numberOfSheets)); ! ! //this code is used for specifying additional attributes to ! //resulting XML document. ! if (workBookAttributes != null) { ! Iterator iter = workBookAttributes.keySet().iterator(); ! while (iter.hasNext()) { ! String name = (String) iter.next(); ! String value = (String) workBookAttributes.get(name); ! root.addAttribute(name, value); ! } ! } ! ! for (int i = 0; i < numberOfSheets; i++) { ! Element sheetElement = root.addElement("sheet"); ! sheet = wb.getSheetAt(i); ! String sheetName = wb.getSheetName(i); ! sheetElement.addAttribute("sheet-name", sheetName); ! sheetElement.addAttribute("sheet-number", ! (new Integer(i)).toString()); ! ! int rowCount = 0; ! int firstRowNum = sheet.getFirstRowNum(); ! int lastRowNum = sheet.getLastRowNum(); ! ! for (int m = firstRowNum; m <= lastRowNum; m++) { ! row = sheet.getRow(m); ! if (row == null) ! continue; ! Element rowElement = sheetElement.addElement("row"); ! rowElement.addAttribute("row-number", ! (new Integer(m)).toString()); ! rowCount++; ! int firstCellNum = row.getFirstCellNum(); ! int lastCellNum = row.getLastCellNum(); ! int cellCount = 0; ! for (int p = firstCellNum; p <= lastCellNum; p++) { ! cell = row.getCell((short) p); ! // if (cell == null || cell.getCellType() == HSSFCell.CELL_TYPE_BLANK) continue; ! if (cell == null) ! continue; ! ! cellCount++; ! Element cellElement = rowElement.addElement("cell"); ! cellElement.addAttribute("cell-number", String.valueOf(cellCount)); ! cellElement.addAttribute("cell-colnum", ! String.valueOf(cell.getCellNum())); ! ! int cellType = cell.getCellType(); ! switch (cellType) { ! case HSSFCell.CELL_TYPE_NUMERIC : ! cellElement.addAttribute("type", "Numeric"); ! cellElement.addText( ! String.valueOf(cell.getNumericCellValue())); ! break; ! case HSSFCell.CELL_TYPE_STRING : ! cellElement.addAttribute("type", "String"); ! cellElement.addText(cell.getStringCellValue()); ! break; ! case HSSFCell.CELL_TYPE_BOOLEAN : ! cellElement.addAttribute("type", "Boolean"); ! cellElement.addText( ! String.valueOf(cell.getBooleanCellValue())); ! break; ! case HSSFCell.CELL_TYPE_BLANK : ! cellElement.addAttribute("type", "N/A"); ! break; ! default : ! break; ! } ! } ! rowElement.addAttribute( ! "number-of-cells", ! String.valueOf(cellCount)); ! } ! sheetElement.addAttribute( ! "number-of-rows", ! String.valueOf(rowCount)); ! } ! return document; ! } catch(IOException iox) { ! throw new ConversionException("", iox); ! } ! } ! ! ! /** ! * @return Returns the workBookAttributes. ! */ ! public HashMap getWorkBookAttributes() { ! return workBookAttributes; ! } ! /** ! * @param workBookAttributes The workBookAttributes to set. ! */ ! public void setWorkBookAttributes(HashMap workBookAttributes) { ! this.workBookAttributes = workBookAttributes; ! } ! } |
|
From: Dejan K. <dej...@nb...> - 2003-12-29 13:46:38
|
Unfortunately, I was pretty bussy when you sent that mail, so I haven't time to examine the code. I even don't have that mail here.... Anyway, I haven't problems with issues you have tried to solve with that code so I guess I cannot help you a lot. Dejan > All: > > What do you think of the observer pattern classes I emailed to the list some > time back for the configuration classes? > |
|
From: Dejan K. <dej...@nb...> - 2003-12-29 13:40:13
|
IMO, document is consisted of contents and attributes. So I think that
method name getContents or maybe getContentsAsString (since content can be
binary) is better. But as you said - it is not a big deal. I'll need to
change some of my pipelines anyway since I've used toString() there!
Dejan
----- Original Message -----
From: "Bruce McDonald" <br...@mc...>
To: "Dejan Krsmanovic" <dej...@nb...>; "Babeldoc Developer List"
<bab...@li...>
Sent: Monday, December 29, 2003 2:08 PM
Subject: Re: [Babeldoc-devel] Re: PipelineDocument.toString()
> Dejan:
> I kinda liked getDocumentAsString but its not a big deal.
>
> All:
>
> What do you think of the observer pattern classes I emailed to the list
some
> time back for the configuration classes?
>
> regards,
> Bruce.
>
> On Monday 29 December 2003 03:13 am, Dejan Krsmanovic wrote:
> > I would suggest using some shorter name. Something like getContents() as
> > Mitch Christensen proposed. Note that this method will mostly be used in
> > pipeline configurations and I would prefer using:
> >
> > blah.blah=${document.contents}
> >
> > then
> >
> > blah.blah=${document.documentAsString}
> >
> >
> >
> > Dejan
> >
> > >OK, done and committed to both branches. The new method name is
> > >
> > >getDocumentAsString().
> >
> > -------------------------------------------------------
> > This SF.net email is sponsored by: IBM Linux Tutorials.
> > Become an expert in LINUX or just sharpen your skills. Sign up for
IBM's
> > Free Linux Tutorials. Learn everything from the bash shell to sys
admin.
> > Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click
> > _______________________________________________
> > Babeldoc-devel mailing list
> > Bab...@li...
> > https://lists.sourceforge.net/lists/listinfo/babeldoc-devel
|
|
From: Bruce M. <br...@mc...> - 2003-12-29 13:08:11
|
Dejan:
I kinda liked getDocumentAsString but its not a big deal.
All:
What do you think of the observer pattern classes I emailed to the list some
time back for the configuration classes?
regards,
Bruce.
On Monday 29 December 2003 03:13 am, Dejan Krsmanovic wrote:
> I would suggest using some shorter name. Something like getContents() as
> Mitch Christensen proposed. Note that this method will mostly be used in
> pipeline configurations and I would prefer using:
>
> blah.blah=${document.contents}
>
> then
>
> blah.blah=${document.documentAsString}
>
>
>
> Dejan
>
> >OK, done and committed to both branches. The new method name is
> >
> >getDocumentAsString().
>
> -------------------------------------------------------
> This SF.net email is sponsored by: IBM Linux Tutorials.
> Become an expert in LINUX or just sharpen your skills. Sign up for IBM's
> Free Linux Tutorials. Learn everything from the bash shell to sys admin.
> Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click
> _______________________________________________
> Babeldoc-devel mailing list
> Bab...@li...
> https://lists.sourceforge.net/lists/listinfo/babeldoc-devel
|
|
From: <mic...@us...> - 2003-12-29 08:56:22
|
Update of /cvsroot/babeldoc/babeldoc/modules/core/src/com/babeldoc/core/pipeline
In directory sc8-pr-cvs1:/tmp/cvs-serv11785/modules/core/src/com/babeldoc/core/pipeline
Modified Files:
Tag: V1-2
PipelineDocument.java
Log Message:
Changed method name to getContents().
Index: PipelineDocument.java
===================================================================
RCS file: /cvsroot/babeldoc/babeldoc/modules/core/src/com/babeldoc/core/pipeline/PipelineDocument.java,v
retrieving revision 1.16.4.1
retrieving revision 1.16.4.2
diff -C2 -d -r1.16.4.1 -r1.16.4.2
*** PipelineDocument.java 28 Dec 2003 21:45:41 -0000 1.16.4.1
--- PipelineDocument.java 29 Dec 2003 08:56:18 -0000 1.16.4.2
***************
*** 426,430 ****
* @return String the current document as a String
*/
! public String getDocumentAsString() {
return new String(buffer);
}
--- 426,430 ----
* @return String the current document as a String
*/
! public String getContents() {
return new String(buffer);
}
|
|
From: <mic...@us...> - 2003-12-29 08:55:13
|
Update of /cvsroot/babeldoc/babeldoc/modules/core/src/com/babeldoc/core/pipeline
In directory sc8-pr-cvs1:/tmp/cvs-serv11643/modules/core/src/com/babeldoc/core/pipeline
Modified Files:
PipelineDocument.java
Log Message:
Changed method name to getContents().
Index: PipelineDocument.java
===================================================================
RCS file: /cvsroot/babeldoc/babeldoc/modules/core/src/com/babeldoc/core/pipeline/PipelineDocument.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** PipelineDocument.java 28 Dec 2003 21:46:18 -0000 1.17
--- PipelineDocument.java 29 Dec 2003 08:55:07 -0000 1.18
***************
*** 426,430 ****
* @return String the current document as a String
*/
! public String getDocumentAsString() {
return new String(buffer);
}
--- 426,430 ----
* @return String the current document as a String
*/
! public String getContents() {
return new String(buffer);
}
|
|
From: Michael A. <mic...@ze...> - 2003-12-29 08:53:44
|
Fine, I'll make the change.
On Mon, 2003-12-29 at 08:13, Dejan Krsmanovic wrote:
> I would suggest using some shorter name. Something like getContents() as
> Mitch Christensen proposed. Note that this method will mostly be used in
> pipeline configurations and I would prefer using:
>=20
> blah.blah=3D${document.contents}
>=20
> then
>=20
> blah.blah=3D${document.documentAsString}
>=20
>=20
>=20
> Dejan
>=20
> >OK, done and committed to both branches. The new method name is
>=20
> >getDocumentAsString().
>=20
>=20
>=20
>=20
>=20
>=20
> -------------------------------------------------------
> This SF.net email is sponsored by: IBM Linux Tutorials.
> Become an expert in LINUX or just sharpen your skills. Sign up for IBM's
> Free Linux Tutorials. Learn everything from the bash shell to sys admin.
> Click now! http://ads.osdn.com/?ad_id=3D1278&alloc_id=3D3371&op=3Dclick
> _______________________________________________
> Babeldoc-devel mailing list
> Bab...@li...
> https://lists.sourceforge.net/lists/listinfo/babeldoc-devel
|
|
From: <de...@us...> - 2003-12-29 08:41:39
|
Update of /cvsroot/babeldoc/babeldoc/modules/scanner/config/i18n
In directory sc8-pr-cvs1:/tmp/cvs-serv9758/modules/scanner/config/i18n
Modified Files:
Tag: V1-2
messages.properties
Log Message:
Updated 1.2 branch with scanner bugfixes
Index: messages.properties
===================================================================
RCS file: /cvsroot/babeldoc/babeldoc/modules/scanner/config/i18n/messages.properties,v
retrieving revision 1.18
retrieving revision 1.18.4.1
diff -C2 -d -r1.18 -r1.18.4.1
*** messages.properties 13 Oct 2003 07:24:39 -0000 1.18
--- messages.properties 29 Dec 2003 08:41:33 -0000 1.18.4.1
***************
*** 95,98 ****
--- 95,99 ----
scanner.MailboxScannerInfo.option.toFilter=Regular expression which, if matched by the To field, causes the message to be processed
scanner.MailboxScannerInfo.option.subjectFilter=Regular expression which, if matched by the Subject field, causes the message to be processed
+ scanner.MailboxScannerInfo.option.deleteInvalid=Delete messages that are not valid (invalid address etc.) and not processed by Babeldoc
scanner.ExternalApplicationScanner.description=The ExternalApplicationScanner runs an external application and pipes the standard output from that application into the pipeline.
|
|
From: <de...@us...> - 2003-12-29 08:41:38
|
Update of /cvsroot/babeldoc/babeldoc/modules/scanner/src/com/babeldoc/scanner/worker
In directory sc8-pr-cvs1:/tmp/cvs-serv9758/modules/scanner/src/com/babeldoc/scanner/worker
Modified Files:
Tag: V1-2
MailboxScanner.java
Log Message:
Updated 1.2 branch with scanner bugfixes
Index: MailboxScanner.java
===================================================================
RCS file: /cvsroot/babeldoc/babeldoc/modules/scanner/src/com/babeldoc/scanner/worker/MailboxScanner.java,v
retrieving revision 1.29.4.1
retrieving revision 1.29.4.2
diff -C2 -d -r1.29.4.1 -r1.29.4.2
*** MailboxScanner.java 10 Dec 2003 09:48:34 -0000 1.29.4.1
--- MailboxScanner.java 29 Dec 2003 08:41:33 -0000 1.29.4.2
***************
*** 1,70 ****
! /* ====================================================================
! * 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:
! *
[...1011 lines suppressed...]
! options.add(new ConfigOption(MailboxScanner.FROM_FILTER,
! IConfigOptionType.STRING, null, true, I18n
! .get("scanner.MailboxScannerInfo.option.fromFilter")));
! options.add(new ConfigOption(MailboxScanner.TO_FILTER,
! IConfigOptionType.STRING, null, true, I18n
! .get("scanner.MailboxScannerInfo.option.toFilter")));
! options.add(new ConfigOption(MailboxScanner.SUBJECT_FILTER,
! IConfigOptionType.STRING, null, true, I18n
! .get("scanner.MailboxScannerInfo.option.subjectFilter")));
! options.add(new ConfigOption(MailboxScanner.DELETE,
! IConfigOptionType.BOOLEAN, "false", true, I18n
! .get("scanner.MailboxScannerInfo.option.deleteInvalid")));
!
! return options;
! }
}
|
|
From: Dejan K. <dej...@nb...> - 2003-12-29 08:16:42
|
I would suggest using some shorter name. Something like getContents() as
Mitch Christensen proposed. Note that this method will mostly be used in
pipeline configurations and I would prefer using:
blah.blah=${document.contents}
then
blah.blah=${document.documentAsString}
Dejan
>OK, done and committed to both branches. The new method name is
>getDocumentAsString().
|
|
From: Bruce M. <br...@mc...> - 2003-12-29 02:32:16
|
Dejan, Haha - too late for the 1.2.1 - I did that on December 26!!! Get those fixes in for 1.2.2. I think that Mike is going to implement the changes in 1.3 - can you do it in 1.2 also? That would be great. regards, Bruce. On Sunday 28 December 2003 03:38 pm, Dejan Krsmanovic wrote: > The only problem I see here is that toString was used > in previous versions for getting document as String. > There are examples in documentation where toString is > used this way. I wrote many pipelines which use > toString method for accessing content, too. > On the other hand I agree with Bruce and Mike that > toString() should return full state of object as > String - not just content. Note that currently (in 1.2 > release) there is no way to access content of document > as String so whatever option we choose - it should be > implemented in 1.2 release too, not just 1.3 (1.4 > stable). > > Dejan > P.S. > I fixes few bugs in Scanner module but I have updated > only HEAD branch. I will update 1.2 branch too, and we > can start thinking about 1.2.1 bugfix release. > > --- Bruce McDonald <br...@mc...> wrote: > > Mike, > > > > Good to see you back. > > > > I completely agree with you here. Your name looks > > perfect. > > > > regards, > > Bruce. > > > > On Saturday 27 December 2003 01:20 pm, Michael > > > > Ansley wrote: > > > Hi, Bruce, > > > > > > I noticed the discussion on the users list > > > > regarding the > > > > > PipelineDocument.toString() method. In the > > > > absence of other > > > > > suggestions, I'd like to suggest that: > > > > > > a) toString() stay as it is, because I think that > > > > any toString() method > > > > > should completely describe the object it's called > > > > on, > > > > > b) we create a new method, say documentToString() > > > > or > > > > > getDocumentAsString(), which contains the original > > > > toString() > > > > > functionality. > > > > > > I'm disinclined to think of this as a bug, and as > > > > such, I don't see any > > > > > reason for 1.2 to revert to the old behaviour, > > > > although others may > > > > > disagree. However, I would prefer to see 1.3 > > > > follow the suggestion > > > > > outlined above. > > > > > > Thoughts... > > > > > > Any objections to me creating the new method in > > > > 1.3? Preference for a > > > > > name? > > > > > > > > > MikeA > > ------------------------------------------------------- > > > This SF.net email is sponsored by: IBM Linux > > Tutorials. > > Become an expert in LINUX or just sharpen your > > skills. Sign up for IBM's > > Free Linux Tutorials. Learn everything from the > > bash shell to sys admin. > > Click now! > > http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click > > > _______________________________________________ > > Babeldoc-devel mailing list > > Bab...@li... > > https://lists.sourceforge.net/lists/listinfo/babeldoc-devel > > > __________________________________ > Do you Yahoo!? > New Yahoo! Photos - easier uploading and sharing. > http://photos.yahoo.com/ > > > ------------------------------------------------------- > This SF.net email is sponsored by: IBM Linux Tutorials. > Become an expert in LINUX or just sharpen your skills. Sign up for IBM's > Free Linux Tutorials. Learn everything from the bash shell to sys admin. > Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click > _______________________________________________ > Babeldoc-devel mailing list > Bab...@li... > https://lists.sourceforge.net/lists/listinfo/babeldoc-devel |
|
From: Michael A. <mic...@ze...> - 2003-12-28 21:48:09
|
OK, done and committed to both branches. The new method name is getDocumentAsString(). =20 Cheers... MikeA On Sun, 2003-12-28 at 20:38, Dejan Krsmanovic wrote: > The only problem I see here is that toString was used > in previous versions for getting document as String. > There are examples in documentation where toString is > used this way. I wrote many pipelines which use > toString method for accessing content, too. > On the other hand I agree with Bruce and Mike that > toString() should return full state of object as > String - not just content. Note that currently (in 1.2 > release) there is no way to access content of document > as String so whatever option we choose - it should be > implemented in 1.2 release too, not just 1.3 (1.4 > stable).=20 >=20 > Dejan > P.S.=20 > I fixes few bugs in Scanner module but I have updated > only HEAD branch. I will update 1.2 branch too, and we > can start thinking about 1.2.1 bugfix release. >=20 >=20 > --- Bruce McDonald <br...@mc...> wrote: > > Mike, > >=20 > > Good to see you back. =20 > >=20 > > I completely agree with you here. Your name looks > > perfect. > >=20 > > regards, > > Bruce. > >=20 > > On Saturday 27 December 2003 01:20 pm, Michael > > Ansley wrote: > > > Hi, Bruce, > > > > > > I noticed the discussion on the users list > > regarding the > > > PipelineDocument.toString() method. In the > > absence of other > > > suggestions, I'd like to suggest that: > > > > > > a) toString() stay as it is, because I think that > > any toString() method > > > should completely describe the object it's called > > on, > > > > > > b) we create a new method, say documentToString() > > or > > > getDocumentAsString(), which contains the original > > toString() > > > functionality. > > > > > > I'm disinclined to think of this as a bug, and as > > such, I don't see any > > > reason for 1.2 to revert to the old behaviour, > > although others may > > > disagree. However, I would prefer to see 1.3 > > follow the suggestion > > > outlined above. > > > > > > Thoughts... > > > > > > Any objections to me creating the new method in > > 1.3? Preference for a > > > name? > > > > > > > > > MikeA > >=20 > >=20 > > > ------------------------------------------------------- > > This SF.net email is sponsored by: IBM Linux > > Tutorials. > > Become an expert in LINUX or just sharpen your > > skills. Sign up for IBM's > > Free Linux Tutorials. Learn everything from the > > bash shell to sys admin. > > Click now! > > > http://ads.osdn.com/?ad_id=3D1278&alloc_id=3D3371&op=3Dclick > > _______________________________________________ > > Babeldoc-devel mailing list > > Bab...@li... > > > https://lists.sourceforge.net/lists/listinfo/babeldoc-devel >=20 >=20 > __________________________________ > Do you Yahoo!? > New Yahoo! Photos - easier uploading and sharing. > http://photos.yahoo.com/ >=20 >=20 > ------------------------------------------------------- > This SF.net email is sponsored by: IBM Linux Tutorials. > Become an expert in LINUX or just sharpen your skills. Sign up for IBM's > Free Linux Tutorials. Learn everything from the bash shell to sys admin. > Click now! http://ads.osdn.com/?ad_id=3D1278&alloc_id=3D3371&op=3Dclick > _______________________________________________ > Babeldoc-devel mailing list > Bab...@li... > https://lists.sourceforge.net/lists/listinfo/babeldoc-devel |
|
From: <mic...@us...> - 2003-12-28 21:46:22
|
Update of /cvsroot/babeldoc/babeldoc/modules/core/src/com/babeldoc/core/pipeline
In directory sc8-pr-cvs1:/tmp/cvs-serv13085/modules/core/src/com/babeldoc/core/pipeline
Modified Files:
PipelineDocument.java
Log Message:
Added a getDocumentAsString() method, to complement the toString() changes earlier.
Index: PipelineDocument.java
===================================================================
RCS file: /cvsroot/babeldoc/babeldoc/modules/core/src/com/babeldoc/core/pipeline/PipelineDocument.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** PipelineDocument.java 8 Sep 2003 22:48:44 -0000 1.16
--- PipelineDocument.java 28 Dec 2003 21:46:18 -0000 1.17
***************
*** 422,425 ****
--- 422,434 ----
/**
+ * Return the document to a string
+ *
+ * @return String the current document as a String
+ */
+ public String getDocumentAsString() {
+ return new String(buffer);
+ }
+
+ /**
* Kinda clone
*
|
|
From: <mic...@us...> - 2003-12-28 21:45:44
|
Update of /cvsroot/babeldoc/babeldoc/modules/core/src/com/babeldoc/core/pipeline
In directory sc8-pr-cvs1:/tmp/cvs-serv12992/modules/core/src/com/babeldoc/core/pipeline
Modified Files:
Tag: V1-2
PipelineDocument.java
Log Message:
Added a getDocumentAsString() method, to complement the toString() changes earlier.
Index: PipelineDocument.java
===================================================================
RCS file: /cvsroot/babeldoc/babeldoc/modules/core/src/com/babeldoc/core/pipeline/PipelineDocument.java,v
retrieving revision 1.16
retrieving revision 1.16.4.1
diff -C2 -d -r1.16 -r1.16.4.1
*** PipelineDocument.java 8 Sep 2003 22:48:44 -0000 1.16
--- PipelineDocument.java 28 Dec 2003 21:45:41 -0000 1.16.4.1
***************
*** 422,425 ****
--- 422,434 ----
/**
+ * Return the document to a string
+ *
+ * @return String the current document as a String
+ */
+ public String getDocumentAsString() {
+ return new String(buffer);
+ }
+
+ /**
* Kinda clone
*
|
|
From: Dejan K. <dej...@ya...> - 2003-12-28 20:38:59
|
The only problem I see here is that toString was used in previous versions for getting document as String. There are examples in documentation where toString is used this way. I wrote many pipelines which use toString method for accessing content, too. On the other hand I agree with Bruce and Mike that toString() should return full state of object as String - not just content. Note that currently (in 1.2 release) there is no way to access content of document as String so whatever option we choose - it should be implemented in 1.2 release too, not just 1.3 (1.4 stable). Dejan P.S. I fixes few bugs in Scanner module but I have updated only HEAD branch. I will update 1.2 branch too, and we can start thinking about 1.2.1 bugfix release. --- Bruce McDonald <br...@mc...> wrote: > Mike, > > Good to see you back. > > I completely agree with you here. Your name looks > perfect. > > regards, > Bruce. > > On Saturday 27 December 2003 01:20 pm, Michael > Ansley wrote: > > Hi, Bruce, > > > > I noticed the discussion on the users list > regarding the > > PipelineDocument.toString() method. In the > absence of other > > suggestions, I'd like to suggest that: > > > > a) toString() stay as it is, because I think that > any toString() method > > should completely describe the object it's called > on, > > > > b) we create a new method, say documentToString() > or > > getDocumentAsString(), which contains the original > toString() > > functionality. > > > > I'm disinclined to think of this as a bug, and as > such, I don't see any > > reason for 1.2 to revert to the old behaviour, > although others may > > disagree. However, I would prefer to see 1.3 > follow the suggestion > > outlined above. > > > > Thoughts... > > > > Any objections to me creating the new method in > 1.3? Preference for a > > name? > > > > > > MikeA > > > ------------------------------------------------------- > This SF.net email is sponsored by: IBM Linux > Tutorials. > Become an expert in LINUX or just sharpen your > skills. Sign up for IBM's > Free Linux Tutorials. Learn everything from the > bash shell to sys admin. > Click now! > http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click > _______________________________________________ > Babeldoc-devel mailing list > Bab...@li... > https://lists.sourceforge.net/lists/listinfo/babeldoc-devel __________________________________ Do you Yahoo!? New Yahoo! Photos - easier uploading and sharing. http://photos.yahoo.com/ |
|
From: Bruce M. <br...@mc...> - 2003-12-28 13:54:52
|
Mike, Good to see you back. I completely agree with you here. Your name looks perfect. regards, Bruce. On Saturday 27 December 2003 01:20 pm, Michael Ansley wrote: > Hi, Bruce, > > I noticed the discussion on the users list regarding the > PipelineDocument.toString() method. In the absence of other > suggestions, I'd like to suggest that: > > a) toString() stay as it is, because I think that any toString() method > should completely describe the object it's called on, > > b) we create a new method, say documentToString() or > getDocumentAsString(), which contains the original toString() > functionality. > > I'm disinclined to think of this as a bug, and as such, I don't see any > reason for 1.2 to revert to the old behaviour, although others may > disagree. However, I would prefer to see 1.3 follow the suggestion > outlined above. > > Thoughts... > > Any objections to me creating the new method in 1.3? Preference for a > name? > > > MikeA |
|
From: <tr...@us...> - 2003-12-26 18:14:02
|
Update of /cvsroot/babeldoc/babeldoc/modules/conversion/src/com/babeldoc/conversion/flatfile
In directory sc8-pr-cvs1:/tmp/cvs-serv24773/modules/conversion/src/com/babeldoc/conversion/flatfile
Modified Files:
Tag: V1-2
FlatFileConverter.java
Log Message:
column error in the substring
Index: FlatFileConverter.java
===================================================================
RCS file: /cvsroot/babeldoc/babeldoc/modules/conversion/src/com/babeldoc/conversion/flatfile/FlatFileConverter.java,v
retrieving revision 1.2
retrieving revision 1.2.4.1
diff -C2 -d -r1.2 -r1.2.4.1
*** FlatFileConverter.java 30 Oct 2003 00:15:56 -0000 1.2
--- FlatFileConverter.java 26 Dec 2003 18:13:59 -0000 1.2.4.1
***************
*** 1,438 ****
! package com.babeldoc.conversion.flatfile;
!
! import com.babeldoc.conversion.ConversionException;
! import com.babeldoc.core.I18n;
! import com.babeldoc.core.NameValuePair;
! import com.mindprod.csv.CSVReader;
! import org.dom4j.Document;
! import org.dom4j.DocumentFactory;
! import org.dom4j.Element;
!
! import java.io.*;
!
! /**
! */
! public class FlatFileConverter {
! protected ConversionUnmarshaller unmarshaller;
! private Document document;
!
! /**
! * Construct - this requires an unmarshaller which governs the conversion
! * of the flat file.
! *
! * @param unmarshaller
! */
! public FlatFileConverter(ConversionUnmarshaller unmarshaller) {
! this.unmarshaller = unmarshaller;
! }
!
! /**
! * handle csv conversions. Watch the errors and make sure that xml start and
! * end tags getChild handled correctly.
! *
! * @param is the data
! */
! public Document toXml(InputStream is) {
! BufferedReader reader = new BufferedReader(new InputStreamReader(is));
! boolean carryOn = true;
! this.setUnmarshaller(unmarshaller);
!
! document = DocumentFactory.getInstance().createDocument();
! Element root = getDocument().addElement(getUnmarshaller().getRootElement());
! try {
! doSkipLines(reader, getUnmarshaller().getTopSkip());
!
! while (carryOn) {
! String[] paragraph = getParagraph(reader);
!
! if (paragraph == null) {
! break;
! }
!
! // Handle line-segments
! if (getUnmarshaller().getConversionType() == ConversionUnmarshaller.LINESEG_CONVERSION) {
! handleSegmentedLine(root, paragraph);
! } else {
! handleNonSegmented(root, paragraph);
! }
!
! carryOn = doSkipLines(reader, getUnmarshaller().getInterParagraphSkip());
! }
! } catch (Exception e) {
! errorComment(root, e);
! }
! return document;
! }
!
! /**
! * Set the unmarshaller
! *
! * @param unmarshaller the ConversionXmlUnmarshaller to use.
! */
! public void setUnmarshaller(ConversionUnmarshaller unmarshaller) {
! this.unmarshaller = unmarshaller;
! }
!
! /**
! * Get the unmarshaller
! *
! * @return the unmarshaller
! */
! public ConversionUnmarshaller getUnmarshaller() {
! return unmarshaller;
! }
!
! /**
! * Convert the data. Depending on the setting of the type in the
! * unmarshaller the different converters getChild called.
! *
! * @param element the element underwhich to add the new elements (!!!)
! * @param para is the array of strings
! *
! * @throws com.babeldoc.conversion.ConversionException DOCUMENT ME!
! */
! public void convert(Element element, String[] para) throws ConversionException {
! if (getUnmarshaller().getConversionType() == ConversionUnmarshaller.CSV_CONVERSION) {
! convertCsv(element, para, getUnmarshaller().getFields());
! } else if (getUnmarshaller().getConversionType() == ConversionUnmarshaller.LINE_CONVERSION) {
! convertLine(element, para, getUnmarshaller().getFields());
! } else if (getUnmarshaller().getConversionType() == ConversionUnmarshaller.PARA_CONVERSION) {
! convertPara(element, para, getUnmarshaller().getFields());
! } else {
! throw new ConversionException(I18n.get("conversion.007"));
! }
! }
!
! /**
! * Skip the number of lines at the top of the file.
! *
! * @param reader DOCUMENT ME!
! * @param numToSkip DOCUMENT ME!
! *
! * @return more lines found??
! */
! protected boolean doSkipLines(BufferedReader reader, int numToSkip) {
! for (int i = 0; i < numToSkip; ++i) {
! if (readLine(reader) == null) {
! return false;
! }
! }
! return true;
! }
!
! /**
! * Add an error comment right here.
! *
! * @param element
! * @param e
! */
! protected void errorComment(Element element, Exception e) {
! e.printStackTrace();
! element.addComment(e.toString());
! }
! /**
! * read the line from the input stream.
! *
! * @param reader the input stream.
! *
! * @return return null if no more lines found, else return the line.
! */
! protected static String readLine(BufferedReader reader) {
! try {
! return reader.readLine();
! } catch (Exception e) {
! return null;
! }
! }
!
! /**
! * Scan the input for all the lines in a paragraph and return them
! *
! * @param reader the input stream
! *
! * @return the paragraph of lines OR NULL if lines ran out before end.
! */
! protected String[] getParagraph(BufferedReader reader) {
! String[] lines = new String[getUnmarshaller().getLinesPerPara()];
!
! for (int i = 0; i < lines.length; ++i) {
! String line = readLine(reader);
!
! if (line != null) {
! lines[i] = trimLine(line);
! } else {
! return null;
! }
! }
!
! return lines;
! }
!
! /**
! * Convert from csv format. Simple enough. Things to watch for: Differing
! * number of tokens in input and configuration and if the configuration file
! * duplicate field numbers are found.
! *
! * @param row the row element to add the elements to.
! * @param para the array of lines (only one line expected)
! * @param fields DOCUMENT ME!
! *
! * @throws com.babeldoc.conversion.ConversionException DOCUMENT ME!
! */
! protected void convertCsv(Element row, String[] para, FieldData[] fields)
! throws ConversionException {
! if (para.length != 1) {
! throw new ConversionException(I18n.get("conversion.001"));
! }
!
! char separator = ',';
! if(this.getUnmarshaller().getFieldSeparator()!=null) {
! separator = this.getUnmarshaller().getFieldSeparator().charAt(0);
! }
!
! for(int l=0; l < para.length; ++l) {
! CSVReader csvreader = new CSVReader(new StringReader(para[l]),
! separator, '\"', false, true);
! if(this.getUnmarshaller().getFieldSeparator()!=null) {
! }
! String[] ltokens = new String[0];
! try {
! ltokens = csvreader.getAllFieldsInLine();
! } catch (IOException e) {
! e.printStackTrace(); //This should never happen
! }
!
! if (ltokens != null) {
! NameValuePair[] pairs = new NameValuePair[ltokens.length];
!
! for (int i = 0; i < fields.length; ++i) {
! FieldData field = fields[i];
! String name = field.name;
! int fieldNum = field.number - 1;
!
! // Make sure that we dont try and reference an ltoken in
! // the input stream from the field number that does not exist
! // And protect against data duplication.
! if (fieldNum > pairs.length-1) {
! throw new ConversionException(I18n.get("conversion.002",
! new Integer(getUnmarshaller().getFields().length),
! new Integer(ltokens.length)));
! } else if (pairs[fieldNum] != null) {
! throw new ConversionException(I18n.get("conversion.003", name));
! } else {
! pairs[fieldNum] = new NameValuePair(name, ltokens[fieldNum]);
! }
! }
! addElements(row, pairs);
! }
! }
! }
!
! private static void addElements(Element row, NameValuePair[] pairs) {
! for(int j = 0; j < pairs.length; ++j) {
! if(pairs[j]!=null) {
! Element element = row.addElement(pairs[j].getName());
! element.addText(pairs[j].getValue());
! }
! }
! }
!
! /**
! * Convert from lines.
! *
! * @param row the row element to add the field elements to.
! * @param para the paragraph of input data
! * @param fields the fields to extract from the input data
! *
! * @throws com.babeldoc.conversion.ConversionException DOCUMENT ME!
! */
! protected void convertLine(Element row, String[] para, FieldData[] fields)
! throws ConversionException {
! if (para.length != 1) {
! throw new ConversionException(I18n.get("conversion.004"));
! }
!
! String line = para[0];
! NameValuePair[] pairs = new NameValuePair[fields.length];
!
! for (int i = 0; i < fields.length; ++i) {
! FieldData field = fields[i];
! String name = field.name;
! int start = field.column - 1;
! int width = field.width;
! int end = start + width;
!
! // Check overruns.
! String value = null;
!
! // Handle negative starts bug: 741190 ]
! if (start < 0) {
! start = 0;
! }
!
! // Ok getChild data - first check if we can getChild all the data
! if (end > line.length()) {
! // can we getChild any of it?
! if (line.length() < start) {
! value = "";
! }
! // Well, we getChild what we can.
! else {
! value = line.substring(start);
! }
! } else {
! value = line.substring(start, end);
! }
!
! pairs[i] = new NameValuePair(name, value);
! }
! addElements(row, pairs);
! }
!
! /**
! * Convert from para. Things to watch are that the field does not exceed the
! * current line length or the number of rows. Other than that this is a
! * simple piece of code.
! *
! * @param rowElement the row element to which to add the field elements
! * @param para the paragraph of input
! * @param fields DOCUMENT ME!
! *
! * @throws com.babeldoc.conversion.ConversionException DOCUMENT ME!
! */
! protected void convertPara(Element rowElement, String[] para, FieldData[] fields)
! throws ConversionException {
! NameValuePair[] pairs = new NameValuePair[fields.length];
!
! for (int i = 0; i < fields.length; ++i) {
! FieldData field = fields[i];
! String name = field.name;
! int row = field.row - 1;
! int start = field.column - 1;
! int width = field.width;
! int end = start + width;
!
! // Check overruns.
! if (row > para.length) {
! throw new ConversionException(I18n.get("conversion.005", name));
! } else if (end > para[row].length()) {
! throw new ConversionException(I18n.get("conversion.006", name));
! }
!
! String value = para[row].substring(start, end);
! pairs[i] = new NameValuePair(name, value);
! }
!
! addElements(rowElement, pairs);
! }
!
! /**
! * Trim the left margin from the line.
! *
! * @param input the line to trim
! *
! * @return the trimmed line
! */
! protected String trimLine(String input) {
! int leftMargin = unmarshaller.getLeftMargin();
!
! if (leftMargin == 0) {
! return input;
! } else if (leftMargin >= input.length()) {
! return null;
! } else {
! return input.substring(leftMargin);
! }
! }
!
! /**
! * Handle a line segment.
! *
! * @param startElement add a line segment
! * @param lineSegment
! */
! private Element handleLineSegmentElement(Element startElement, LineSegmentData lineSegment) {
! if (lineSegment.startGroup != null) {
! startElement = startElement.addElement(lineSegment.startGroup);
! }
! return startElement.addElement(lineSegment.name);
! }
!
! /**
! * Handle non-segmented paragraph
! *
! * @param root the root element
! * @param paragraph the paragraph
! */
! private void handleNonSegmented(Element root, String[] paragraph) {
! Element rowElement = root.addElement(getUnmarshaller().getRowElement());
!
! try {
! convert(rowElement, paragraph);
! } catch (ConversionException ce) {
! errorComment(rowElement, ce);
! }
! }
!
! /**
! * Handle segmentline paragraph
! *
! * @param element element to start doing this segmented line
! * @param para the paragraph
! */
! private void handleSegmentedLine(Element element, String[] para) {
! String line = para[0];
! int numSegments = getUnmarshaller().getLineSegments().length;
!
! for (int i = 0; i < numSegments; ++i) {
! LineSegmentData lineSegment = getUnmarshaller().getLineSegments()[i];
! int column = lineSegment.column - 1;
! int width = lineSegment.width;
! String value = lineSegment.value;
!
! if ((line.length() > (column + width)) &&
! line.substring(column, width).equals(value)) {
! Element segmentElement = handleLineSegmentElement(element, lineSegment);
!
! try {
! handlineLineSegmentElementData(segmentElement, lineSegment, para);
!
! break;
! } catch (Exception e) {
! errorComment(segmentElement, e);
! } finally {
! }
! }
! }
! }
!
! /**
! * Handle the two kinds of line segments...
! *
! * @param lineSegment
! * @param para
! *
! * @throws com.babeldoc.conversion.ConversionException
! */
! private void handlineLineSegmentElementData(Element element, LineSegmentData lineSegment,
! String[] para) throws ConversionException {
! FieldData[] fields = lineSegment.fields;
!
! if (lineSegment.conversionType == ConversionUnmarshaller.CSV_CONVERSION) {
! convertCsv(element, para, fields);
! } else if (lineSegment.conversionType == ConversionUnmarshaller.LINE_CONVERSION) {
! convertLine(element, para, fields);
! } else {
! throw new ConversionException(I18n.get("conversion.007"));
! }
! }
!
! public Document getDocument() {
! return document;
! }
!
! public void setDocument(Document document) {
! this.document = document;
! }
!
! }
--- 1,438 ----
! package com.babeldoc.conversion.flatfile;
!
! import com.babeldoc.conversion.ConversionException;
! import com.babeldoc.core.I18n;
! import com.babeldoc.core.NameValuePair;
! import com.mindprod.csv.CSVReader;
! import org.dom4j.Document;
! import org.dom4j.DocumentFactory;
! import org.dom4j.Element;
!
! import java.io.*;
!
! /**
! */
! public class FlatFileConverter {
! protected ConversionUnmarshaller unmarshaller;
! private Document document;
!
! /**
! * Construct - this requires an unmarshaller which governs the conversion
! * of the flat file.
! *
! * @param unmarshaller
! */
! public FlatFileConverter(ConversionUnmarshaller unmarshaller) {
! this.unmarshaller = unmarshaller;
! }
!
! /**
! * handle csv conversions. Watch the errors and make sure that xml start and
! * end tags getChild handled correctly.
! *
! * @param is the data
! */
! public Document toXml(InputStream is) {
! BufferedReader reader = new BufferedReader(new InputStreamReader(is));
! boolean carryOn = true;
! this.setUnmarshaller(unmarshaller);
!
! document = DocumentFactory.getInstance().createDocument();
! Element root = getDocument().addElement(getUnmarshaller().getRootElement());
! try {
! doSkipLines(reader, getUnmarshaller().getTopSkip());
!
! while (carryOn) {
! String[] paragraph = getParagraph(reader);
!
! if (paragraph == null) {
! break;
! }
!
! // Handle line-segments
! if (getUnmarshaller().getConversionType() == ConversionUnmarshaller.LINESEG_CONVERSION) {
! handleSegmentedLine(root, paragraph);
! } else {
! handleNonSegmented(root, paragraph);
! }
!
! carryOn = doSkipLines(reader, getUnmarshaller().getInterParagraphSkip());
! }
! } catch (Exception e) {
! errorComment(root, e);
! }
! return document;
! }
!
! /**
! * Set the unmarshaller
! *
! * @param unmarshaller the ConversionXmlUnmarshaller to use.
! */
! public void setUnmarshaller(ConversionUnmarshaller unmarshaller) {
! this.unmarshaller = unmarshaller;
! }
!
! /**
! * Get the unmarshaller
! *
! * @return the unmarshaller
! */
! public ConversionUnmarshaller getUnmarshaller() {
! return unmarshaller;
! }
!
! /**
! * Convert the data. Depending on the setting of the type in the
! * unmarshaller the different converters getChild called.
! *
! * @param element the element underwhich to add the new elements (!!!)
! * @param para is the array of strings
! *
! * @throws com.babeldoc.conversion.ConversionException DOCUMENT ME!
! */
! public void convert(Element element, String[] para) throws ConversionException {
! if (getUnmarshaller().getConversionType() == ConversionUnmarshaller.CSV_CONVERSION) {
! convertCsv(element, para, getUnmarshaller().getFields());
! } else if (getUnmarshaller().getConversionType() == ConversionUnmarshaller.LINE_CONVERSION) {
! convertLine(element, para, getUnmarshaller().getFields());
! } else if (getUnmarshaller().getConversionType() == ConversionUnmarshaller.PARA_CONVERSION) {
! convertPara(element, para, getUnmarshaller().getFields());
! } else {
! throw new ConversionException(I18n.get("conversion.007"));
! }
! }
!
! /**
! * Skip the number of lines at the top of the file.
! *
! * @param reader DOCUMENT ME!
! * @param numToSkip DOCUMENT ME!
! *
! * @return more lines found??
! */
! protected boolean doSkipLines(BufferedReader reader, int numToSkip) {
! for (int i = 0; i < numToSkip; ++i) {
! if (readLine(reader) == null) {
! return false;
! }
! }
! return true;
! }
!
! /**
! * Add an error comment right here.
! *
! * @param element
! * @param e
! */
! protected void errorComment(Element element, Exception e) {
! e.printStackTrace();
! element.addComment(e.toString());
! }
! /**
! * read the line from the input stream.
! *
! * @param reader the input stream.
! *
! * @return return null if no more lines found, else return the line.
! */
! protected static String readLine(BufferedReader reader) {
! try {
! return reader.readLine();
! } catch (Exception e) {
! return null;
! }
! }
!
! /**
! * Scan the input for all the lines in a paragraph and return them
! *
! * @param reader the input stream
! *
! * @return the paragraph of lines OR NULL if lines ran out before end.
! */
! protected String[] getParagraph(BufferedReader reader) {
! String[] lines = new String[getUnmarshaller().getLinesPerPara()];
!
! for (int i = 0; i < lines.length; ++i) {
! String line = readLine(reader);
!
! if (line != null) {
! lines[i] = trimLine(line);
! } else {
! return null;
! }
! }
!
! return lines;
! }
!
! /**
! * Convert from csv format. Simple enough. Things to watch for: Differing
! * number of tokens in input and configuration and if the configuration file
! * duplicate field numbers are found.
! *
! * @param row the row element to add the elements to.
! * @param para the array of lines (only one line expected)
! * @param fields DOCUMENT ME!
! *
! * @throws com.babeldoc.conversion.ConversionException DOCUMENT ME!
! */
! protected void convertCsv(Element row, String[] para, FieldData[] fields)
! throws ConversionException {
! if (para.length != 1) {
! throw new ConversionException(I18n.get("conversion.001"));
! }
!
! char separator = ',';
! if(this.getUnmarshaller().getFieldSeparator()!=null) {
! separator = this.getUnmarshaller().getFieldSeparator().charAt(0);
! }
!
! for(int l=0; l < para.length; ++l) {
! CSVReader csvreader = new CSVReader(new StringReader(para[l]),
! separator, '\"', false, true);
! if(this.getUnmarshaller().getFieldSeparator()!=null) {
! }
! String[] ltokens = new String[0];
! try {
! ltokens = csvreader.getAllFieldsInLine();
! } catch (IOException e) {
! e.printStackTrace(); //This should never happen
! }
!
! if (ltokens != null) {
! NameValuePair[] pairs = new NameValuePair[ltokens.length];
!
! for (int i = 0; i < fields.length; ++i) {
! FieldData field = fields[i];
! String name = field.name;
! int fieldNum = field.number - 1;
!
! // Make sure that we dont try and reference an ltoken in
! // the input stream from the field number that does not exist
! // And protect against data duplication.
! if (fieldNum > pairs.length-1) {
! throw new ConversionException(I18n.get("conversion.002",
! new Integer(getUnmarshaller().getFields().length),
! new Integer(ltokens.length)));
! } else if (pairs[fieldNum] != null) {
! throw new ConversionException(I18n.get("conversion.003", name));
! } else {
! pairs[fieldNum] = new NameValuePair(name, ltokens[fieldNum]);
! }
! }
! addElements(row, pairs);
! }
! }
! }
!
! private static void addElements(Element row, NameValuePair[] pairs) {
! for(int j = 0; j < pairs.length; ++j) {
! if(pairs[j]!=null) {
! Element element = row.addElement(pairs[j].getName());
! element.addText(pairs[j].getValue());
! }
! }
! }
!
! /**
! * Convert from lines.
! *
! * @param row the row element to add the field elements to.
! * @param para the paragraph of input data
! * @param fields the fields to extract from the input data
! *
! * @throws com.babeldoc.conversion.ConversionException DOCUMENT ME!
! */
! protected void convertLine(Element row, String[] para, FieldData[] fields)
! throws ConversionException {
! if (para.length != 1) {
! throw new ConversionException(I18n.get("conversion.004"));
! }
!
! String line = para[0];
! NameValuePair[] pairs = new NameValuePair[fields.length];
!
! for (int i = 0; i < fields.length; ++i) {
! FieldData field = fields[i];
! String name = field.name;
! int start = field.column - 1;
! int width = field.width;
! int end = start + width;
!
! // Check overruns.
! String value = null;
!
! // Handle negative starts bug: 741190 ]
! if (start < 0) {
! start = 0;
! }
!
! // Ok getChild data - first check if we can getChild all the data
! if (end > line.length()) {
! // can we getChild any of it?
! if (line.length() < start) {
! value = "";
! }
! // Well, we getChild what we can.
! else {
! value = line.substring(start);
! }
! } else {
! value = line.substring(start, end);
! }
!
! pairs[i] = new NameValuePair(name, value);
! }
! addElements(row, pairs);
! }
!
! /**
! * Convert from para. Things to watch are that the field does not exceed the
! * current line length or the number of rows. Other than that this is a
! * simple piece of code.
! *
! * @param rowElement the row element to which to add the field elements
! * @param para the paragraph of input
! * @param fields DOCUMENT ME!
! *
! * @throws com.babeldoc.conversion.ConversionException DOCUMENT ME!
! */
! protected void convertPara(Element rowElement, String[] para, FieldData[] fields)
! throws ConversionException {
! NameValuePair[] pairs = new NameValuePair[fields.length];
!
! for (int i = 0; i < fields.length; ++i) {
! FieldData field = fields[i];
! String name = field.name;
! int row = field.row - 1;
! int start = field.column - 1;
! int width = field.width;
! int end = start + width;
!
! // Check overruns.
! if (row > para.length) {
! throw new ConversionException(I18n.get("conversion.005", name));
! } else if (end > para[row].length()) {
! throw new ConversionException(I18n.get("conversion.006", name));
! }
!
! String value = para[row].substring(start, end);
! pairs[i] = new NameValuePair(name, value);
! }
!
! addElements(rowElement, pairs);
! }
!
! /**
! * Trim the left margin from the line.
! *
! * @param input the line to trim
! *
! * @return the trimmed line
! */
! protected String trimLine(String input) {
! int leftMargin = unmarshaller.getLeftMargin();
!
! if (leftMargin == 0) {
! return input;
! } else if (leftMargin >= input.length()) {
! return null;
! } else {
! return input.substring(leftMargin);
! }
! }
!
! /**
! * Handle a line segment.
! *
! * @param startElement add a line segment
! * @param lineSegment
! */
! private Element handleLineSegmentElement(Element startElement, LineSegmentData lineSegment) {
! if (lineSegment.startGroup != null) {
! startElement = startElement.addElement(lineSegment.startGroup);
! }
! return startElement.addElement(lineSegment.name);
! }
!
! /**
! * Handle non-segmented paragraph
! *
! * @param root the root element
! * @param paragraph the paragraph
! */
! private void handleNonSegmented(Element root, String[] paragraph) {
! Element rowElement = root.addElement(getUnmarshaller().getRowElement());
!
! try {
! convert(rowElement, paragraph);
! } catch (ConversionException ce) {
! errorComment(rowElement, ce);
! }
! }
!
! /**
! * Handle segmentline paragraph
! *
! * @param element element to start doing this segmented line
! * @param para the paragraph
! */
! private void handleSegmentedLine(Element element, String[] para) {
! String line = para[0];
! int numSegments = getUnmarshaller().getLineSegments().length;
!
! for (int i = 0; i < numSegments; ++i) {
! LineSegmentData lineSegment = getUnmarshaller().getLineSegments()[i];
! int column = lineSegment.column - 1;
! int width = lineSegment.width;
! String value = lineSegment.value;
!
! if ((line.length() > (column + width)) &&
! line.substring(column, column+width).equals(value)) {
! Element segmentElement = handleLineSegmentElement(element, lineSegment);
!
! try {
! handlineLineSegmentElementData(segmentElement, lineSegment, para);
!
! break;
! } catch (Exception e) {
! errorComment(segmentElement, e);
! } finally {
! }
! }
! }
! }
!
! /**
! * Handle the two kinds of line segments...
! *
! * @param lineSegment
! * @param para
! *
! * @throws com.babeldoc.conversion.ConversionException
! */
! private void handlineLineSegmentElementData(Element element, LineSegmentData lineSegment,
! String[] para) throws ConversionException {
! FieldData[] fields = lineSegment.fields;
!
! if (lineSegment.conversionType == ConversionUnmarshaller.CSV_CONVERSION) {
! convertCsv(element, para, fields);
! } else if (lineSegment.conversionType == ConversionUnmarshaller.LINE_CONVERSION) {
! convertLine(element, para, fields);
! } else {
! throw new ConversionException(I18n.get("conversion.007"));
! }
! }
!
! public Document getDocument() {
! return document;
! }
!
! public void setDocument(Document document) {
! this.document = document;
! }
!
! }
|
|
From: <de...@us...> - 2003-12-25 15:14:03
|
Update of /cvsroot/babeldoc/babeldoc/modules/scanner/src/com/babeldoc/scanner/worker In directory sc8-pr-cvs1:/tmp/cvs-serv19537/babeldoc/modules/scanner/src/com/babeldoc/scanner/worker Modified Files: MailboxScanner.java Log Message: Fixed bug introduced after Hans Benedict fixed bug he introduced ;) If charset is null then NPE is thrown from InputStreamReader constructor Index: MailboxScanner.java =================================================================== RCS file: /cvsroot/babeldoc/babeldoc/modules/scanner/src/com/babeldoc/scanner/worker/MailboxScanner.java,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** MailboxScanner.java 25 Dec 2003 14:15:50 -0000 1.31 --- MailboxScanner.java 25 Dec 2003 15:14:00 -0000 1.32 *************** *** 6,26 **** * * 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, --- 6,25 ---- * * 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, *************** *** 333,338 **** // Code donated by Hans Benedict. MimeType type = new MimeType(part.getContentType()); ! BufferedReader reader = new BufferedReader(new InputStreamReader(part ! .getInputStream(), type.getParameter("charset"))); StringBuffer result = new StringBuffer(); String line; --- 332,343 ---- // Code donated by Hans Benedict. MimeType type = new MimeType(part.getContentType()); ! BufferedReader reader = null; ! String charset = type.getParameter("charset"); ! if (charset != null) { ! reader = new BufferedReader(new InputStreamReader(part.getInputStream(), ! charset)); ! } else { ! reader = new BufferedReader(new InputStreamReader(part.getInputStream())); ! } StringBuffer result = new StringBuffer(); String line; |
|
From: <de...@us...> - 2003-12-25 14:15:53
|
Update of /cvsroot/babeldoc/babeldoc/modules/scanner/config/i18n In directory sc8-pr-cvs1:/tmp/cvs-serv11953/babeldoc/modules/scanner/config/i18n Modified Files: messages.properties Log Message: Fixed bugs #865417 and #865679 - Throwing exceptions during processing a message will not stop processing other messages - Binary attachments are now handled properly (you should set binary=true) in scanner config - Also new config option has been added to MailboxScanner - deleteInvalid which can be used for deleting messages that are not valid (that raise exceptions) USE THIS OPTION WITH CAUTION since it can be destructive. It can be usefull when you know that valid e-mails does not throw exceptions and you want to delete all other mails Index: messages.properties =================================================================== RCS file: /cvsroot/babeldoc/babeldoc/modules/scanner/config/i18n/messages.properties,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** messages.properties 13 Oct 2003 07:24:39 -0000 1.18 --- messages.properties 25 Dec 2003 14:15:50 -0000 1.19 *************** *** 95,98 **** --- 95,99 ---- scanner.MailboxScannerInfo.option.toFilter=Regular expression which, if matched by the To field, causes the message to be processed scanner.MailboxScannerInfo.option.subjectFilter=Regular expression which, if matched by the Subject field, causes the message to be processed + scanner.MailboxScannerInfo.option.deleteInvalid=Delete messages that are not valid (invalid address etc.) and not processed by Babeldoc scanner.ExternalApplicationScanner.description=The ExternalApplicationScanner runs an external application and pipes the standard output from that application into the pipeline. |