org.aminds.io
クラス LookaheadReader

java.lang.Object
  上位を拡張 java.io.Reader
      上位を拡張 java.io.FilterReader
          上位を拡張 org.aminds.io.ReusableFilterReader
              上位を拡張 org.aminds.io.LookaheadReader
すべての実装されたインタフェース:
Closeable, Readable

public class LookaheadReader
extends ReusableFilterReader

A Reader that is capable of looking ahead. It allows to read code points as well as chars (Unicode code units).

作成者:
Masashi Nakanishi

フィールドの概要
protected  CharQueue queue
           
 
クラス java.io.FilterReader から継承されたフィールド
in
 
クラス java.io.Reader から継承されたフィールド
lock
 
コンストラクタの概要
LookaheadReader(Reader in)
           
LookaheadReader(Reader in, int initCapacity)
           
 
メソッドの概要
 void close()
           
 int codePointAt(int index)
           
 int lookahead(int index)
          Look ahead a character at the position specified by the index from the current position of the stream.
 int lookaheadCodePoint()
          Look ahead a next character as Unicode code point, not as UTF-16 code unit.
 int lookaheadCodePoint(int index)
          Look ahead a character as Unicode code point, not as UTF-16 code unit, at the position specified.
 void mark(int readAheadLimit)
           
 boolean markSupported()
           
 int offsetsByCodePoints(int index, int codePointOffset)
           
 int read()
           
 int read(char[] cbuf, int off, int len)
           
 int readCodePoint()
          Read a single code point, not a character as UTF-16 code unit, contrasting with read().
 boolean ready()
           
 void reset()
           
 void reset(Reader in)
          Reset the contained Reader.
 void reset(Reader in, int capacity)
           
 long skip(long n)
           
 long skipCodePoint(long n)
          Skip characters by units of code point.
 
クラス java.io.Reader から継承されたメソッド
read, read
 
クラス java.lang.Object から継承されたメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

フィールドの詳細

queue

protected CharQueue queue
コンストラクタの詳細

LookaheadReader

public LookaheadReader(Reader in)

LookaheadReader

public LookaheadReader(Reader in,
                       int initCapacity)
メソッドの詳細

read

public int read()
         throws IOException
オーバーライド:
クラス FilterReader 内の read
例外:
IOException

read

public int read(char[] cbuf,
                int off,
                int len)
         throws IOException
オーバーライド:
クラス FilterReader 内の read
例外:
IOException

skip

public long skip(long n)
          throws IOException
オーバーライド:
クラス FilterReader 内の skip
例外:
IOException

ready

public boolean ready()
              throws IOException
オーバーライド:
クラス FilterReader 内の ready
例外:
IOException

markSupported

public boolean markSupported()
オーバーライド:
クラス FilterReader 内の markSupported

mark

public void mark(int readAheadLimit)
          throws IOException
オーバーライド:
クラス FilterReader 内の mark
例外:
IOException

reset

public void reset()
           throws IOException
オーバーライド:
クラス FilterReader 内の reset
例外:
IOException

close

public void close()
           throws IOException
定義:
インタフェース Closeable 内の close
オーバーライド:
クラス FilterReader 内の close
例外:
IOException

reset

public void reset(Reader in)
           throws IOException
クラス ReusableFilterReader の記述:
Reset the contained Reader. Note that this method does neither invoke reset() nor close() method of the underlying Reader, while FilterReader.reset() does invoke reset() of the underlying.

オーバーライド:
クラス ReusableFilterReader 内の reset
パラメータ:
in - a new Reader
例外:
IOException

reset

public void reset(Reader in,
                  int capacity)
           throws IOException
例外:
IOException

lookahead

public int lookahead(int index)
              throws IOException
Look ahead a character at the position specified by the index from the current position of the stream. It allows to get information ahead without moving forward the current position of the stream. This method will block until some characters is available, an I/O error occurs, or the end of the stream is reached.

パラメータ:
index - a position relative to the current position of the stream, >= 0
戻り値:
the character (as UTF-16 code unit) looked
例外:
IllegalArgumentException - If index is negative.
IOException - If an I/O error occurs

readCodePoint

public int readCodePoint()
                  throws IOException
Read a single code point, not a character as UTF-16 code unit, contrasting with read(). This method will block until some characters is available, an I/O error occurs, or the end of the stream is reached.

戻り値:
the Unicode code point (0x00 to 0x10FFFF) read, or -1 if the end of the stream has been reached
例外:
IOException - If an I/O error occurs

lookaheadCodePoint

public int lookaheadCodePoint()
                       throws IOException
Look ahead a next character as Unicode code point, not as UTF-16 code unit. It allows to get information ahead without moving forward the current position of the stream. This method will block until some characters is available, an I/O error occurs, or the end of the stream is reached.

戻り値:
the Unicode code point (0x00 to 0x10FFFF) looked, or -1 if there is no character to be read
例外:
IOException - If an I/O error occurs

lookaheadCodePoint

public int lookaheadCodePoint(int index)
                       throws IOException
Look ahead a character as Unicode code point, not as UTF-16 code unit, at the position specified. It allows to get information ahead without moving forward the current position of the stream. This method will block until some characters is available, an I/O error occurs, or the end of the stream is reached.

FIXME: we may need faster implementation.

パラメータ:
index - index by units of code point, relative to the current position of the stream, >= 0
戻り値:
the Unicode code point looked, not an UTF-16 code unit, or -1 if there is no character to be read
例外:
IllegalArgumentException - If index is negative.
IOException - If an I/O error occurs

offsetsByCodePoints

public int offsetsByCodePoints(int index,
                               int codePointOffset)

codePointAt

public int codePointAt(int index)

skipCodePoint

public long skipCodePoint(long n)
                   throws IOException
Skip characters by units of code point. This method will block until some characters are available, an I/O error occurs, or the end of the stream is reached.

パラメータ:
n - The number of code points to skip
戻り値:
The number of code points actually skipped
例外:
IllegalArgumentException - If n is negative.
IOException - If an I/O error occurs


Copyright (c) 2008-2011 Masashi Nakanishi.