Class CharReader

java.lang.Object
  |
  +--java.io.Reader
        |
        +--java.io.StringReader
              |
              +--CharReader

class CharReader
extends java.io.StringReader

A simple reader for reading chars one at a time from a String. Both peek() and read() methods are provided. Any whitespace is is skipped. For debugging purposes, a trace of characters read can be turned on or off (default is off).


Field Summary
(package private) static int eof
          Integer returned by StringReader for end of input.
(package private) static char nullchar
          Character returned when end of input reached.
(package private)  boolean traceOn
          Indicate whether tracing is on or off.
 
Fields inherited from class java.io.StringReader
 
Fields inherited from class java.io.Reader
lock
 
Constructor Summary
(package private) CharReader(java.lang.String s)
          Construct a CharReader for a String.
 
Method Summary
 char get()
          Get the next non-whitespace "character", returning nullchar if there are no more characters.
 boolean hasMore()
          Return true if there are more characters to be get, false otherwise.
 char peek()
          Return the next non-whitespace character, but leave the character in the input to be gotten again.
private  int readNonWhiteSpace()
          Get the next non-whitespace character, returning nullchar if there are no more characters.
 void setTrace(boolean traceOn)
          Set the trace on or off.
 java.lang.String toString()
          Return the remaining input as a String.
 
Methods inherited from class java.io.StringReader
close, mark, markSupported, read, read, ready, reset, skip
 
Methods inherited from class java.io.Reader
read
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

traceOn

boolean traceOn
Indicate whether tracing is on or off.


nullchar

static char nullchar
Character returned when end of input reached.


eof

static int eof
Integer returned by StringReader for end of input.

Constructor Detail

CharReader

CharReader(java.lang.String s)
Construct a CharReader for a String.

Method Detail

get

public char get()
Get the next non-whitespace "character", returning nullchar if there are no more characters.


peek

public char peek()
Return the next non-whitespace character, but leave the character in the input to be gotten again. If there are no more characters, nullchar is returned.


hasMore

public boolean hasMore()
Return true if there are more characters to be get, false otherwise.


toString

public java.lang.String toString()
Return the remaining input as a String.

Overrides:
toString in class java.lang.Object

readNonWhiteSpace

private int readNonWhiteSpace()
Get the next non-whitespace character, returning nullchar if there are no more characters.


setTrace

public void setTrace(boolean traceOn)
Set the trace on or off.