Top Description Fields Constructors Methods
com.fasterxml.jackson.dataformat.csv.impl

public final Class CsvParserBootstrapper

extends Object
Class Inheritance
Imports
java.io.*, com.fasterxml.jackson.core.*, com.fasterxml.jackson.core.format.InputAccessor, .MatchStrength, com.fasterxml.jackson.core.io.IOContext, .MergedStream, .UTF32Reader, com.fasterxml.jackson.dataformat.csv.CsvParser

This class is used to determine the encoding of byte stream that is to contain CSV document. Since there is no real specification for how this should work with CSV, it will be based on rules used with JSON (which themselves are similar to those used with XML); main points are to check for BOM first, then look for multi-byted fixed-length encodings (UTF-16, UTF-32). And finally, if neither found, must decide between most likely alternatives, UTF-8 and Latin-1.

Field Summary

Modifier and TypeField and Description
protected boolean
protected int
protected final ObjectCodec
protected final IOContext
protected final InputStream
protected final byte[]
private int
protected int
_inputProcessed

Current number of input units (bytes or chars) that were processed in previous blocks, before contents of current input buffer.

private int
pack-priv static final byte
pack-priv static final byte
pack-priv static final byte

Constructor Summary

AccessConstructor and Description
public
public
CsvParserBootstrapper(IOContext ctxt, ObjectCodec codec, byte[] inputBuffer, int inputStart, int inputLen)

Method Summary

Modifier and TypeMethod and Description
private Reader
_createReader(JsonEncoding enc, boolean autoClose)

private boolean
checkUTF16(int i16)

private boolean
checkUTF32(int quad)

public CsvParser
constructParser(int baseFeatures, int csvFeatures)

protected boolean
ensureLoaded(int minimum)

private boolean

Returns:

True if a BOM was successfully found, and encoding thereby recognized.
handleBOM
(int quad)

public static MatchStrength
hasCSVFormat(InputAccessor acc, int quoteChar, char separatorChar)

Current implementation is not as thorough as one used by other data formats like JSON.

private void
private static final int
skipSpace(InputAccessor acc, byte b)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_bigEndianback to summary
protected boolean _bigEndian
_bytesPerCharback to summary
protected int _bytesPerChar
_codecback to summary
protected final ObjectCodec _codec
_contextback to summary
protected final IOContext _context
_inback to summary
protected final InputStream _in
_inputBufferback to summary
protected final byte[] _inputBuffer
_inputEndback to summary
private int _inputEnd
_inputProcessedback to summary
protected int _inputProcessed

Current number of input units (bytes or chars) that were processed in previous blocks, before contents of current input buffer.

Note

includes possible BOMs, if those were part of the input.

_inputPtrback to summary
private int _inputPtr
UTF8_BOM_1back to summary
pack-priv static final byte UTF8_BOM_1
UTF8_BOM_2back to summary
pack-priv static final byte UTF8_BOM_2
UTF8_BOM_3back to summary
pack-priv static final byte UTF8_BOM_3

Constructor Detail

CsvParserBootstrapperback to summary
public CsvParserBootstrapper(IOContext ctxt, ObjectCodec codec, InputStream in)
CsvParserBootstrapperback to summary
public CsvParserBootstrapper(IOContext ctxt, ObjectCodec codec, byte[] inputBuffer, int inputStart, int inputLen)

Method Detail

_createReaderback to summary
private Reader _createReader(JsonEncoding enc, boolean autoClose) throws IOException
Annotations
@SuppressWarnings:resource
checkUTF16back to summary
private boolean checkUTF16(int i16)
checkUTF32back to summary
private boolean checkUTF32(int quad) throws IOException
constructParserback to summary
public CsvParser constructParser(int baseFeatures, int csvFeatures) throws IOException
ensureLoadedback to summary
protected boolean ensureLoaded(int minimum) throws IOException
handleBOMback to summary
private boolean handleBOM(int quad) throws IOException
Returns:boolean

True if a BOM was successfully found, and encoding thereby recognized.

hasCSVFormatback to summary
public static MatchStrength hasCSVFormat(InputAccessor acc, int quoteChar, char separatorChar) throws IOException

Current implementation is not as thorough as one used by other data formats like JSON. But it should work, for now, and can be improved as necessary.

reportWeirdUCS4back to summary
private void reportWeirdUCS4(String type) throws IOException
skipSpaceback to summary
private static final int skipSpace(InputAccessor acc, byte b) throws IOException