You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Mike Cordes (JIRA)" <ji...@apache.org> on 2008/06/24 13:16:45 UTC
[jira] Created: (SANDBOX-243) CSVWriter.writeValue() not using
value delimiter
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.
[jira] Updated: (SANDBOX-243) CSVWriter.writeValue() not using
value delimiter
Posted by "Henri Yandell (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/SANDBOX-243?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Henri Yandell updated SANDBOX-243:
----------------------------------
Fix Version/s: (was: Nightly Builds)
CSV 1.0
Fix for 1.0 - assuming we keep this package in 1.0.
> 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: CSV 1.0
>
> Original Estimate: 0.08h
> Remaining Estimate: 0.08h
>
> 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 {color:blue}{{if (!config.isValueDelimiterIgnored())}}{color} block should be removed from the {color:blue}{{if (config.isFixedWidth())}}{color} 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.
[jira] Updated: (SANDBOX-243) CSVWriter.writeValue() not using
value delimiter
Posted by "Mike Cordes (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/SANDBOX-243?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Mike Cordes updated SANDBOX-243:
--------------------------------
Description:
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 {color:blue}{{if (!config.isValueDelimiterIgnored())}}{color} block should be removed from the {color:blue}{{if (config.isFixedWidth())}}{color} 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}
was:
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}
> 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
>
> Original Estimate: 0.08h
> Remaining Estimate: 0.08h
>
> 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 {color:blue}{{if (!config.isValueDelimiterIgnored())}}{color} block should be removed from the {color:blue}{{if (config.isFixedWidth())}}{color} 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.