Update of /cvsroot/babeldoc/babeldoc/modules/conversion/src/com/babeldoc/conversion/flatfile In directory sc8-pr-cvs1:/tmp/cvs-serv25588/src/com/babeldoc/conversion/flatfile Added Files: ConversionUnmarshaller.java FieldData.java FlatFileConversionClient.java FlatFileConverter.java LineSegmentData.java Log Message: Lots of rearrangement of the conversion module - now using dom4j in the flatfile code - moved packages around. --- NEW FILE: ConversionUnmarshaller.java --- /* ==================================================================== * 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/flatfile/ConversionUnmarshaller.java,v 1.1 2003/07/19 13:16:47 triphop Exp $ * $DateTime$ * $Author: triphop $ * */ package com.babeldoc.conversion.flatfile; /** * Interface that conversion unmarshallers must implement. The definitive * implementation of this class is DigesterConversionUnmarshaller. No further * implementations are necessary and certainly not planned. The reason for * this class stems from when the old SAX based conversion unmarshaller was * replaced with the new digester and I needed to swap the two * interchangeably. * * @author bmcdonald * @version 1.0 */ public interface ConversionUnmarshaller { /** What kind of file is this? */ public static final int CSV_CONVERSION = 0; public static final int LINE_CONVERSION = 1; public static final int PARA_CONVERSION = 2; public static final int LINESEG_CONVERSION = 3; /** * Get the conversion type * * @return */ public int getConversionType(); /** * Get the field separator for csv fields. * * @return */ public String getFieldSeparator(); /** * Get the field data * * @return */ public FieldData[] getFields(); /** * get the interparagraph skip * * @return */ public int getInterParagraphSkip(); /** * get the characters to skip from the left * * @return */ public int getLeftMargin(); /** * Get the line segments. * * @return */ public LineSegmentData[] getLineSegments(); /** * get the line separator * * @return */ public String getLineSeparator(); /** * Get the lines per para * * @return */ public int getLinesPerPara(); /** * Get the root element * * @return */ public String getRootElement(); /** * get the row element * * @return */ public String getRowElement(); /** * Get the lines to skip * * @return */ public int getTopSkip(); } --- NEW FILE: FieldData.java --- /* ==================================================================== * 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/flatfile/FieldData.java,v 1.1 2003/07/19 13:16:47 triphop Exp $ * $DateTime$ * $Author: triphop $ * */ package com.babeldoc.conversion.flatfile; import org.apache.commons.lang.builder.ToStringBuilder; /** * Simple utility class to hold all the field data. This is one of the two * main data objects in the conversion process. * * @author Bmcdonald * @version 1.0 */ public class FieldData { public String name; public int column; public int number; public int row; public int width; /** * Useful for debugging. * * @return */ public String toString() { return new ToStringBuilder(this).append("name", name).append("row", row) .append("column", column) .append("width", width) .append("number", number).toString(); } } --- NEW FILE: FlatFileConversionClient.java --- /* ==================================================================== * 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/flatfile/FlatFileConversionClient.java,v 1.1 2003/07/19 13:16:47 triphop Exp $ * $DateTime$ * $Author: triphop $ * */ package com.babeldoc.conversion.flatfile; import com.babeldoc.conversion.ConversionException; import com.babeldoc.conversion.ConversionHelper; import com.babeldoc.conversion.flatfile.digester.DigesterConversionUnmarshaller; 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 org.dom4j.Document; import java.io.IOException; import java.io.InputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; /** * <p> * Do conversions based on conversion xml file. This is the entry point for * running xml based conversions. The conversions xml file is converted to a * set of value objects by the Unmarshaller. These classes carry the data * controlling the conversion process. * </p> * * <p> * The actual conversion xml is specied by a schema xml file, * readme/schema/conversion.xsd * </p> * * @author Bmcdonald * @version 1.0 */ public class FlatFileConversionClient extends BabeldocCommand { protected static final String NULL = ""; protected ConversionUnmarshaller unmarshaller; private Document document; /** * Construct this object and call the super with the argument for setting up * the conversion client. * * @param args */ public FlatFileConversionClient(String[] args) { super("conversion", I18n.get("conversion.009"), args); } /** * Main method. * * @param commandline DOCUMENT ME! */ public void execute(CommandLine commandline) { InputStream in = null; InputStream conf = null; if (commandline.hasOption('c')) { String convFile = commandline.getOptionValue('c'); try { conf = ResourceLoader.getResourceStream(convFile); } catch (IOException e) { LogService.getInstance().logError(I18n.get( "conversion.exception.io.convfile", convFile), e); return; } } 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) && (conf != null)) { PrintWriter writer = new PrintWriter(new OutputStreamWriter(System.out)); try { ConversionHelper.render(new FlatFileConverter(new DigesterConversionUnmarshaller(conf)).toXml(in), System.out); } catch (ConversionException e) { LogService.getInstance().logError(e); } writer.flush(); writer.close(); } else { System.err.println(I18n.get("conversion.008")); } } /** * Main * * @param args the arguments */ public static void main(String[] args) { new FlatFileConversionClient(args); } /** * setup the options on the command line. * * @param options the options to access */ public void setupCommandLine(Options options) { super.setupCommandLine(options); LogService.getInstance(); options.addOption(OptionBuilder.isRequired().hasArg(true) .withDescription(I18n.get("conversion.010")) .withLongOpt("file").create('f')); options.addOption(OptionBuilder.isRequired().hasArg(true) .withDescription(I18n.get("conversion.011")) .withLongOpt("config").create('c')); } } --- NEW FILE: FlatFileConverter.java --- 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 get 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 get 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) { 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) { 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) { 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 get data - first check if we can get all the data if (end > line.length()) { // can we get any of it? if (line.length() < start) { value = ""; } // Well, we get 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; } } --- NEW FILE: LineSegmentData.java --- /* ==================================================================== * 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/flatfile/LineSegmentData.java,v 1.1 2003/07/19 13:16:47 triphop Exp $ * $DateTime$ * $Author: triphop $ * */ package com.babeldoc.conversion.flatfile; import org.apache.commons.lang.builder.ToStringBuilder; /** * Hold the configuration for each of the line segments. This one of the two * main data objects in the conversion process. * * @author Bmcdonald * @version 1.0 */ public class LineSegmentData { public String endGroup; public String name; public String startGroup; public String value; public FieldData[] fields; public int column; public int conversionType; public int width; /** * toXml to a string * * @return string */ public String toString() { return new ToStringBuilder(this).append("name", name) .append("column", column) .append("width", width) .append("conversionType", conversionType) .append("value", value) .append("startGroup", startGroup) .append("endGroup", endGroup) .append("fields", fields).toString(); } } |