Top Description Fields Constructors Methods
com.fasterxml.jackson.dataformat.javaprop.io

public final Class Latin1Reader

extends Reader
Class Inheritance
Imports
java.io.*, com.fasterxml.jackson.core.io.IOContext

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

Modifier and TypeField and Description
private int
_charCount

Total read character count; used for error reporting purposes

private byte[]
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 than mByteBufferEnd

private InputStream
private final IOContext
_ioContext

IO context to use for returning input buffer, iff buffer is to be recycled when input ends.

private char[]
Inherited from java.io.Reader:
lock

Constructor Summary

AccessConstructor and Description
public
Latin1Reader(byte[] buf, int ptr, int len)

public

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements abstract java.io.Reader.close.

Implements java.io.Closeable.close.

Closes the stream and releases any system resources associated with it.

private final void
freeBuffers()

This method should be called along with (or instead of) normal close.

public int
private boolean

Returns:

True, if enough bytes were read to allow decoding of at least one full character; false if EOF was encountered instead.
loadMore
()

public int
read()

Overrides java.io.Reader.read.

Reads a single character.

public int
read(char[]
Destination buffer
cbuf
)

Overrides java.io.Reader.read.

Reads characters into an array.

public int
read(char[]
Destination buffer
cbuf
,
int
Offset at which to start storing characters
start
,
int
Maximum number of characters to read
len
)

Implements abstract java.io.Reader.read.

Reads characters into a portion of an array.

Inherited from java.io.Reader:
markmarkSupportednullReaderreadreadyresetskiptransferTo

Field Detail

_charCountback to summary
private int _charCount

Total read character count; used for error reporting purposes

_inputBufferback to summary
private byte[] _inputBuffer
_inputEndback to summary
private int _inputEnd

Pointed to the end marker, that is, position one after the last valid available byte.

_inputPtrback to summary
private int _inputPtr

Pointer to the next available byte (if any), iff less than mByteBufferEnd

_inputSourceback to summary
private InputStream _inputSource
_ioContextback to summary
private final IOContext _ioContext

IO context to use for returning input buffer, iff buffer is to be recycled when input ends.

_tmpBufferback to summary
private char[] _tmpBuffer

Constructor Detail

Latin1Readerback to summary
public Latin1Reader(byte[] buf, int ptr, int len)
Latin1Readerback to summary
public Latin1Reader(IOContext ctxt, InputStream in)

Method Detail

closeback to summary
public void close() throws IOException

Implements abstract java.io.Reader.close.

Implements java.io.Closeable.close.

Doc from java.io.Reader.close.

Closes the stream and releases any system resources associated with it. Once the stream has been closed, further read(), ready(), mark(), reset(), or skip() invocations will throw an IOException. Closing a previously closed stream has no effect.

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs
freeBuffersback to summary
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).

getReadCharsCountback to summary
public int getReadCharsCount()
loadMoreback to summary
private boolean loadMore() throws IOException
Returns:boolean

True, if enough bytes were read to allow decoding of at least one full character; false if EOF was encountered instead.

readback to summary
public int read() throws IOException

Overrides java.io.Reader.read.

Doc from java.io.Reader.read.

Reads a single character. This method will block until a character is available, an I/O error occurs, or the end of the stream is reached.

Subclasses that intend to support efficient single-character input should override this method.

Returns:int

The character read, as an integer in the range 0 to 65535 (0x00-0xffff), or -1 if the end of the stream has been reached

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs
readback to summary
public int read(char[] cbuf) throws IOException

Overrides java.io.Reader.read.

Doc from java.io.Reader.read.

Reads characters into an array. This method will block until some input is available, an I/O error occurs, or the end of the stream is reached.

If the length of cbuf is zero, then no characters are read and 0 is returned; otherwise, there is an attempt to read at least one character. If no character is available because the stream is at its end, the value -1 is returned; otherwise, at least one character is read and stored into cbuf.

Parameters
cbuf:char[]

Destination buffer

Returns:int

The number of characters read, or -1 if the end of the stream has been reached

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs
readback to summary
public int read(char[] cbuf, int start, int len) throws IOException

Implements abstract java.io.Reader.read.

Doc from java.io.Reader.read.

Reads characters into a portion of an array. This method will block until some input is available, an I/O error occurs, or the end of the stream is reached.

If len is zero, then no characters are read and 0 is returned; otherwise, there is an attempt to read at least one character. If no character is available because the stream is at its end, the value -1 is returned; otherwise, at least one character is read and stored into cbuf.

Parameters
cbuf:char[]

Destination buffer

start:int

Offset at which to start storing characters

len:int

Maximum number of characters to read

Returns:int

The number of characters read, or -1 if the end of the stream has been reached

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs