Class ByteSourceJsonBootstrapper
java.lang.Object
tools.jackson.core.json.ByteSourceJsonBootstrapper
This class is used to determine the encoding of byte stream
that is to contain JSON content. Rules are fairly simple, and
defined in JSON specification (RFC-4627 or newer), except
for BOM handling, which is a property of underlying
streams.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanWhether input has been detected to be in Big-Endian encoding or not.private final booleanFlag that indicates whether buffer above is to be recycled after being used or not.private intprivate final IOContextprivate final InputStreamprivate final byte[]private intprivate intprivate static final intstatic final bytestatic final bytestatic final byte -
Constructor Summary
ConstructorsConstructorDescriptionByteSourceJsonBootstrapper(IOContext ctxt, byte[] inputBuffer, int inputStart, int inputLen) ByteSourceJsonBootstrapper(IOContext ctxt, InputStream in) -
Method Summary
Modifier and TypeMethodDescriptionprivate JacksonException_createIOFailure(String msg) private void_reportWeirdUCS4(String type) private static JacksonExceptionprivate booleancheckUTF16(int i16) private booleancheckUTF32(int quad) constructParser(ObjectReadContext readCtxt, int streamReadFeatures, int formatReadFeatures, ByteQuadsCanonicalizer rootByteSymbols, CharsToNameCanonicalizer rootCharSymbols, int factoryFeatures) Method that should be called after constructing an instace.protected booleanensureLoaded(int minimum) private booleanhandleBOM(int quad) static intskipUTF8BOM(DataInput input) Helper method that may be called to see if givenDataInputhas BOM marker, and if so, to skip it.
-
Field Details
-
UTF8_BOM_1
public static final byte UTF8_BOM_1- See Also:
-
UTF8_BOM_2
public static final byte UTF8_BOM_2- See Also:
-
UTF8_BOM_3
public static final byte UTF8_BOM_3- See Also:
-
STRING_READER_BYTE_ARRAY_LENGTH_LIMIT
private static final int STRING_READER_BYTE_ARRAY_LENGTH_LIMIT- See Also:
-
_context
-
_in
-
_inputBuffer
private final byte[] _inputBuffer -
_inputPtr
private int _inputPtr -
_inputEnd
private int _inputEnd -
_bufferRecyclable
private final boolean _bufferRecyclableFlag that indicates whether buffer above is to be recycled after being used or not. -
_bigEndian
private boolean _bigEndianWhether input has been detected to be in Big-Endian encoding or not. -
_bytesPerChar
private int _bytesPerChar
-
-
Constructor Details
-
ByteSourceJsonBootstrapper
-
ByteSourceJsonBootstrapper
-
-
Method Details
-
detectEncoding
Method that should be called after constructing an instace. It will figure out encoding that content uses, to allow for instantiating a proper scanner object.- Returns:
JsonEncodingdetected, if any;JsonEncoding.UTF8otherwise- Throws:
JacksonException- If read from underlying input source fails
-
skipUTF8BOM
Helper method that may be called to see if givenDataInputhas BOM marker, and if so, to skip it.- Parameters:
input- DataInput to read content from- Returns:
- Byte (as unsigned
int) read after possible UTF-8 BOM - Throws:
JacksonException- If read from underlying input source fails
-
constructReader
- Throws:
JacksonException
-
constructParser
public JsonParser constructParser(ObjectReadContext readCtxt, int streamReadFeatures, int formatReadFeatures, ByteQuadsCanonicalizer rootByteSymbols, CharsToNameCanonicalizer rootCharSymbols, int factoryFeatures) throws JacksonException - Throws:
JacksonException
-
handleBOM
- Returns:
- True if a BOM was succesfully found, and encoding thereby recognized.
- Throws:
JacksonException
-
checkUTF32
- Throws:
JacksonException
-
checkUTF16
private boolean checkUTF16(int i16) -
_reportWeirdUCS4
- Throws:
JacksonException
-
ensureLoaded
- Throws:
JacksonException
-
_createIOFailure
- Throws:
JacksonException
-
_wrapIOFailure
- Throws:
JacksonException
-