Class AbstractTextDataReader
java.lang.Object
com.aquima.interactions.framework.util.textdata.AbstractTextDataReader
- Direct Known Subclasses:
CsvReader
,FixedWidthTextReader
Abstract base class to parse a text based resource.
- Since:
- 6.3
- Author:
- Jon van Leuven
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
The default line to start reading. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
AbstractTextDataReader
(IResource resource, int skipLines, String charset) -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes the underlying reader.protected String
Reads the next line from the file.protected abstract String[]
Parses an incoming String and returns an array of elements.readAll
(boolean hasHeader) Reads the entire file into a TextDataContent object.String[]
readNext()
Reads the next line from the buffer and converts to a string array.
-
Field Details
-
DEFAULT_SKIP_LINES
public static final int DEFAULT_SKIP_LINESThe default line to start reading.- See Also:
-
-
Constructor Details
-
AbstractTextDataReader
-
-
Method Details
-
readAll
Reads the entire file into a TextDataContent object.- Parameters:
hasHeader
- Indicator if the first row is treated as header.- Returns:
- a TextDataContent.
- Throws:
IOException
- if bad things happen during the read
-
readNext
Reads the next line from the buffer and converts to a string array.- Returns:
- a string array with each comma-separated element as a separate entry.
- Throws:
IOException
- if bad things happen during the read
-
getNextLine
Reads the next line from the file. Empty lines are skipped.- Returns:
- the next line from the file without trailing newline
- Throws:
IOException
- if bad things happen during the read
-
parseLine
Parses an incoming String and returns an array of elements.- Parameters:
nextLine
- the string to parse- Returns:
- the comma-tokenized list of elements, or null if nextLine is null
- Throws:
IOException
- if bad things happen during the read
-
close
Closes the underlying reader.- Throws:
IOException
- if the close fails
-