Package com.fasterxml.jackson.core.json
Class ByteSourceJsonBootstrapper
java.lang.Object
com.fasterxml.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
Modifier and TypeFieldDescriptionstatic final byte
static final byte
static final byte
-
Constructor Summary
ConstructorDescriptionByteSourceJsonBootstrapper
(IOContext ctxt, byte[] inputBuffer, int inputStart, int inputLen) ByteSourceJsonBootstrapper
(IOContext ctxt, InputStream in) -
Method Summary
Modifier and TypeMethodDescriptionconstructParser
(int parserFeatures, ObjectCodec codec, ByteQuadsCanonicalizer rootByteSymbols, CharsToNameCanonicalizer rootCharSymbols, int factoryFeatures) Method that should be called after constructing an instace.protected boolean
ensureLoaded
(int minimum) static MatchStrength
Current implementation is not as thorough as other functionality (ByteSourceJsonBootstrapper
); supports UTF-8, for example.static int
skipUTF8BOM
(DataInput input) Helper method that may be called to see if givenDataInput
has 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:
-
-
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:
JsonEncoding
detected, if any;JsonEncoding.UTF8
otherwise- Throws:
IOException
- If read from underlying input source fails
-
skipUTF8BOM
Helper method that may be called to see if givenDataInput
has 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:
IOException
- If read from underlying input source fails- Since:
- 2.8
-
constructReader
- Throws:
IOException
-
constructParser
public JsonParser constructParser(int parserFeatures, ObjectCodec codec, ByteQuadsCanonicalizer rootByteSymbols, CharsToNameCanonicalizer rootCharSymbols, int factoryFeatures) throws IOException - Throws:
IOException
-
hasJSONFormat
Current implementation is not as thorough as other functionality (ByteSourceJsonBootstrapper
); supports UTF-8, for example. But it should work, for now, and can be improved as necessary.- Parameters:
acc
- InputAccessor to use for accessing content to check- Returns:
- Strength of match (never
null
) - Throws:
IOException
- if input access fails due to read problem
-
ensureLoaded
- Throws:
IOException
-