public class StringSource extends java.lang.Object implements CharSequenceTokenizerSource
TokenizerSource
and its extension
CharSequenceTokenizerSource
for strings. It is a shortcut for:
String myData = "..."; TokenizerSource source = new ReaderSource(new StringReader(myData));
CharSequence
interface. Since this interface
was only introduced with Java 1.4, this class can only be used with 1.4 or
higher Java versions.TokenizerSource
,
CharSequenceTokenizerSource
,
CharArraySource
Constructor and Description |
---|
StringSource(java.lang.String data)
Constructing a
StringSource on the given String . |
Modifier and Type | Method and Description |
---|---|
char |
charAt(int index)
Implements
CharSequence.charAt(int) for this class. |
int |
length()
Implements
CharSequence.length() for this class. |
int |
read(char[] cbuf,
int offset,
int maxChars)
This method copies the available data into the given buffer according to
the given offset and maximum character count.
|
java.lang.CharSequence |
subSequence(int start,
int end)
Implements
CharSequence.subSequence(int, int) for this class. |
public StringSource(java.lang.String data)
StringSource
on the given String
.
A null
value is handled like an empty string.data
- the stringpublic int read(char[] cbuf, int offset, int maxChars) throws java.lang.Exception
TokenizerSource.read(char[], int, int)
for details.read
in interface TokenizerSource
cbuf
- buffer to receive dataoffset
- position from where the data should be inserted in cbuf
maxChars
- maximum number of characters to be read into cbuf
java.lang.Exception
- anything that could happen during read, most likely IOException
public char charAt(int index)
CharSequence.charAt(int)
for this class.charAt
in interface java.lang.CharSequence
index
- which character to retrievepublic int length()
CharSequence.length()
for this class.length
in interface java.lang.CharSequence
public java.lang.CharSequence subSequence(int start, int end)
CharSequence.subSequence(int, int)
for this class.subSequence
in interface java.lang.CharSequence
start
- the new CharSequence
contains the characters
from and including this positionend
- the new CharSequence
contains the characters
up to and excluding this positionCharSequence