ohymosj
クラス OhBufferedReader

java.lang.Object
  拡張java.io.Reader
      拡張java.io.BufferedReader
          拡張ohymosj.OhBufferedReader

public class OhBufferedReader
extends java.io.BufferedReader

クラス BufferedReader に単語の読み取り機能を追加したクラスです。

BufferedReader は、行の読み取りはできますが、単語の読み取りが できません。この OhBufferedReader は、

  1. readWord() によって、空白文字(半角空白、タブ、改行文字) を区切り文字と見なして、単語を切り出すことができます。
  2. コメントを読み飛ばすように指定できます。指定すれば、行頭に # がある行は無視されます。行の途中に、# があると、そこか ら行末まで無視されます。
この OhBufferedReader は、データを読み取るために、ストリーム から1行を取得し、それをメモリに保持しています。メモリ内の文字 列を走査して、単語を切り出します。 コンストラクタ以外に定義されている関数は、 getTreatCommentFlag(), pushBack(), read(), readLine(), readWord(), skipWhites(), treatComment(boolean aMode) です。これ以外に親クラスから継承した関数で使用して良いものは、 close() です。

バージョン:
$Revision: 1.5 $ $Date: 2004/02/10 14:19:13 $

フィールドの概要
protected  int _ipos
           
protected  int _lineno
           
protected  java.lang.String _nextLine
           
protected  boolean _treatCommentP
           
protected static java.lang.String NEWLINE
           
 
クラス java.io.Reader から継承したフィールド
lock
 
コンストラクタの概要
OhBufferedReader(java.io.Reader aIn)
          Creates a new OhBufferedReader instance.
OhBufferedReader(java.io.Reader aIn, boolean aTreatCommentP)
           
OhBufferedReader(java.io.Reader aIn, int aSz)
          Creates a new OhBufferedReader instance.
OhBufferedReader(java.io.Reader aIn, int aSz, boolean aTreatCommentP)
           
 
メソッドの概要
 boolean getTreatCommentP()
          Returns the boolean flag about treat-comment-mode.
 void mark(int a)
           
 void pushBack()
          Push back the last character which had been read in to this Reader.
 int read()
          Read one character.
 int read(char[] cbuf, int off, int len)
           
 java.lang.String readLine()
          Reads a line of text.
 java.lang.String readWord()
          Read a word.
 void reset()
           
 void setTreatCommentP(boolean aTreatCommentP)
          Sets treat-comment-mode on.
 long skip(long n)
           
 int skipWhites()
          Skip white letters.
 
クラス java.io.BufferedReader から継承したメソッド
close, markSupported, ready
 
クラス java.io.Reader から継承したメソッド
read
 
クラス java.lang.Object から継承したメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

フィールドの詳細

_nextLine

protected java.lang.String _nextLine

_ipos

protected int _ipos

_treatCommentP

protected boolean _treatCommentP

_lineno

protected int _lineno

NEWLINE

protected static java.lang.String NEWLINE
コンストラクタの詳細

OhBufferedReader

public OhBufferedReader(java.io.Reader aIn)
Creates a new OhBufferedReader instance.


OhBufferedReader

public OhBufferedReader(java.io.Reader aIn,
                        boolean aTreatCommentP)

OhBufferedReader

public OhBufferedReader(java.io.Reader aIn,
                        int aSz)
Creates a new OhBufferedReader instance.


OhBufferedReader

public OhBufferedReader(java.io.Reader aIn,
                        int aSz,
                        boolean aTreatCommentP)
メソッドの詳細

pushBack

public void pushBack()
Push back the last character which had been read in to this Reader. Only the character which bad been read in from the current line can be pushed back.
この Reader に最後に読み込まれた文字を読まなかったことにし て、元に戻します。ただし、戻すことができるのは、現在読み込 みの対象になっている行から読まれた文字だけです。


setTreatCommentP

public void setTreatCommentP(boolean aTreatCommentP)
Sets treat-comment-mode on. When treat-comment-mode is on,
  1. lines which start with '#' are ignored;
  2. part string from '#' to the line end is ignored.
In default, treat-comment-mode is off.

戻り値:
a boolean value

getTreatCommentP

public boolean getTreatCommentP()
Returns the boolean flag about treat-comment-mode. If this flag is true, treat-comment-mode is on.

戻り値:
a boolean value

read

public int read()
         throws java.io.IOException
Read one character. When eof was deteced, return -1. When the reading pointer is at the line end, return '\n'.

戻り値:
an int value
例外:
java.io.IOException - if an error occurs

readLine

public java.lang.String readLine()
                          throws java.io.IOException
Reads a line of text.
現在の読み取り位置から行末まで読み取って返します。

現在の読みとり位置がファイル終端に来ているときは、 readLine() は、null を返します。

現在の読み取り位置が行末にあるときは、空き文字列を返します。

つぎの読み取りポイントは、このメソッドで読取った行のつ ぎの行の行頭になります。

戻り値:
a String value
例外:
java.io.IOException - if an error occurs

readWord

public java.lang.String readWord()
                          throws java.io.IOException
Read a word.
単語を読みとります。読み取り位置が行末なら、つぎの行から単 語を読みます。単語を読み取ろうとしたときに、空行 (行頭にす ぐ改行がある行) に遭遇したら、空き文字列を返します。

単語とは、

  1. 引用符号以外の非空白文字の連続
  2. 引用符号 (" または ') から引用符号までの文字列
を言います。

戻り値:
a String value
例外:
java.io.IOException - if an error occurs

skipWhites

public int skipWhites()
               throws java.io.IOException
Skip white letters. The line end mark is also skipped.
空白文字 (半角空白、タブ文字、改行文字) を読み飛ばし、非空 白文字の上に読み取りポイントを移動します。 空白文字を読み飛ばしている間に、ファイルの終端に達したとき は、-1 を返します。それ以外のときは、読み取りポイントの文字 のコードを返します。

例外:
java.io.IOException

skip

public long skip(long n)
          throws java.io.IOException
例外:
java.io.IOException

read

public int read(char[] cbuf,
                int off,
                int len)
         throws java.io.IOException
例外:
java.io.IOException

mark

public void mark(int a)
          throws java.io.IOException
例外:
java.io.IOException

reset

public void reset()
           throws java.io.IOException
例外:
java.io.IOException