public class CSVReaderBuilder extends Object implements ReaderBuilder<CSVHeader,CSVRow>
| Constructor and Description |
|---|
CSVReaderBuilder() |
| Modifier and Type | Method and Description |
|---|---|
CSVReaderBuilder |
addIgnorePrefix(String prefix)
Adds an ignore line prefix.
|
CSVReaderBuilder |
containsHeader(boolean containsHeader)
Specifies whether the resulting reader considers a header line
default: true
|
static CSVReaderBuilder |
create()
Creates csv reader builder instance
|
DataContainer<CSVHeader,CSVRow> |
fromFile(File f)
Creates a data container from a file.
|
DataContainer<CSVHeader,CSVRow> |
fromResource(String content,
ClassLoader classLoader)
Creates a data container from a resoruce
|
DataContainer<CSVHeader,CSVRow> |
fromString(String content)
Creates a data container from a string
|
String |
getHeaderPrefix() |
Character |
getSeparator() |
boolean |
isContainsHeader() |
CSVReader |
load(File file)
Creates a
CSVReader for the specified file |
CSVReader |
load(String content)
Creates a
CSVReader for the specified csv content string |
void |
loadAttributes(Map<String,String> attributes)
Sets all attributes using a map
"separator" = csv column separator
"headerPrefix" = header line prefix
"containsHeader" = reader considers header line (true or false)
|
CSVReader |
loadResource(String resourcePath)
Creates a
CSVReader for a specified resource. |
CSVReader |
loadResource(String resourcePath,
ClassLoader classLoader)
Creates a
CSVReader for a specified resource. |
CSVReaderBuilder |
withHeaderPrefix(String headerPrefix)
Sets the header prefix used by the resulting reader.
|
CSVReaderBuilder |
withSeparator(Character separator)
Sets the csv column separator char used by the resulting reader
default: '\t'
|
public static CSVReaderBuilder create()
public CSVReaderBuilder withSeparator(Character separator)
default: '\t'
separator - csv column separatorpublic CSVReaderBuilder containsHeader(boolean containsHeader)
default: true
containsHeader - header line parameterpublic CSVReaderBuilder addIgnorePrefix(String prefix)
prefix - ignore line prefixpublic CSVReaderBuilder withHeaderPrefix(String headerPrefix)
default:#
headerPrefix - header line prefixpublic Character getSeparator()
public String getHeaderPrefix()
public boolean isContainsHeader()
public CSVReader load(File file)
CSVReader for the specified filefile - source filepublic CSVReader load(String content)
CSVReader for the specified csv content stringcontent - csv content stringpublic CSVReader loadResource(String resourcePath, ClassLoader classLoader)
CSVReader for a specified resource.
The provided ClassLoader is used to load the resource.resourcePath - path to csv resourceclassLoader - ClassLoader used to load the resourcepublic CSVReader loadResource(String resourcePath)
CSVReader for a specified resource.
The ClassLoader of CSVResourceReader is used to load the resource.resourcePath - path to csv resourcepublic void loadAttributes(Map<String,String> attributes) throws Exception
"separator" = csv column separator
"headerPrefix" = header line prefix
"containsHeader" = reader considers header line (true or false)
loadAttributes in interface ReaderBuilder<CSVHeader,CSVRow>attributes - map of attributesException - throws an exception if an attribute can not be correctly parsedpublic DataContainer<CSVHeader,CSVRow> fromFile(File f)
ReaderBuilderfromFile in interface ReaderBuilder<CSVHeader,CSVRow>f - file to be readload(File)public DataContainer<CSVHeader,CSVRow> fromString(String content)
ReaderBuilderfromString in interface ReaderBuilder<CSVHeader,CSVRow>content - string content used to create the data containerload(String)public DataContainer<CSVHeader,CSVRow> fromResource(String content, ClassLoader classLoader)
ReaderBuilderfromResource in interface ReaderBuilder<CSVHeader,CSVRow>content - resource pathclassLoader - class loaderloadResource(String, ClassLoader)Copyright © 2017. All rights reserved.