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 text;
8
9 public StringCharStream(String text) {
10 this.text = text;
11 this.cur = 0;
12 }
13
14 public StringCharStream(String text, String 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
34 }
35 }