Class UTF8Reader
java.lang.Object
java.io.Reader
com.fasterxml.jackson.dataformat.toml.UTF8Reader
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Readable
Optimized Reader that reads UTF-8 encoded content from an input stream.
Content may come either from a static
byte[]
buffer or
InputStream
.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final boolean
private int
Total read byte count; used for error reporting purposesprivate int
Total read character count; used for error reporting purposesprivate byte[]
private int
Pointed to the end marker, that is, position one after the last valid available byte.private int
Pointer to the next available byte (if any), iff less thanmByteBufferEnd
private InputStream
private final com.fasterxml.jackson.core.io.IOContext
IO context to use for returning input buffer, iff buffer is to be recycled when input ends.private int
Decoded first character of a surrogate pair, if one needs to be bufferedprivate char[]
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
UTF8Reader
(com.fasterxml.jackson.core.io.IOContext ctxt, InputStream in, boolean autoClose, byte[] buf, int ptr, int end) -
Method Summary
Modifier and TypeMethodDescriptionprotected final boolean
Method that can be used to see if we can actually modify the underlying buffer.void
close()
static UTF8Reader
construct
(byte[] buf, int ptr, int len) static UTF8Reader
construct
(com.fasterxml.jackson.core.io.IOContext ctxt, InputStream in, boolean autoClose) private void
This method should be called along with (or instead of) normal close.private boolean
loadMore
(int available) int
read()
int
read
(char[] cbuf) int
read
(char[] cbuf, int start, int len) protected final int
protected final int
readBytesAt
(int offset) protected void
reportBounds
(char[] cbuf, int start, int len) private void
reportInvalidInitial
(int mask, int offset) private void
reportInvalidOther
(int mask, int offset) protected void
private void
reportUnexpectedEOF
(int gotBytes, int needed) Methods inherited from class java.io.Reader
mark, markSupported, nullReader, read, ready, reset, skip, transferTo
-
Field Details
-
_ioContext
private final com.fasterxml.jackson.core.io.IOContext _ioContextIO context to use for returning input buffer, iff buffer is to be recycled when input ends. -
_inputSource
-
_autoClose
private final boolean _autoClose -
_inputBuffer
private byte[] _inputBuffer -
_inputPtr
private int _inputPtrPointer to the next available byte (if any), iff less thanmByteBufferEnd
-
_inputEnd
private int _inputEndPointed to the end marker, that is, position one after the last valid available byte. -
_surrogate
private int _surrogateDecoded first character of a surrogate pair, if one needs to be buffered -
_charCount
private int _charCountTotal read character count; used for error reporting purposes -
_byteCount
private int _byteCountTotal read byte count; used for error reporting purposes -
_tmpBuffer
private char[] _tmpBuffer
-
-
Constructor Details
-
UTF8Reader
private UTF8Reader(com.fasterxml.jackson.core.io.IOContext ctxt, InputStream in, boolean autoClose, byte[] buf, int ptr, int end)
-
-
Method Details
-
construct
public static UTF8Reader construct(com.fasterxml.jackson.core.io.IOContext ctxt, InputStream in, boolean autoClose) -
construct
-
freeBuffers
private void freeBuffers()This method should be called along with (or instead of) normal close. After calling this method, no further reads should be tried. Method will try to recycle read buffers (if any). -
canModifyBuffer
protected final boolean canModifyBuffer()Method that can be used to see if we can actually modify the underlying buffer. This is the case if we are managing the buffer, but not if it was just given to us. -
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in classReader
- Throws:
IOException
-
read
- Overrides:
read
in classReader
- Throws:
IOException
-
read
- Overrides:
read
in classReader
- Throws:
IOException
-
read
- Specified by:
read
in classReader
- Throws:
IOException
-
loadMore
- Parameters:
available
- Number of "unused" bytes in the input buffer- Returns:
- True, if enough bytes were read to allow decoding of at least one full character; false if EOF was encountered instead.
- Throws:
IOException
-
readBytes
- Throws:
IOException
-
readBytesAt
- Throws:
IOException
-
reportInvalidInitial
- Throws:
IOException
-
reportInvalidOther
- Throws:
IOException
-
reportUnexpectedEOF
- Throws:
IOException
-
reportBounds
- Throws:
IOException
-
reportStrangeStream
- Throws:
IOException
-