Class Latin1Reader
- java.lang.Object
-
- java.io.Reader
-
- com.fasterxml.jackson.dataformat.javaprop.io.Latin1Reader
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,java.lang.Readable
public final class Latin1Reader extends java.io.Reader
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
Fields Modifier and Type Field Description private int
_charCount
Total read character count; used for error reporting purposesprivate byte[]
_inputBuffer
private int
_inputEnd
Pointed to the end marker, that is, position one after the last valid available byte.private int
_inputPtr
Pointer to the next available byte (if any), iff less thanmByteBufferEnd
private java.io.InputStream
_inputSource
private com.fasterxml.jackson.core.io.IOContext
_ioContext
IO context to use for returning input buffer, iff buffer is to be recycled when input ends.private char[]
_tmpBuffer
-
Constructor Summary
Constructors Constructor Description Latin1Reader(byte[] buf, int ptr, int len)
Latin1Reader(com.fasterxml.jackson.core.io.IOContext ctxt, java.io.InputStream in)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
private void
freeBuffers()
This method should be called along with (or instead of) normal close.int
getReadCharsCount()
private boolean
loadMore()
int
read()
int
read(char[] cbuf)
int
read(char[] cbuf, int start, int len)
-
-
-
Field Detail
-
_ioContext
private final com.fasterxml.jackson.core.io.IOContext _ioContext
IO context to use for returning input buffer, iff buffer is to be recycled when input ends.
-
_inputSource
private java.io.InputStream _inputSource
-
_inputBuffer
private byte[] _inputBuffer
-
_inputPtr
private int _inputPtr
Pointer to the next available byte (if any), iff less thanmByteBufferEnd
-
_inputEnd
private int _inputEnd
Pointed to the end marker, that is, position one after the last valid available byte.
-
_charCount
private int _charCount
Total read character count; used for error reporting purposes
-
_tmpBuffer
private char[] _tmpBuffer
-
-
Method Detail
-
getReadCharsCount
public int getReadCharsCount()
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Specified by:
close
in classjava.io.Reader
- Throws:
java.io.IOException
-
read
public int read() throws java.io.IOException
- Overrides:
read
in classjava.io.Reader
- Throws:
java.io.IOException
-
read
public int read(char[] cbuf) throws java.io.IOException
- Overrides:
read
in classjava.io.Reader
- Throws:
java.io.IOException
-
read
public int read(char[] cbuf, int start, int len) throws java.io.IOException
- Specified by:
read
in classjava.io.Reader
- Throws:
java.io.IOException
-
loadMore
private boolean loadMore() throws java.io.IOException
- 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:
java.io.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).
-
-