KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > freemarker > eclipse > test > util > MockCharacterScanner


1 package freemarker.eclipse.test.util;
2
3 import org.eclipse.jface.text.rules.ICharacterScanner;
4
5 /**
6  * An implementation of ICharacterScanner. AbstractRuleTestCase uses this class
7  * to pass a piece of ftl code to an IRule.
8  *
9  * @see freemarker.eclipse.test.AbstractRuleTestCase
10  *
11  * @author <a HREF="mailto:stephan&#64;chaquotay.net">Stephan Mueller</a>
12  * @version $Id: MockCharacterScanner.java,v 1.1 2004/02/05 00:17:52 stephanmueller Exp $
13  */

14 public class MockCharacterScanner implements ICharacterScanner {
15
16     private int pos = 0;
17     private String JavaDoc text = "";
18
19     public MockCharacterScanner(String JavaDoc text) {
20         this.text = text;
21     }
22
23     public int getColumn() {
24         throw new UnsupportedOperationException JavaDoc();
25     }
26
27     public char[][] getLegalLineDelimiters() {
28         return new char[][] { "\n".toCharArray()};
29     }
30
31     public int read() {
32         return text.charAt(pos++);
33     }
34
35     public void unread() {
36         pos--;
37     }
38
39     public int getPos() {
40         return pos;
41     }
42 }
Popular Tags