protected abstract static class CsvParser.AbstractDSL<D extends CsvParser.AbstractDSL<D>> extends Object
Modifier and Type | Class and Description |
---|---|
protected static class |
CsvParser.AbstractDSL.StringPostProcessing |
Modifier and Type | Field and Description |
---|---|
protected int |
bufferSize |
protected org.simpleflatmapper.util.Function<? super CellConsumer,? extends CellConsumer> |
cellConsumerWrapper |
protected char |
escapeChar |
protected int |
limit |
protected int |
maxBufferSize |
protected boolean |
parallelReader |
protected char |
quoteChar |
protected char |
separatorChar |
protected int |
skip |
protected boolean |
specialisedCharConsumer |
protected CsvParser.AbstractDSL.StringPostProcessing |
stringPostProcessing |
protected boolean |
yamlComment |
Modifier | Constructor and Description |
---|---|
protected |
AbstractDSL() |
protected |
AbstractDSL(char separatorChar,
char quoteChar,
char escapeChar,
int bufferSize,
int skip,
int limit,
int maxBufferSize,
CsvParser.AbstractDSL.StringPostProcessing stringPostProcessing,
org.simpleflatmapper.util.Function<? super CellConsumer,? extends CellConsumer> cellConsumerWrapper,
boolean yamlComment,
boolean parallelReader,
boolean specialisedCharConsumer) |
Modifier and Type | Method and Description |
---|---|
int |
bufferSize() |
D |
bufferSize(int size)
set the size of the char buffer to read from.
|
protected CharBuffer |
charBuffer(CharSequence content) |
protected CharBuffer |
charBuffer(Reader reader) |
protected CharBuffer |
charBuffer(String content) |
protected AbstractCharConsumer |
charConsumer(CharBuffer charBuffer) |
D |
disableSpecialisedCharConsumer() |
D |
escape(char c)
set the quote character.
|
<H extends org.simpleflatmapper.util.CheckedConsumer<String[]>> |
forEach(CharSequence content,
H consumer) |
<H extends org.simpleflatmapper.util.CheckedConsumer<String[]>> |
forEach(File file,
H consumer) |
<H extends org.simpleflatmapper.util.CheckedConsumer<String[]>> |
forEach(Reader reader,
H consumer) |
<H extends org.simpleflatmapper.util.CheckedConsumer<String[]>> |
forEach(String content,
H consumer) |
protected CellPreProcessor |
getCellTransformer(TextFormat textFormat,
CsvParser.AbstractDSL.StringPostProcessing stringPostProcessing) |
protected TextFormat |
getTextFormat() |
protected CellPreProcessor |
getUnescapeCellTransformer(TextFormat textFormat) |
Iterator<String[]> |
iterator(CharSequence content) |
org.simpleflatmapper.util.CloseableIterator<String[]> |
iterator(File file) |
Iterator<String[]> |
iterator(Reader reader) |
Iterator<String[]> |
iterator(String content) |
int |
limit() |
D |
limit(int limit)
set the number of row to process.
|
<T> CsvParser.MapToDSL<T> |
mapTo(Class<T> target) |
<T1,T2> CsvParser.MapToDSL<org.simpleflatmapper.tuple.Tuple2<T1,T2>> |
mapTo(Class<T1> class1,
Class<T2> class2) |
<T1,T2,T3> CsvParser.MapToDSL<org.simpleflatmapper.tuple.Tuple3<T1,T2,T3>> |
mapTo(Class<T1> class1,
Class<T2> class2,
Class<T3> class3) |
<T1,T2,T3,T4> |
mapTo(Class<T1> class1,
Class<T2> class2,
Class<T3> class3,
Class<T4> class4) |
<T1,T2,T3,T4,T5> |
mapTo(Class<T1> class1,
Class<T2> class2,
Class<T3> class3,
Class<T4> class4,
Class<T5> class5) |
<T1,T2,T3,T4,T5,T6> |
mapTo(Class<T1> class1,
Class<T2> class2,
Class<T3> class3,
Class<T4> class4,
Class<T5> class5,
Class<T6> class6) |
<T1,T2,T3,T4,T5,T6,T7> |
mapTo(Class<T1> class1,
Class<T2> class2,
Class<T3> class3,
Class<T4> class4,
Class<T5> class5,
Class<T6> class6,
Class<T7> class7) |
<T1,T2,T3,T4,T5,T6,T7,T8> |
mapTo(Class<T1> class1,
Class<T2> class2,
Class<T3> class3,
Class<T4> class4,
Class<T5> class5,
Class<T6> class6,
Class<T7> class7,
Class<T8> class8) |
<T> CsvParser.MapToDSL<T> |
mapTo(Type target) |
<T> CsvParser.MapToDSL<T> |
mapTo(org.simpleflatmapper.util.TypeReference<T> target) |
<T> CsvParser.MapWithDSL<T> |
mapWith(CsvMapper<T> mapper) |
int |
maxBufferSize() |
D |
maxBufferSize(int maxBufferSize)
set the maximum size of the content the parser will handle before failing to avoid OOM.
|
protected abstract D |
newDSL(char separatorChar,
char quoteChar,
char escapeChar,
int bufferSize,
int skip,
int limit,
int maxBufferSize,
CsvParser.AbstractDSL.StringPostProcessing stringPostProcessing,
org.simpleflatmapper.util.Function<? super CellConsumer,? extends CellConsumer> cellConsumerWrapper,
boolean yamlComment,
boolean parallelReader,
boolean specialisedCharConsumer) |
D |
parallelReader()
on parsing from a reader the Reader will be fetched from a another thread.
|
<CC extends CellConsumer> |
parse(CharSequence content,
CC cellConsumer) |
<CC extends CellConsumer> |
parse(File file,
CC cellConsumer) |
<CC extends CellConsumer> |
parse(Reader reader,
CC cellConsumer)
Parse the content from the reader as a csv and call back the cellConsumer with the cell values.
|
<CC extends CellConsumer> |
parse(String content,
CC cellConsumer) |
char |
quote() |
D |
quote(char c)
set the quote character.
|
CsvReader |
reader(CharSequence content) |
CloseableCsvReader |
reader(File file) |
CsvReader |
reader(Reader reader)
Create a CsvReader and the specified reader.
|
CsvReader |
reader(String content) |
Iterator<Row> |
rowIterator(CharSequence content) |
org.simpleflatmapper.util.CloseableIterator<Row> |
rowIterator(File file) |
Iterator<Row> |
rowIterator(Reader reader) |
Iterator<Row> |
rowIterator(String content) |
Stream<Row> |
rowStream(CharSequence content) |
<R> R |
rowStream(File file,
Function<Stream<Row>,R> function) |
Stream<Row> |
rowStream(Reader reader) |
Stream<Row> |
rowStream(String content) |
char |
separator() |
D |
separator(char c)
set the separator character.
|
D |
serialReader()
deactivate the parallelReader.
|
int |
skip() |
D |
skip(int skip)
set the number of line to skip.
|
Stream<String[]> |
stream(CharSequence content) |
Stream<String[]> |
stream(File file)
Deprecated.
|
<R> R |
stream(File file,
Function<Stream<String[]>,R> function) |
Stream<String[]> |
stream(Reader reader) |
Stream<String[]> |
stream(String content) |
protected final char separatorChar
protected final char quoteChar
protected final char escapeChar
protected final int bufferSize
protected final int skip
protected final int limit
protected final int maxBufferSize
protected final CsvParser.AbstractDSL.StringPostProcessing stringPostProcessing
protected final org.simpleflatmapper.util.Function<? super CellConsumer,? extends CellConsumer> cellConsumerWrapper
protected final boolean yamlComment
protected final boolean parallelReader
protected final boolean specialisedCharConsumer
protected AbstractDSL()
protected AbstractDSL(char separatorChar, char quoteChar, char escapeChar, int bufferSize, int skip, int limit, int maxBufferSize, CsvParser.AbstractDSL.StringPostProcessing stringPostProcessing, org.simpleflatmapper.util.Function<? super CellConsumer,? extends CellConsumer> cellConsumerWrapper, boolean yamlComment, boolean parallelReader, boolean specialisedCharConsumer)
public final <CC extends CellConsumer> CC parse(Reader reader, CC cellConsumer) throws IOException
CC
- the type of the cell consumerreader
- the readercellConsumer
- the callback object for each cell valueIOException
- if and error occurs in the readerpublic final <CC extends CellConsumer> CC parse(String content, CC cellConsumer) throws IOException
IOException
public final <CC extends CellConsumer> CC parse(CharSequence content, CC cellConsumer) throws IOException
IOException
public final <CC extends CellConsumer> CC parse(File file, CC cellConsumer) throws IOException
IOException
public final CsvReader reader(Reader reader) throws IOException
reader
- the contentIOException
- if an io error occurspublic final CsvReader reader(CharSequence content) throws IOException
IOException
public final CsvReader reader(String content) throws IOException
IOException
protected CharBuffer charBuffer(Reader reader) throws IOException
IOException
protected CharBuffer charBuffer(CharSequence content) throws IOException
IOException
protected CharBuffer charBuffer(String content) throws IOException
IOException
public final CloseableCsvReader reader(File file) throws IOException
IOException
public final Iterator<String[]> iterator(Reader reader) throws IOException
IOException
public final Iterator<String[]> iterator(CharSequence content) throws IOException
IOException
public final Iterator<String[]> iterator(String content) throws IOException
IOException
public final org.simpleflatmapper.util.CloseableIterator<String[]> iterator(File file) throws IOException
IOException
public final Iterator<Row> rowIterator(Reader reader) throws IOException
IOException
public final Iterator<Row> rowIterator(CharSequence content) throws IOException
IOException
public final Iterator<Row> rowIterator(String content) throws IOException
IOException
public final org.simpleflatmapper.util.CloseableIterator<Row> rowIterator(File file) throws IOException
IOException
public final <H extends org.simpleflatmapper.util.CheckedConsumer<String[]>> H forEach(Reader reader, H consumer) throws IOException
IOException
public final <H extends org.simpleflatmapper.util.CheckedConsumer<String[]>> H forEach(CharSequence content, H consumer) throws IOException
IOException
public final <H extends org.simpleflatmapper.util.CheckedConsumer<String[]>> H forEach(String content, H consumer) throws IOException
IOException
public final <H extends org.simpleflatmapper.util.CheckedConsumer<String[]>> H forEach(File file, H consumer) throws IOException
IOException
public final <T> CsvParser.MapToDSL<T> mapTo(Type target)
public final <T> CsvParser.MapToDSL<T> mapTo(Class<T> target)
public final <T> CsvParser.MapToDSL<T> mapTo(org.simpleflatmapper.util.TypeReference<T> target)
public final <T1,T2> CsvParser.MapToDSL<org.simpleflatmapper.tuple.Tuple2<T1,T2>> mapTo(Class<T1> class1, Class<T2> class2)
public final <T1,T2,T3> CsvParser.MapToDSL<org.simpleflatmapper.tuple.Tuple3<T1,T2,T3>> mapTo(Class<T1> class1, Class<T2> class2, Class<T3> class3)
public final <T1,T2,T3,T4> CsvParser.MapToDSL<org.simpleflatmapper.tuple.Tuple4<T1,T2,T3,T4>> mapTo(Class<T1> class1, Class<T2> class2, Class<T3> class3, Class<T4> class4)
public final <T1,T2,T3,T4,T5> CsvParser.MapToDSL<org.simpleflatmapper.tuple.Tuple5<T1,T2,T3,T4,T5>> mapTo(Class<T1> class1, Class<T2> class2, Class<T3> class3, Class<T4> class4, Class<T5> class5)
public final <T1,T2,T3,T4,T5,T6> CsvParser.MapToDSL<org.simpleflatmapper.tuple.Tuple6<T1,T2,T3,T4,T5,T6>> mapTo(Class<T1> class1, Class<T2> class2, Class<T3> class3, Class<T4> class4, Class<T5> class5, Class<T6> class6)
public final <T1,T2,T3,T4,T5,T6,T7> CsvParser.MapToDSL<org.simpleflatmapper.tuple.Tuple7<T1,T2,T3,T4,T5,T6,T7>> mapTo(Class<T1> class1, Class<T2> class2, Class<T3> class3, Class<T4> class4, Class<T5> class5, Class<T6> class6, Class<T7> class7)
public final <T1,T2,T3,T4,T5,T6,T7,T8> CsvParser.MapToDSL<org.simpleflatmapper.tuple.Tuple8<T1,T2,T3,T4,T5,T6,T7,T8>> mapTo(Class<T1> class1, Class<T2> class2, Class<T3> class3, Class<T4> class4, Class<T5> class5, Class<T6> class6, Class<T7> class7, Class<T8> class8)
public final <T> CsvParser.MapWithDSL<T> mapWith(CsvMapper<T> mapper)
public final Stream<String[]> stream(Reader reader) throws IOException
IOException
public final Stream<String[]> stream(CharSequence content) throws IOException
IOException
public final Stream<String[]> stream(String content) throws IOException
IOException
public final Stream<Row> rowStream(Reader reader) throws IOException
IOException
public final Stream<Row> rowStream(CharSequence content) throws IOException
IOException
public final Stream<Row> rowStream(String content) throws IOException
IOException
@Deprecated public final Stream<String[]> stream(File file) throws IOException
file
- the fileIOException
public final <R> R stream(File file, Function<Stream<String[]>,R> function) throws IOException
IOException
public final <R> R rowStream(File file, Function<Stream<Row>,R> function) throws IOException
IOException
protected final AbstractCharConsumer charConsumer(CharBuffer charBuffer)
protected TextFormat getTextFormat()
protected CellPreProcessor getCellTransformer(TextFormat textFormat, CsvParser.AbstractDSL.StringPostProcessing stringPostProcessing)
protected CellPreProcessor getUnescapeCellTransformer(TextFormat textFormat)
public final int maxBufferSize()
public final int bufferSize()
public final int limit()
public final int skip()
public final char separator()
public final char quote()
public D separator(char c)
c
- the new separator characterpublic D quote(char c)
c
- the quote characterpublic D escape(char c)
c
- the quote characterpublic D bufferSize(int size)
size
- the size in bytespublic D skip(int skip)
skip
- number of line to skip.public D limit(int limit)
limit
- number of row to processpublic D parallelReader()
On java 8 and over it will use the ForkJoinPool by default if the number of core is greater than 1, otherwise it will create a new Thread every time.
On java 6 and 7 it will create a shared ExecutorService with the number of threads set to the number of cores if it is greater than 1, otherwise it will create a new Thread every time.
If you wish to customize the org.simpleflatmapper.util.ParallelReader further for example to specify which Executor to user or the size of the ring buffer or read buffer you will need to wrap the Reader manually.
public D serialReader()
public D disableSpecialisedCharConsumer()
public D maxBufferSize(int maxBufferSize)
maxBufferSize
- the maximum size the buffer will grow, default 8Mprotected abstract D newDSL(char separatorChar, char quoteChar, char escapeChar, int bufferSize, int skip, int limit, int maxBufferSize, CsvParser.AbstractDSL.StringPostProcessing stringPostProcessing, org.simpleflatmapper.util.Function<? super CellConsumer,? extends CellConsumer> cellConsumerWrapper, boolean yamlComment, boolean parallelReader, boolean specialisedCharConsumer)
Copyright © 2018. All rights reserved.