01: /*
02: * StringSequence.java
03: *
04: * This file is part of SQL Workbench/J, http://www.sql-workbench.net
05: *
06: * Copyright 2002-2008, Thomas Kellerer
07: * No part of this code maybe reused without the permission of the author
08: *
09: * To contact the author please send an email to: support@sql-workbench.net
10: *
11: */
12: package workbench.util;
13:
14: import workbench.interfaces.CharacterSequence;
15:
16: /**
17: * An implementation of the CharacterSequence interface
18: * based on a String as the source.
19: *
20: * @see FileMappedSequence
21: * @author support@sql-workbench.net
22: */
23: public class StringSequence implements CharacterSequence {
24: private String source;
25:
26: /**
27: * Create a StringSequence based on the given String
28: */
29: public StringSequence(String s) {
30: this .source = s;
31: }
32:
33: public void done() {
34: this .source = null;
35: }
36:
37: public int length() {
38: return source.length();
39: }
40:
41: public char charAt(int index) {
42: return this .source.charAt(index);
43: }
44:
45: public CharSequence subSequence(int start, int end) {
46: return this.source.substring(start, end);
47: }
48:
49: }
|