2
package com.fasterxml.jackson.core.io;
7
* Simple basic class for optimized readers in this package; implements
8
* "cookie-cutter" methods that are used by all actual implementations.
10
abstract class BaseReader
14
* JSON actually limits available Unicode range in the high end
15
* to the same as xml (to basically limit UTF-8 max byte sequence
18
final protected static int LAST_VALID_UNICODE_CHAR = 0x10FFFF;
20
final protected static char NULL_CHAR = (char) 0;
21
final protected static char NULL_BYTE = (byte) 0;
23
final protected IOContext _context;
25
protected InputStream _in;
27
protected byte[] _buffer;
30
protected int _length;
33
/**********************************************************
35
/**********************************************************
38
protected BaseReader(IOContext context,
39
InputStream in, byte[] buf, int ptr, int len)
49
/**********************************************************
51
/**********************************************************
55
public void close() throws IOException
66
protected char[] _tmpBuf = null;
69
* Although this method is implemented by the base class, AND it should
70
* never be called by main code, let's still implement it bit more
71
* efficiently just in case
74
public int read() throws IOException
76
if (_tmpBuf == null) {
77
_tmpBuf = new char[1];
79
if (read(_tmpBuf, 0, 1) < 1) {
86
/**********************************************************
87
/* Internal/package methods:
88
/**********************************************************
92
* This method should be called along with (or instead of) normal
93
* close. After calling this method, no further reads should be tried.
94
* Method will try to recycle read buffers (if any).
96
public final void freeBuffers()
101
_context.releaseReadIOBuffer(buf);
105
protected void reportBounds(char[] cbuf, int start, int len)
108
throw new ArrayIndexOutOfBoundsException("read(buf,"+start+","+len+"), cbuf["+cbuf.length+"]");
111
protected void reportStrangeStream()
114
throw new IOException("Strange I/O stream, returned 0 bytes on read");