|
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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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
|