public class InputFileLineTokenValueExtractor
extends java.lang.Object
The file is fully read into memory for performance reasons.
If 'cyclic read' in combination with 'randomizing the order of lines' is enabled, then the order of lines
is each time again newly randomized when the end of file is reached.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DEFAULT_COMMENT_TAG
The default comment tag = "#".
|
static java.lang.String |
DEFAULT_TOKEN_DELIMITER
The default line token delimiter = "," (comma).
|
Constructor and Description |
---|
InputFileLineTokenValueExtractor(java.io.File f)
Create a new instance.
|
Modifier and Type | Method and Description |
---|---|
void |
dumpLines()
For debug purpose only, dump all lines to stdout.
|
java.lang.String[] |
getNextLineTokens()
Get the next line and split it into tokens - This method is thread safe.
|
void |
readFile()
Read the file into memory.
|
void |
setCharset(java.nio.charset.Charset charset)
Set the charset (default = UTF-8).
|
void |
setCommentTag(java.lang.String commentTag)
Set the comment tag.
|
void |
setCyclicRead(boolean cyclicRead)
Set if cyclic read is enabled (default = false).
|
void |
setRandomizeLines(boolean randomizeLines)
Set if randomizing the order of lines is enabled (default = false).
|
void |
setRemoveDoubleQuotes(boolean removeDoubleQuotes)
Set if double quotes are removed from the start and from the end of the tokens (default = false).
|
void |
setTokenDelimiter(java.lang.String tokenDelimiter)
Set the token delimiter
|
void |
setTrimExtractedValues(boolean trimExtractedValues)
Set if the value of the tokens are trimmed (default = false).
|
public static final java.lang.String DEFAULT_COMMENT_TAG
setCommentTag(String)
,
Constant Field Valuespublic static final java.lang.String DEFAULT_TOKEN_DELIMITER
setTokenDelimiter(String)
,
Constant Field Valuespublic InputFileLineTokenValueExtractor(java.io.File f) throws java.io.IOException
f
- the file to readjava.io.IOException
- if the file not exists or if the file is a directorypublic void setCharset(java.nio.charset.Charset charset)
charset
- the charsetpublic void setCommentTag(java.lang.String commentTag)
commentTag
- the comment tagDEFAULT_COMMENT_TAG
public void setTokenDelimiter(java.lang.String tokenDelimiter)
tokenDelimiter
- the token delimiterDEFAULT_TOKEN_DELIMITER
public void setCyclicRead(boolean cyclicRead)
cyclicRead
- true = cyclic read is enabledpublic void setRandomizeLines(boolean randomizeLines)
randomizeLines
- true = randomizing the order of lines is enabledpublic void setTrimExtractedValues(boolean trimExtractedValues)
trimExtractedValues
- true = the value of the tokens are trimmedpublic void setRemoveDoubleQuotes(boolean removeDoubleQuotes)
removeDoubleQuotes
- true = double quotes are removed from the start and the end of the tokenspublic void readFile() throws java.io.IOException
java.io.IOException
- if reading of the file failspublic java.lang.String[] getNextLineTokens()
public void dumpLines()