Top Inners Fields Constructors Methods
de.siegmar.fastcsv.reader

pack-priv final Class StrictCsvParser

extends Object
implements CsvParser
Class Inheritance
All Implemented Interfaces
de.siegmar.fastcsv.reader.CsvParser, java.io.Closeable, java.lang.AutoCloseable
Annotations
@SuppressWarnings:checkstyle:CyclomaticComplexity, checkstyle:ExecutableStatementCount, checkstyle:InnerAssignment, checkstyle:JavaNCSS, checkstyle:NestedIfDepth
Static Imports
de.siegmar.fastcsv.util.Util.CR, .Util.LF

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private final boolean
private final CsvCallbackHandler<?>
private final char
private final CommentStrategy
private final StrictCsvParser.CsvBuffer
private boolean
private boolean
private final char
private int
private final char
private long
private int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int

Constructor Summary

AccessConstructor and Description
pack-priv
StrictCsvParser(final char fieldSeparator, final char quoteCharacter, final CommentStrategy commentStrategy, final char commentCharacter, final boolean allowExtraCharsAfterClosingQuote, final CsvCallbackHandler<?> callbackHandler, final int maxBufferSize, final Reader reader)

pack-priv
StrictCsvParser(final char fieldSeparator, final char quoteCharacter, final CommentStrategy commentStrategy, final char commentCharacter, final boolean allowExtraCharsAfterClosingQuote, final CsvCallbackHandler<?> callbackHandler, final String data)

Method Summary

Modifier and TypeMethod and Description
private static void
assertFields(final char fieldSeparator, final char quoteCharacter, final char commentCharacter, final CommentStrategy commentStrategy)

private static int

Returns:

the length of the field data after removing escapes
cleanDelimiters
(final char[]
the buffer containing the field data
buf
,
final int
the start position of the field data (after the opening quote)
begin
,
final int
the end position of the field data (on the closing quote / end of buffer)
end
,
final char
the quote character
quoteCharacter
)

Remove escapes from the field data.

public void
close()

Implements java.io.Closeable.close.

Closes this stream and releases any system resources associated with it.

pack-priv boolean
consume(final char[] lBuf, final int lLen)

public long
getStartingLineNumber()

Implements de.siegmar.fastcsv.reader.CsvParser.getStartingLineNumber.

Returns the starting line number of the last parsed record.

private void
materialize(final char[] lBuf, final int lBegin, final int lPos, final int lStatus, final char quoteCharacter)

public boolean
parse()

Implements de.siegmar.fastcsv.reader.CsvParser.parse.

Parses the next record from the stream and passes it to the callback handler.

public String
peekLine()

Implements de.siegmar.fastcsv.reader.CsvParser.peekLine.

Returns the next line from the stream without consuming it.

private boolean
public void
reset(final long startingLineNumber)

Implements de.siegmar.fastcsv.reader.CsvParser.reset.

Resets the parser to the specified starting line number.

public void
skipLine(final int numCharsToSkip)

Implements de.siegmar.fastcsv.reader.CsvParser.skipLine.

Skips a line in the stream after skipping the specified number of characters.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

allowExtraCharsAfterClosingQuoteback to summary
private final boolean allowExtraCharsAfterClosingQuote
callbackHandlerback to summary
private final CsvCallbackHandler<?> callbackHandler
cCharback to summary
private final char cChar
cStratback to summary
private final CommentStrategy cStrat
csvBufferback to summary
private final StrictCsvParser.CsvBuffer csvBuffer
finishedback to summary
private boolean finished
firstFieldback to summary
private boolean firstField
fsepback to summary
private final char fsep
linesback to summary
private int lines
qCharback to summary
private final char qChar
startingLineNumberback to summary
private long startingLineNumber
statusback to summary
private int status
STATUS_COMMENTED_RECORDback to summary
private static final int STATUS_COMMENTED_RECORD
STATUS_DATA_FIELDback to summary
private static final int STATUS_DATA_FIELD
STATUS_LAST_CHAR_WAS_CRback to summary
private static final int STATUS_LAST_CHAR_WAS_CR
STATUS_NEW_FIELDback to summary
private static final int STATUS_NEW_FIELD
STATUS_QUOTED_FIELDback to summary
private static final int STATUS_QUOTED_FIELD
STATUS_QUOTED_MODEback to summary
private static final int STATUS_QUOTED_MODE
STATUS_RESETback to summary
private static final int STATUS_RESET

Constructor Detail

StrictCsvParserback to summary
pack-priv StrictCsvParser(final char fieldSeparator, final char quoteCharacter, final CommentStrategy commentStrategy, final char commentCharacter, final boolean allowExtraCharsAfterClosingQuote, final CsvCallbackHandler<?> callbackHandler, final int maxBufferSize, final Reader reader)
Annotations
@SuppressWarnings:checkstyle:ParameterNumber
StrictCsvParserback to summary
pack-priv StrictCsvParser(final char fieldSeparator, final char quoteCharacter, final CommentStrategy commentStrategy, final char commentCharacter, final boolean allowExtraCharsAfterClosingQuote, final CsvCallbackHandler<?> callbackHandler, final String data)

Method Detail

