Added a mutator to CSVFormat to change the trimming behavior at both ends

git-svn-id: https://svn.apache.org/repos/asf/commons/sandbox/csv/trunk@1298013 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Emmanuel Bourg 2012-03-07 16:32:36 +00:00
parent 00d0def695
commit 898b7f9629
2 changed files with 9 additions and 0 deletions

View File

@ -198,6 +198,13 @@ public class CSVFormat implements Cloneable, Serializable {
return format;
}
public CSVFormat withSurroundingSpacesIgnored(boolean surroundingSpacesIgnored) {
CSVFormat format = clone();
format.leadingSpacesIgnored = surroundingSpacesIgnored;
format.trailingSpacesIgnored = surroundingSpacesIgnored;
return format;
}
public boolean isUnicodeEscapesInterpreted() {
return unicodeEscapesInterpreted;
}

View File

@ -57,6 +57,8 @@ public class CSVFormatTest extends TestCase {
assertEquals(false, format.withLeadingSpacesIgnored(false).isLeadingSpacesIgnored());
assertEquals(false, format.withTrailingSpacesIgnored(false).isTrailingSpacesIgnored());
assertEquals(false, format.withSurroundingSpacesIgnored(false).isLeadingSpacesIgnored());
assertEquals(false, format.withSurroundingSpacesIgnored(false).isTrailingSpacesIgnored());
assertEquals(false, format.withEmptyLinesIgnored(false).isEmptyLinesIgnored());
assertEquals(false, format.withUnicodeEscapesInterpreted(false).isUnicodeEscapesInterpreted());
}