Changeset 7722
- Timestamp:
- Jun 4, 2019, 1:36:40 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.15-stable/src/core/net/sf/basedb/util/parser/FlatFileParser.java
r7721 r7722 268 268 269 269 /** 270 If white space should be trimmed from data values or not. 271 Default is false. 272 @since 3.15.1 273 */ 274 private boolean trimWhiteSpace; 275 276 /** 270 277 The regular expression for matching the data footer line. 271 278 */ … … 511 518 { 512 519 this.trimQuotes = trimQuotes; 520 } 521 522 /** 523 Set a flag indicating if white-space should be trimmed from 524 start and end of data values. The default setting is false. 525 @param trimWhiteSpace TRUE to remove white-space, FALSE to keep them 526 @since 3.15.1 527 */ 528 public void setTrimWhiteSpace(boolean trimWhiteSpace) 529 { 530 this.trimWhiteSpace = trimWhiteSpace; 513 531 } 514 532 … … 947 965 lines.add(new Line(parsedLines, line, LineType.DATA)); 948 966 parsedDataLines = 1; 949 nextData = new Data(parsedLines, parsedDataLines, line, columns, emptyIsNull, nullIsNull );967 nextData = new Data(parsedLines, parsedDataLines, line, columns, emptyIsNull, nullIsNull, trimWhiteSpace); 950 968 } 951 969 } … … 1472 1490 if (excelSheet != null) 1473 1491 { 1474 nextData = new ExcelData(excelSheet, excelParsedLinesOffset, parsedLines, parsedDataLines, line, columns, emptyIsNull, nullIsNull );1492 nextData = new ExcelData(excelSheet, excelParsedLinesOffset, parsedLines, parsedDataLines, line, columns, emptyIsNull, nullIsNull, trimWhiteSpace); 1475 1493 } 1476 1494 else 1477 1495 { 1478 nextData = new Data(parsedLines, parsedDataLines, line, columns, emptyIsNull, nullIsNull );1496 nextData = new Data(parsedLines, parsedDataLines, line, columns, emptyIsNull, nullIsNull, trimWhiteSpace); 1479 1497 } 1480 1498 } … … 1897 1915 private final boolean emptyIsNull; 1898 1916 private final boolean nullIsNull; 1917 private final boolean trimWhiteSpace; 1899 1918 1900 1919 /** 1901 1920 Create a new data object. 1902 1921 */ 1903 private Data(int lineNo, int dataLineNo, String line, String[] columns, boolean emptyIsNull, boolean nullIsNull )1922 private Data(int lineNo, int dataLineNo, String line, String[] columns, boolean emptyIsNull, boolean nullIsNull, boolean trimWhiteSpace) 1904 1923 { 1905 1924 this.lineNo = lineNo; … … 1909 1928 this.emptyIsNull = emptyIsNull; 1910 1929 this.nullIsNull = nullIsNull; 1930 this.trimWhiteSpace = trimWhiteSpace; 1911 1931 } 1912 1932 … … 1991 2011 protected String fixString(String value) 1992 2012 { 2013 // TODO - In Java 11 we can use String.strip() which also handles other white-space than "space" 2014 if (value != null && trimWhiteSpace) value = value.trim(); 2015 1993 2016 return value == null || 1994 2017 emptyIsNull && value.length() == 0 || … … 1997 2020 } 1998 2021 1999 2000 2022 /** 2001 2023 Shortcut for getInt(index, null, true) … … 2086 2108 Create a new data object. 2087 2109 */ 2088 ExcelData(SheetInfo sheet, int lineOffset, int lineNo, int dataLineNo, String line, String[] columns, boolean emptyIsNull, boolean nullIsNull )2089 { 2090 super(lineNo, dataLineNo, line, columns, emptyIsNull, nullIsNull );2110 ExcelData(SheetInfo sheet, int lineOffset, int lineNo, int dataLineNo, String line, String[] columns, boolean emptyIsNull, boolean nullIsNull, boolean trimWhiteSpace) 2111 { 2112 super(lineNo, dataLineNo, line, columns, emptyIsNull, nullIsNull, trimWhiteSpace); 2091 2113 this.sheet = sheet; 2092 2114 this.rowOffset = sheet.getFirstRow()-1-lineOffset;
Note: See TracChangeset
for help on using the changeset viewer.