Inheritance diagram for CharReader::

Public Methods | |
| char | get () |
| char | peek () |
| boolean | hasMore () |
| String | toString () |
| void | setTrace (boolean traceOn) |
Private Methods | |
| CharReader (String s) | |
| int | readNonWhiteSpace () |
Private Attributes | |
| boolean | traceOn = false |
Static Private Attributes | |
| char | nullchar = |
| int | eof = -1 |
Definition at line 14 of file CharReader.java.
|
|
Construct a CharReader for a String. Definition at line 41 of file CharReader.java. 00042 {
00043 super(s);
00044 }
|
|
|
Get the next non-whitespace "character", returning nullchar if there are no more characters. Definition at line 52 of file CharReader.java. 00053 {
00054 int character = readNonWhiteSpace();
00055
00056 if( character == eof )
00057 {
00058 if( traceOn )
00059 {
00060 System.out.println("geting at end of input, returning null character");
00061 }
00062 return nullchar;
00063 }
00064 else
00065 {
00066 if( traceOn )
00067 {
00068 System.out.println("geting: " + (char)character);
00069 }
00070 return (char)character;
00071 }
00072 }
|
|
|
Return true if there are more characters to be get, false otherwise. Definition at line 118 of file CharReader.java. 00119 {
00120 return peek() != nullchar;
00121 }
|
|
|
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. Definition at line 81 of file CharReader.java. 00082 {
00083 try
00084 {
00085 mark(1);
00086 int character = readNonWhiteSpace();
00087 reset();
00088
00089 if( character == eof )
00090 {
00091 if( traceOn )
00092 {
00093 System.out.println("peeking at end of input, "
00094 + "returning null character");
00095 }
00096 return nullchar;
00097 }
00098 else
00099 {
00100 if( traceOn )
00101 {
00102 System.out.println("peeking at: " + (char)character);
00103 }
00104 return (char)character;
00105 }
00106 }
00107 catch( IOException e )
00108 {
00109 return nullchar;
00110 }
00111 }
|
|
|
Get the next non-whitespace character, returning nullchar if there are no more characters. Definition at line 159 of file CharReader.java. 00160 {
00161 int character;
00162
00163 try
00164 {
00165 character = super.read();
00166
00167 // Keep reading until a non-whitespace character is encountered or eof.
00168
00169 while( character != eof && Character.isWhitespace((char)character) )
00170 {
00171 character = super.read();
00172 }
00173 }
00174 catch( IOException e )
00175 {
00176 return nullchar;
00177 }
00178
00179 return character;
00180 }
|
|
|
Set the trace on or off. Definition at line 187 of file CharReader.java. 00188 {
00189 this.traceOn = traceOn;
00190 }
|
|
|
Return the remaining input as a String. Definition at line 128 of file CharReader.java. 00129 {
00130 StringBuffer buffer = new StringBuffer();
00131
00132 int character;
00133
00134 try
00135 {
00136 character = super.read();
00137
00138 // Keep reading until a non-whitespace character is encountered or eof.
00139
00140 while( character != eof )
00141 {
00142 buffer.append((char)character);
00143 character = super.read();
00144 }
00145 }
00146 catch( IOException e )
00147 {
00148 }
00149
00150 return buffer.toString();
00151 }
|
|
|
Integer returned by StringReader for end of input. Definition at line 34 of file CharReader.java. |
|
|
Character returned when end of input reached. Definition at line 27 of file CharReader.java. |
|
|
Indicate whether tracing is on or off. Definition at line 20 of file CharReader.java. |
1.2.6 written by Dimitri van Heesch,
© 1997-2001