Return-Path: Delivered-To: apmail-commons-issues-archive@locus.apache.org Received: (qmail 98232 invoked from network); 24 Jun 2008 11:17:07 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 24 Jun 2008 11:17:07 -0000 Received: (qmail 17961 invoked by uid 500); 24 Jun 2008 11:17:07 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 17883 invoked by uid 500); 24 Jun 2008 11:17:07 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 17872 invoked by uid 99); 24 Jun 2008 11:17:07 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 24 Jun 2008 04:17:07 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 24 Jun 2008 11:16:25 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 214E5234C149 for ; Tue, 24 Jun 2008 04:16:45 -0700 (PDT) Message-ID: <1076987811.1214306205135.JavaMail.jira@brutus> Date: Tue, 24 Jun 2008 04:16:45 -0700 (PDT) From: "Mike Cordes (JIRA)" To: issues@commons.apache.org Subject: [jira] Created: (SANDBOX-243) CSVWriter.writeValue() not using value delimiter MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org CSVWriter.writeValue() not using value delimiter ------------------------------------------------ Key: SANDBOX-243 URL: https://issues.apache.org/jira/browse/SANDBOX-243 Project: Commons Sandbox Issue Type: Bug Components: CSV Affects Versions: Nightly Builds Reporter: Mike Cordes Priority: Minor Fix For: Nightly Builds CSVWriter.writeValue() only uses value delimiter if field values are fixed width. Here is the existing method: {code:title=CSVWriter.writeValue() error|borderStyle=solid} protected String writeValue(CSVField field, String value) throws Exception { if (config.isFixedWidth()) { if (value.length() < field.getSize()) { int fillPattern = config.getFill(); if (field.overrideFill()) { fillPattern = field.getFill(); } StringBuffer sb = new StringBuffer(); int fillSize = (field.getSize() - value.length()); char[] fill = new char[fillSize]; Arrays.fill(fill, config.getFillChar()); if (fillPattern == CSVConfig.FILLLEFT) { sb.append(fill); sb.append(value); value = sb.toString(); } else { // defaults to fillpattern FILLRIGHT when fixedwidth is used sb.append(value); sb.append(fill); value = sb.toString(); } } else if (value.length() > field.getSize()) { // value to big.. value = value.substring(0, field.getSize()); } if (!config.isValueDelimiterIgnored()) { // add the value delimiter.. value = config.getValueDelimiter()+value+config.getValueDelimiter(); } } return value; } {code} The _if (!config.isValueDelimiterIgnored())_ block should be removed from the _if (config.isFixedWidth())_ block, like so: {code:title=CSVWriter.writeValue() corrected|borderStyle=solid} protected String writeValue(CSVField field, String value) throws Exception { if (config.isFixedWidth()) { if (value.length() < field.getSize()) { int fillPattern = config.getFill(); if (field.overrideFill()) { fillPattern = field.getFill(); } StringBuffer sb = new StringBuffer(); int fillSize = (field.getSize() - value.length()); char[] fill = new char[fillSize]; Arrays.fill(fill, config.getFillChar()); if (fillPattern == CSVConfig.FILLLEFT) { sb.append(fill); sb.append(value); value = sb.toString(); } else { // defaults to fillpattern FILLRIGHT when fixedwidth is used sb.append(value); sb.append(fill); value = sb.toString(); } } else if (value.length() > field.getSize()) { // value to big.. value = value.substring(0, field.getSize()); } } if (!config.isValueDelimiterIgnored()) { // add the value delimiter.. value = config.getValueDelimiter()+value+config.getValueDelimiter(); } return value; } {code} -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.