JSON
Version 1.0

org.codehaus.jackson.io
Class UTF8Reader

java.lang.Object
  extended by java.io.Reader
      extended by org.codehaus.jackson.io.UTF8Reader
All Implemented Interfaces:
Closeable, Readable

public final class UTF8Reader
extends Reader

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 character encoding.


Field Summary
protected static int LAST_VALID_UNICODE_CHAR
          JSON actually limits available Unicode range in the high end to the same as xml (to basically limit UTF-8 max byte sequence length to 4)
protected  byte[] mBuffer
           
protected  IOContext mContext
           
protected  InputStream mIn
           
protected  int mLength
           
protected  int mPtr
           
protected static char NULL_BYTE
           
protected static char NULL_CHAR
           
 
Fields inherited from class java.io.Reader
lock
 
Constructor Summary
UTF8Reader(IOContext ctxt, InputStream in, byte[] buf, int ptr, int len)
           
 
Method Summary
 void close()
           
 void freeBuffers()
          This method should be called along with (or instead of) normal close.
 int read()
          Although this method is implemented by the base class, AND it should never be called by main code, let's still implement it bit more efficiently just in case
 int read(char[] cbuf, int start, int len)
           
protected  void reportBounds(char[] cbuf, int start, int len)
           
protected  void reportStrangeStream()
           
 
Methods inherited from class java.io.Reader
mark, markSupported, read, read, ready, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LAST_VALID_UNICODE_CHAR

protected static final int LAST_VALID_UNICODE_CHAR
JSON actually limits available Unicode range in the high end to the same as xml (to basically limit UTF-8 max byte sequence length to 4)

See Also:
Constant Field Values

NULL_CHAR

protected static final char NULL_CHAR
See Also:
Constant Field Values

NULL_BYTE

protected static final char NULL_BYTE
See Also:
Constant Field Values

mContext

protected final IOContext mContext

mIn

protected InputStream mIn

mBuffer

protected byte[] mBuffer

mPtr

protected int mPtr

mLength

protected int mLength
Constructor Detail

UTF8Reader

public UTF8Reader(IOContext ctxt,
                  InputStream in,
                  byte[] buf,
                  int ptr,
                  int len)
Method Detail

read

public int read(char[] cbuf,
                int start,
                int len)
         throws IOException
Specified by:
read in class Reader
Throws:
IOException

close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Specified by:
close in class Reader
Throws:
IOException

read

public int read()
         throws IOException
Although this method is implemented by the base class, AND it should never be called by main code, let's still implement it bit more efficiently just in case

Overrides:
read in class Reader
Throws:
IOException

freeBuffers

public 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).


reportBounds

protected void reportBounds(char[] cbuf,
                            int start,
                            int len)
                     throws IOException
Throws:
IOException

reportStrangeStream

protected void reportStrangeStream()
                            throws IOException
Throws:
IOException

JSON
Version 1.0

Apache License, Version 2.0