KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > codehaus > groovy > syntax > lexer > StringCharStream


1 package org.codehaus.groovy.syntax.lexer;
2
3 import org.codehaus.groovy.syntax.ReadException;
4
5 public class StringCharStream extends AbstractCharStream {
6     private int cur;
7     private String JavaDoc text;
8
9     public StringCharStream(String JavaDoc text) {
10         this.text = text;
11         this.cur = 0;
12     }
13
14     public StringCharStream(String JavaDoc text, String JavaDoc description) {
15         super(description);
16         this.text = text;
17         this.cur = 0;
18     }
19
20     public char consume() throws ReadException {
21         if (this.cur >= this.text.length()) {
22             return CharStream.EOS;
23         }
24
25         char c = this.text.charAt(this.cur);
26
27         ++this.cur;
28
29         return c;
30     }
31
32     public void close() throws ReadException {
33         // do nothing
34
}
35 }
36
Popular Tags