Package org.evolvis.tartools.csvfile
Class SSVFileReader
java.lang.Object
org.evolvis.tartools.csvfile.CSVFile
org.evolvis.tartools.csvfile.CSVFileReader
org.evolvis.tartools.csvfile.SSVFileReader
CSVFileReader subclass to read the SSV format:
- Line feed (0x0A) is row separator
- Unit separator (0x1F) is column separator
- No quote or escape characters are used
- Carriage return (0x0D) represents embedded newline
- Cell content is arbitrary binary except 0x0A, 0x1F (and NUL)
- Author:
- mirabilos (t.glaser@tarent.de)
- See Also:
-
Field Summary
Fields inherited from class org.evolvis.tartools.csvfile.CSVFileReader
in, lineFields inherited from class org.evolvis.tartools.csvfile.CSVFile
CR, CRLF, DEFAULT_FIELD_SEPARATOR, DEFAULT_TEXT_QUALIFIER, fieldSeparator, LF, textQualifier -
Constructor Summary
ConstructorsConstructorDescriptionSSVFileReader(InputStream stream) SSVFileReader constructor just needing an InputStream for the data to read.SSVFileReader(Reader reader) SSVFileReader constructor just needing a reader for the SSV data to read.SSVFileReader(String inputFileName) SSVFileReader constructor just needing the name of the existing SSV file to read. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidAdds extracted field to list of fields, handling SSV postprocessing.protected booleanfieldIsQuoted(int i) SSV does not have any quoted fields.charThrows an exception, SSV has no quote character.Splits the next line of the input SSV file into fields.voidsetFieldSeparator(char sep) Throws an exception, the field separator is constant for SSV.voidsetTextQualifier(char qual) Throws an exception, SSV has no quote character.voidSwitches the reader to use Unix (LF only) instead of the native underlying system’s newline on decoding embedded newlines.Methods inherited from class org.evolvis.tartools.csvfile.CSVFileReader
close, handlePlainField, handleQuotedField, readFieldsMethods inherited from class org.evolvis.tartools.csvfile.CSVFile
getFieldSeparator
-
Constructor Details
-
SSVFileReader
SSVFileReader constructor just needing the name of the existing SSV file to read. The SSV file is assumed to be in, and will be read using, UTF-8 encoding.- Parameters:
inputFileName- The name of the CSV file to be opened for reading- Throws:
FileNotFoundException- if the file to be read does not exist
-
SSVFileReader
SSVFileReader constructor just needing an InputStream for the data to read. The SSV file is assumed to be in, and will be read using, UTF-8 encoding.- Parameters:
stream- TheInputStreamfor reading CSV data
-
SSVFileReader
SSVFileReader constructor just needing a reader for the SSV data to read.- Parameters:
reader- TheReaderfor reading CSV data, which MUST be using an ASCII-compatible charset (such as UTF-8); we sadly cannot test that
-
-
Method Details
-
setFieldSeparator
public void setFieldSeparator(char sep) Throws an exception, the field separator is constant for SSV.- Overrides:
setFieldSeparatorin classCSVFile- Parameters:
sep- The new field separator to be ignored
-
setTextQualifier
public void setTextQualifier(char qual) Throws an exception, SSV has no quote character.- Overrides:
setTextQualifierin classCSVFile- Parameters:
qual- The new text qualifier to be ignored
-
getTextQualifier
public char getTextQualifier()Throws an exception, SSV has no quote character.- Overrides:
getTextQualifierin classCSVFile- Returns:
- The char containing the current text qualifier
-
readFields
Splits the next line of the input SSV file into fields.- Overrides:
readFieldsin classCSVFileReader- Returns:
- List of String containing each field from the next line of the file
- Throws:
IOException- if an error occurs while reading the new line from the file
-
fieldIsQuoted
protected boolean fieldIsQuoted(int i) SSV does not have any quoted fields.- Overrides:
fieldIsQuotedin classCSVFileReader- Parameters:
i- Offset into the input line denoting start of field- Returns:
- false
-
addField
Adds extracted field to list of fields, handling SSV postprocessing. Converts embedded newline marker to platform newline character.- Overrides:
addFieldin classCSVFileReader- Parameters:
fields- list of fields to add field tofield- raw extracted String- See Also:
-
useUnixNewline
public void useUnixNewline()Switches the reader to use Unix (LF only) instead of the native underlying system’s newline on decoding embedded newlines.
-