|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.io.Reader
com.jasonclawson.jackson.dataformat.hocon.UTF8Reader
public final class UTF8Reader
This code was poached from jackson-dataformat-yaml. https://github.com/FasterXML/jackson-dataformat-yaml com.fasterxml.jackson.dataformat.yaml.UTF8Reader Optimized Reader that reads UTF-8 encoded content from an input stream. In addition to doing (hopefully) optimal conversion, it can also take array of "pre-read" (leftover) bytes; this is necessary when preliminary stream/reader is trying to figure out underlying character encoding.
| Field Summary | |
|---|---|
protected byte[][] |
_bufferHolder
|
protected static ThreadLocal<SoftReference<byte[][]>> |
_bufferRecycler
This ThreadLocal contains a SoftRerefence
to a byte array used for holding content to decode |
protected byte[] |
_inputBuffer
|
protected int |
_inputEnd
Pointed to the end marker, that is, position one after the last valid available byte. |
protected int |
_inputPtr
Pointer to the next available byte (if any), iff less than mByteBufferEnd |
protected int |
_surrogate
Decoded first character of a surrogate pair, if one needs to be buffered |
| Fields inherited from class java.io.Reader |
|---|
lock |
| Constructor Summary | |
|---|---|
UTF8Reader(byte[] buf,
int ptr,
int len,
boolean autoClose)
|
|
UTF8Reader(InputStream in,
boolean autoClose)
|
|
| Method Summary | |
|---|---|
void |
close()
|
void |
freeBuffers()
This method should be called along with (or instead of) normal close. |
protected InputStream |
getStream()
|
int |
read()
Although this method is implemented by the base class, AND it should never be called by Woodstox code, let's still implement it bit more efficiently just in case |
int |
read(char[] cbuf)
|
int |
read(char[] cbuf,
int start,
int len)
|
protected int |
readBytes()
Method for reading as many bytes from the underlying stream as possible (that fit in the buffer), to the beginning of the buffer. |
protected int |
readBytesAt(int offset)
Method for reading as many bytes from the underlying stream as possible (that fit in the buffer considering offset), to the specified offset. |
protected void |
reportBounds(char[] cbuf,
int start,
int len)
|
protected void |
reportStrangeStream()
|
| Methods inherited from class java.io.Reader |
|---|
mark, markSupported, read, ready, reset, skip |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final ThreadLocal<SoftReference<byte[][]>> _bufferRecycler
ThreadLocal contains a SoftRerefence
to a byte array used for holding content to decode
protected final byte[][] _bufferHolder
protected byte[] _inputBuffer
protected int _inputPtr
mByteBufferEnd
protected int _inputEnd
protected int _surrogate
| Constructor Detail |
|---|
public UTF8Reader(InputStream in,
boolean autoClose)
public UTF8Reader(byte[] buf,
int ptr,
int len,
boolean autoClose)
| Method Detail |
|---|
public void close()
throws IOException
close in interface Closeableclose in class ReaderIOException
public int read()
throws IOException
read in class ReaderIOException
public int read(char[] cbuf)
throws IOException
read in class ReaderIOException
public int read(char[] cbuf,
int start,
int len)
throws IOException
read in class ReaderIOExceptionprotected final InputStream getStream()
protected final int readBytes()
throws IOException
IOException
protected final int readBytesAt(int offset)
throws IOException
IOExceptionpublic final void freeBuffers()
protected void reportBounds(char[] cbuf,
int start,
int len)
throws IOException
IOException
protected void reportStrangeStream()
throws IOException
IOException
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||