assertFieldsback to summary
private static void assertFields(final char fieldSeparator, final char quoteCharacter, final char commentCharacter, final CommentStrategy commentStrategy)
cleanDelimitersback to summary
private static int cleanDelimiters(final char[] buf, final int begin, final int end, final char quoteCharacter)

Remove escapes from the field data.

The input buffer could look like this: foo ""is"" bar

Parameters
buf:char[]

the buffer containing the field data

begin:int

the start position of the field data (after the opening quote)

end:int

the end position of the field data (on the closing quote / end of buffer)

quoteCharacter:char

the quote character

Returns:int

the length of the field data after removing escapes

closeback to summary
public void close() throws IOException

Implements java.io.Closeable.close.

Doc from java.io.Closeable.close.

Closes this stream and releases any system resources associated with it. If the stream is already closed then invoking this method has no effect.

As noted in AutoCloseable#close(), cases where the close may fail require careful attention. It is strongly advised to relinquish the underlying resources and to internally mark the Closeable as closed, prior to throwing the IOException.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs
consumeback to summary
pack-priv boolean consume(final char[] lBuf, final int lLen)
Annotations
@SuppressWarnings:LabelledBreakTarget
getStartingLineNumberback to summary
public long getStartingLineNumber()

Implements de.siegmar.fastcsv.reader.CsvParser.getStartingLineNumber.

Doc from de.siegmar.fastcsv.reader.CsvParser.getStartingLineNumber.

Returns the starting line number of the last parsed record.

Annotations
@Override
materializeback to summary
private void materialize(final char[] lBuf, final int lBegin, final int lPos, final int lStatus, final char quoteCharacter)
parseback to summary
public boolean parse() throws IOException

Implements de.siegmar.fastcsv.reader.CsvParser.parse.

Doc from de.siegmar.fastcsv.reader.CsvParser.parse.

Parses the next record from the stream and passes it to the callback handler.

Annotations
@SuppressWarnings:checkstyle:ReturnCount
@Override
peekLineback to summary
public String peekLine() throws IOException

Implements de.siegmar.fastcsv.reader.CsvParser.peekLine.

Doc from de.siegmar.fastcsv.reader.CsvParser.peekLine.

Returns the next line from the stream without consuming it.

Annotations
@Override
processBufferTailback to summary
private boolean processBufferTail()
resetback to summary
public void reset(final long startingLineNumber)

Implements de.siegmar.fastcsv.reader.CsvParser.reset.

Doc from de.siegmar.fastcsv.reader.CsvParser.reset.

Resets the parser to the specified starting line number.

Annotations
@SuppressWarnings:checkstyle:HiddenField
@Override
skipLineback to summary
public void skipLine(final int numCharsToSkip) throws IOException

Implements de.siegmar.fastcsv.reader.CsvParser.skipLine.

Doc from de.siegmar.fastcsv.reader.CsvParser.skipLine.

Skips a line in the stream after skipping the specified number of characters.

Annotations
@Override
de.siegmar.fastcsv.reader back to summary

private Class StrictCsvParser.CsvBuffer

extends Object
implements Closeable
Class Inheritance
All Implemented Interfaces
java.io.Closeable, java.lang.AutoCloseable
Annotations
@SuppressWarnings:checkstyle:visibilitymodifier

Field Summary

Modifier and TypeField and Description
pack-priv int
pack-priv char[]
private static final int
pack-priv int
private final int
pack-priv int
private final Reader
private final int

Constructor Summary

AccessConstructor and Description
pack-priv
CsvBuffer(final Reader reader, final int maxBufferSize)

pack-priv
CsvBuffer(final String data)

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements java.io.Closeable.close.

Closes this stream and releases any system resources associated with it.

private boolean

Returns:

true, if data was fetched, false if the end of the stream was reached
fetchData
()

Reads data from the underlying reader and manages the local buffer.

private char[]
private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

beginback to summary
pack-priv int begin
bufback to summary
pack-priv char[] buf
DEFAULT_READ_SIZEback to summary
private static final int DEFAULT_READ_SIZE
lenback to summary
pack-priv int len
maxBufferSizeback to summary
private final int maxBufferSize
posback to summary
pack-priv int pos
readerback to summary
private final Reader reader
Annotations
@Nullable
readSizeback to summary
private final int readSize

Constructor Detail

CsvBufferback to summary
pack-priv CsvBuffer(final Reader reader, final int maxBufferSize)
CsvBufferback to summary
pack-priv CsvBuffer(final String data)

Method Detail

closeback to summary
public void close() throws IOException

Implements java.io.Closeable.close.

Doc from java.io.Closeable.close.

Closes this stream and releases any system resources associated with it. If the stream is already closed then invoking this method has no effect.

As noted in AutoCloseable#close(), cases where the close may fail require careful attention. It is strongly advised to relinquish the underlying resources and to internally mark the Closeable as closed, prior to throwing the IOException.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs
fetchDataback to summary
private boolean fetchData() throws IOException

Reads data from the underlying reader and manages the local buffer.

Returns:boolean

true, if data was fetched, false if the end of the stream was reached

Exceptions
IOException:
if a read error occurs
largerBufferback to summary
private char[] largerBuffer()
resetback to summary
private void reset()