Class CsvParserBootstrapper
- java.lang.Object
-
- com.fasterxml.jackson.dataformat.csv.impl.CsvParserBootstrapper
-
public final class CsvParserBootstrapper extends java.lang.ObjectThis 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
Fields Modifier and Type Field Description protected boolean_bigEndianprotected int_bytesPerCharprotected com.fasterxml.jackson.core.ObjectCodec_codecprotected com.fasterxml.jackson.core.io.IOContext_contextprotected java.io.InputStream_inprotected byte[]_inputBufferprivate int_inputEndprotected int_inputProcessedCurrent number of input units (bytes or chars) that were processed in previous blocks, before contents of current input buffer.private int_inputPtr(package private) static byteUTF8_BOM_1(package private) static byteUTF8_BOM_2(package private) static byteUTF8_BOM_3
-
Constructor Summary
Constructors Constructor Description CsvParserBootstrapper(com.fasterxml.jackson.core.io.IOContext ctxt, com.fasterxml.jackson.core.ObjectCodec codec, byte[] inputBuffer, int inputStart, int inputLen)CsvParserBootstrapper(com.fasterxml.jackson.core.io.IOContext ctxt, com.fasterxml.jackson.core.ObjectCodec codec, java.io.InputStream in)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.io.Reader_createReader(com.fasterxml.jackson.core.JsonEncoding enc, boolean autoClose)private booleancheckUTF16(int i16)private booleancheckUTF32(int quad)CsvParserconstructParser(int baseFeatures, int csvFeatures)protected booleanensureLoaded(int minimum)private booleanhandleBOM(int quad)static com.fasterxml.jackson.core.format.MatchStrengthhasCSVFormat(com.fasterxml.jackson.core.format.InputAccessor acc, int quoteChar, char separatorChar)Current implementation is not as thorough as one used by other data formats like JSON.private voidreportWeirdUCS4(java.lang.String type)private static intskipSpace(com.fasterxml.jackson.core.format.InputAccessor acc, byte b)
-
-
-
Field Detail
-
UTF8_BOM_1
static final byte UTF8_BOM_1
- See Also:
- Constant Field Values
-
UTF8_BOM_2
static final byte UTF8_BOM_2
- See Also:
- Constant Field Values
-
UTF8_BOM_3
static final byte UTF8_BOM_3
- See Also:
- Constant Field Values
-
_context
protected final com.fasterxml.jackson.core.io.IOContext _context
-
_codec
protected final com.fasterxml.jackson.core.ObjectCodec _codec
-
_in
protected final java.io.InputStream _in
-
_inputBuffer
protected final byte[] _inputBuffer
-
_inputPtr
private int _inputPtr
-
_inputEnd
private int _inputEnd
-
_inputProcessed
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.
-
_bigEndian
protected boolean _bigEndian
-
_bytesPerChar
protected int _bytesPerChar
-
-
Constructor Detail
-
CsvParserBootstrapper
public CsvParserBootstrapper(com.fasterxml.jackson.core.io.IOContext ctxt, com.fasterxml.jackson.core.ObjectCodec codec, java.io.InputStream in)
-
CsvParserBootstrapper
public CsvParserBootstrapper(com.fasterxml.jackson.core.io.IOContext ctxt, com.fasterxml.jackson.core.ObjectCodec codec, byte[] inputBuffer, int inputStart, int inputLen)
-
-
Method Detail
-
constructParser
public CsvParser constructParser(int baseFeatures, int csvFeatures) throws java.io.IOException
- Throws:
java.io.IOException
-
_createReader
private java.io.Reader _createReader(com.fasterxml.jackson.core.JsonEncoding enc, boolean autoClose) throws java.io.IOException- Throws:
java.io.IOException
-
hasCSVFormat
public static com.fasterxml.jackson.core.format.MatchStrength hasCSVFormat(com.fasterxml.jackson.core.format.InputAccessor acc, int quoteChar, char separatorChar) throws java.io.IOExceptionCurrent 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.- Throws:
java.io.IOException
-
skipSpace
private static final int skipSpace(com.fasterxml.jackson.core.format.InputAccessor acc, byte b) throws java.io.IOException- Throws:
java.io.IOException
-
handleBOM
private boolean handleBOM(int quad) throws java.io.IOException- Returns:
- True if a BOM was successfully found, and encoding thereby recognized.
- Throws:
java.io.IOException
-
checkUTF32
private boolean checkUTF32(int quad) throws java.io.IOException- Throws:
java.io.IOException
-
checkUTF16
private boolean checkUTF16(int i16)
-
reportWeirdUCS4
private void reportWeirdUCS4(java.lang.String type) throws java.io.IOException- Throws:
java.io.IOException
-
ensureLoaded
protected boolean ensureLoaded(int minimum) throws java.io.IOException- Throws:
java.io.IOException
-
-