Package com.fasterxml.jackson.core.json
Class ByteSourceJsonBootstrapper
- java.lang.Object
-
- com.fasterxml.jackson.core.json.ByteSourceJsonBootstrapper
-
public final class ByteSourceJsonBootstrapper extends java.lang.ObjectThis 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
Fields Modifier and Type Field Description static byteUTF8_BOM_1static byteUTF8_BOM_2static byteUTF8_BOM_3
-
Constructor Summary
Constructors Constructor Description ByteSourceJsonBootstrapper(IOContext ctxt, byte[] inputBuffer, int inputStart, int inputLen)ByteSourceJsonBootstrapper(IOContext ctxt, java.io.InputStream in)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description JsonParserconstructParser(int parserFeatures, ObjectCodec codec, ByteQuadsCanonicalizer rootByteSymbols, CharsToNameCanonicalizer rootCharSymbols, int factoryFeatures)java.io.ReaderconstructReader()JsonEncodingdetectEncoding()Method that should be called after constructing an instace.static MatchStrengthhasJSONFormat(InputAccessor acc)Current implementation is not as thorough as other functionality (ByteSourceJsonBootstrapper); supports UTF-8, for example.static intskipUTF8BOM(java.io.DataInput input)Helper method that may be called to see if givenDataInputhas BOM marker, and if so, to skip it.
-
-
-
Field Detail
-
UTF8_BOM_1
public static final byte UTF8_BOM_1
- See Also:
- Constant Field Values
-
UTF8_BOM_2
public static final byte UTF8_BOM_2
- See Also:
- Constant Field Values
-
UTF8_BOM_3
public static final byte UTF8_BOM_3
- See Also:
- Constant Field Values
-
-
Method Detail
-
detectEncoding
public JsonEncoding detectEncoding() throws java.io.IOException
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:
java.io.IOException- If read from underlying input source fails
-
skipUTF8BOM
public static int skipUTF8BOM(java.io.DataInput input) throws java.io.IOExceptionHelper 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:
java.io.IOException- If read from underlying input source fails- Since:
- 2.8
-
constructReader
public java.io.Reader constructReader() throws java.io.IOException- Throws:
java.io.IOException
-
constructParser
public JsonParser constructParser(int parserFeatures, ObjectCodec codec, ByteQuadsCanonicalizer rootByteSymbols, CharsToNameCanonicalizer rootCharSymbols, int factoryFeatures) throws java.io.IOException
- Throws:
java.io.IOException
-
hasJSONFormat
public static MatchStrength hasJSONFormat(InputAccessor acc) throws java.io.IOException
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:
java.io.IOException- if input access fails due to read problem
-
-