Class Latin1Reader
java.lang.Object
java.io.Reader
com.fasterxml.jackson.dataformat.javaprop.io.Latin1Reader
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Readable
Optimized Reader that reads ISO-8859-1 encoded content from an input stream.
The reason for custom implementation is that this allows recycling of
underlying read buffer, which is important for small content.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate 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 char[]
-
Constructor Summary
ConstructorsConstructorDescriptionLatin1Reader
(byte[] buf, int ptr, int len) Latin1Reader
(com.fasterxml.jackson.core.io.IOContext ctxt, InputStream in) -
Method Summary
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
-
_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. -
_charCount
private int _charCountTotal read character count; used for error reporting purposes -
_tmpBuffer
private char[] _tmpBuffer
-
-
Constructor Details
-
Latin1Reader
public Latin1Reader(byte[] buf, int ptr, int len) -
Latin1Reader
-
-
Method Details
-
getReadCharsCount
public int getReadCharsCount() -
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
- Returns:
- True, if enough bytes were read to allow decoding of at least one full character; false if EOF was encountered instead.
- Throws:
IOException
-
freeBuffers
private final 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).
-