Package org.codehaus.jackson.impl
Class ByteSourceBootstrapper
- java.lang.Object
-
- org.codehaus.jackson.impl.ByteSourceBootstrapper
-
public final class ByteSourceBootstrapper extends java.lang.Object
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
Fields Modifier and Type Field Description protected boolean
_bigEndian
protected int
_bytesPerChar
protected IOContext
_context
protected java.io.InputStream
_in
protected byte[]
_inputBuffer
protected int
_inputProcessed
Current number of input units (bytes or chars) that were processed in previous blocks, before contents of current input buffer.
-
Constructor Summary
Constructors Constructor Description ByteSourceBootstrapper(IOContext ctxt, byte[] inputBuffer, int inputStart, int inputLen)
ByteSourceBootstrapper(IOContext ctxt, java.io.InputStream in)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description JsonParser
constructParser(int features, ObjectCodec codec, BytesToNameCanonicalizer rootByteSymbols, CharsToNameCanonicalizer rootCharSymbols)
java.io.Reader
constructReader()
JsonEncoding
detectEncoding()
Method that should be called after constructing an instace.protected boolean
ensureLoaded(int minimum)
static MatchStrength
hasJSONFormat(InputAccessor acc)
Current implementation is not as thorough as other functionality (ByteSourceBootstrapper
); supports UTF-8, for example.
-
-
-
Field Detail
-
_context
protected final IOContext _context
-
_in
protected final java.io.InputStream _in
-
_inputBuffer
protected final byte[] _inputBuffer
-
_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
-
-
Method Detail
-
detectEncoding
public JsonEncoding detectEncoding() throws java.io.IOException, JsonParseException
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.- Throws:
java.io.IOException
JsonParseException
-
constructReader
public java.io.Reader constructReader() throws java.io.IOException
- Throws:
java.io.IOException
-
constructParser
public JsonParser constructParser(int features, ObjectCodec codec, BytesToNameCanonicalizer rootByteSymbols, CharsToNameCanonicalizer rootCharSymbols) throws java.io.IOException, JsonParseException
- Throws:
java.io.IOException
JsonParseException
-
hasJSONFormat
public static MatchStrength hasJSONFormat(InputAccessor acc) throws java.io.IOException
Current implementation is not as thorough as other functionality (ByteSourceBootstrapper
); supports UTF-8, for example. But it should work, for now, and can be improved as necessary.- Throws:
java.io.IOException
- Since:
- 1.8
-
ensureLoaded
protected boolean ensureLoaded(int minimum) throws java.io.IOException
- Throws:
java.io.IOException
-
-