@Test public void testRemoveEscapedEnclosuresWithOneEscapedInMiddle() { CsvInputData csvInputData = new CsvInputData(); csvInputData.enclosure = "\"".getBytes(); String result = new String( csvInputData.removeEscapedEnclosures( "abcd \"\" defg".getBytes(), 1 ) ); assertEquals( "abcd \" defg", result ); }
byte[] removeEscapedEnclosures( byte[] field, int nrEnclosuresFound ) { byte[] result = new byte[field.length - nrEnclosuresFound]; int resultIndex = 0; for ( int i = 0; i < field.length; i++ ) { result[resultIndex++] = field[i]; if ( field[i] == enclosure[0] && i + 1 < field.length && field[i + 1] == enclosure[0] ) { i++; } } return result; }
CsvInputData extends BaseStepData implements StepDataInterface { byte[] removeEscapedEnclosures( byte[] field, int nrEnclosuresFound ) { byte[] result = new byte[field.length - nrEnclosuresFound]; int resultIndex = 0; for ( int i = 0; i < field.length; i++ ) { result[resultIndex++] = field[i]; if ( field[i] == enclosure[0] && i + 1 < field.length && field[i + 1] == enclosure[0] ) { i++; } } return result; } }
CsvInputData extends BaseStepData implements StepDataInterface { byte[] removeEscapedEnclosures( byte[] field, int nrEnclosuresFound ) { byte[] result = new byte[field.length - nrEnclosuresFound]; int resultIndex = 0; for ( int i = 0; i < field.length; i++ ) { result[resultIndex++] = field[i]; if ( field[i] == enclosure[0] && i + 1 < field.length && field[i + 1] == enclosure[0] ) { i++; } } return result; } CsvInputData(); }
CsvInputData extends BaseStepData implements StepDataInterface { byte[] removeEscapedEnclosures( byte[] field, int nrEnclosuresFound ) { byte[] result = new byte[field.length - nrEnclosuresFound]; int resultIndex = 0; for ( int i = 0; i < field.length; i++ ) { result[resultIndex++] = field[i]; if ( field[i] == enclosure[0] && i + 1 < field.length && field[i + 1] == enclosure[0] ) { i++; } } return result; } CsvInputData();  }
CsvInputData extends BaseStepData implements StepDataInterface { byte[] removeEscapedEnclosures( byte[] field, int nrEnclosuresFound ) { byte[] result = new byte[field.length - nrEnclosuresFound]; int resultIndex = 0; for ( int i = 0; i < field.length; i++ ) { result[resultIndex++] = field[i]; if ( field[i] == enclosure[0] && i + 1 < field.length && field[i + 1] == enclosure[0] ) { i++; } } return result; } CsvInputData();  public FileChannel fc; public ByteBuffer bb; public RowMetaInterface convertRowMeta; public RowMetaInterface outputRowMeta; public byte[] delimiter; public byte[] enclosure; public int preferredBufferSize; public String[] filenames; public int filenr; public int startFilenr; public byte[] binaryFilename; public FileInputStream fis; public boolean isAddingRowNumber; public long rowNumber; public boolean stopReading; public int stepNumber; public int totalNumberOfSteps; public List<Long> fileSizes; public long totalFileSize; public long blockToRead; public long startPosition; public long endPosition; public long bytesToSkipInFirstFile; public long totalBytesRead; public boolean parallel; public int filenameFieldIndex; public int rownumFieldIndex; public EncodingType encodingType; public PatternMatcherInterface delimiterMatcher; public PatternMatcherInterface enclosureMatcher; public CrLfMatcherInterface crLfMatcher; public FieldsMapping fieldsMapping; }