DelimitedRecordMapper extends AbstractRecordMapper<P> implements RecordMapper<String, P> { public void setDelimiter(final String delimiter) { String prefix = ""; if ("|".equals(delimiter)) { prefix = "\\"; } this.delimiter = prefix + delimiter; } DelimitedRecordMapper(final Class<P> recordClass);  DelimitedRecordMapper(final Class<P> recordClass, String... fieldNames);  DelimitedRecordMapper(final Class<P> recordClass, final String[] fieldNames, final int recordExpectedLength);  DelimitedRecordMapper(final Class<P> recordClass, final Integer... fieldsPositions);  DelimitedRecordMapper(final Class<P> recordClass, final Integer[] fieldsPositions, final String[] fieldNames);  DelimitedRecordMapper(final Class<P> recordClass, final Integer[] fieldsPositions, final String[] fieldNames, final int recordExpectedLength); @Override Record<P> processRecord(final Record<String> record); void setDelimiter(final String delimiter); void setTrimWhitespaces(final boolean trimWhitespaces); void setQualifier(final String qualifier); static final String DEFAULT_DELIMITER; static final String DEFAULT_QUALIFIER; static final boolean DEFAULT_WHITESPACE_TRIMMING; }
@Test public void testRecordParsingWithPipeDelimiter() throws Exception { delimitedRecordMapper.setDelimiter("|"); when(record.getPayload()).thenReturn("foo|bar|30|1990-12-12|true"); validateRecord(record); }
@Test public void testRecordParsingWithSpaceDelimiter() throws Exception { delimitedRecordMapper.setDelimiter(" "); when(record.getPayload()).thenReturn("foo bar 30 1990-12-12 true"); validateRecord(record); }
@Test public void testRecordParsingWithTabDelimiter() throws Exception { delimitedRecordMapper.setDelimiter("\t"); when(record.getPayload()).thenReturn("foo\tbar\t30\t1990-12-12\ttrue"); validateRecord(record); }
@Test public void testRecordParsingWithMultipleCharactersDelimiter() throws Exception { delimitedRecordMapper.setDelimiter("###"); when(record.getPayload()).thenReturn("foo###bar###30###1990-12-12###true"); validateRecord(record); }