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
-
public class SSVFileReader extends CSVFileReader
CSVFileReadersubclass to read the SSV format:- Line feed (0x0A) is row separator
- Field separator (0x1C) is column separator
- No quote or escape characters are used
- Carriage return (0x0D) represents embedded newline
- Cell content is arbitrary binary except 0x0A, 0x1C (and NUL)
- Author:
- mirabilos (t.glaser@tarent.de)
- See Also:
- SSV at shellsnippets @ Evolvis
-
-
Field Summary
-
Fields inherited from class org.evolvis.tartools.csvfile.CSVFileReader
in, line
-
Fields inherited from class org.evolvis.tartools.csvfile.CSVFile
CR, CRLF, DEFAULT_FIELD_SEPARATOR, DEFAULT_TEXT_QUALIFIER, fieldSeparator, LF, textQualifier
-
-
Constructor Summary
Constructors Constructor Description SSVFileReader(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddField(List<String> fields, String field)Adds extracted field to list of fields, handling SSV postprocessing.protected booleanfieldIsQuoted(int i)SSV does not have any quoted fields.chargetTextQualifier()Throws an exception, SSV has no quote character.List<String>readFields()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.voiduseUnixNewline()Switches 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, readFields
-
Methods inherited from class org.evolvis.tartools.csvfile.CSVFile
getFieldSeparator
-
-
-
-
Constructor Detail
-
SSVFileReader
public SSVFileReader(String inputFileName) throws FileNotFoundException
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
public SSVFileReader(InputStream stream)
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
-
-
Method Detail
-
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
public List<String> readFields() throws IOException
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
protected void addField(List<String> fields, String field)
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
-
useUnixNewline
public void useUnixNewline()
Switches the reader to use Unix (LF only) instead of the native underlying system’s newline on decoding embedded newlines.
-
-