-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
63 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
src/main/java/com/univocity/articles/csvcomparison/parser8/SesseltjonnaParser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package com.univocity.articles.csvcomparison.parser8; | ||
|
||
import java.io.File; | ||
import java.io.Reader; | ||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
import com.github.skjolber.stcsv.CsvReader; | ||
import com.github.skjolber.stcsv.builder.StringArrayCsvReaderBuilder; | ||
import com.github.skjolber.stcsv.sa.StringArrayCsvReader; | ||
import com.github.skjolber.stcsv.sa.rfc4180.RFC4180StringArrayCsvReader; | ||
import com.univocity.articles.csvcomparison.parser.AbstractParser; | ||
|
||
public class SesseltjonnaParser extends AbstractParser { | ||
|
||
public SesseltjonnaParser() { | ||
super("Sesseltjonna-csv databinding"); | ||
} | ||
|
||
@Override | ||
public void processRows(final Reader input) throws Exception { | ||
CsvReader<String[]> reader = StringArrayCsvReader.builder().build(input); | ||
|
||
String[] next; | ||
do { | ||
next = reader.next(); | ||
if(next == null) { | ||
break; | ||
} | ||
process(next); | ||
} while(true); | ||
} | ||
|
||
@Override | ||
public List<String[]> parseRows(final Reader input) throws Exception { | ||
CsvReader<String[]> reader = StringArrayCsvReader.builder().build(input); | ||
List<String[]> arrayList = new ArrayList<>(10000); | ||
|
||
String[] next; | ||
do { | ||
next = reader.next(); | ||
if(next == null) { | ||
break; | ||
} | ||
// the same array is returned, so make a copy | ||
String[] copy = new String[next.length]; | ||
System.arrayCopy(next, 0, copy, 0, next.length); | ||
arrayList.add(copy); | ||
} while(true); | ||
|
||
return arrayList; | ||
} | ||
|
||
} |