public class CharArraySource extends java.lang.Object implements CharSequenceTokenizerSource
TokenizerSource and its extension
CharSequenceTokenizerSource for character arrays. It is a shortcut for:
char[] myData = { ... };
TokenizerSource source = new ReaderSource(new CharArrayReader(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,
StringSource| Constructor and Description |
|---|
CharArraySource(char[] data)
Constructing a
CharArraySource instance using the
given character buffer starting with offset 0 and the full length of the
array. |
CharArraySource(char[] data,
int offset,
int length)
Constructing an
CharArraySource instance using the
given character buffer starting with the given offset 0 and the given length. |
| 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. |
java.lang.String |
toString()
Returns the string representation of this
CharArraySource according
to the CharSequence interface contract. |
public CharArraySource(char[] data)
CharArraySource instance using the
given character buffer starting with offset 0 and the full length of the
array.data - the character data to tokenizepublic CharArraySource(char[] data,
int offset,
int length)
CharArraySource instance using the
given character buffer starting with the given offset 0 and the given length.data - the character data to tokenizeoffset - there to start in the given datalength - count of characters to tokenizepublic int read(char[] cbuf,
int offset,
int maxChars)
throws java.lang.Exception
TokenizerSource.read(char[], int, int)
for details.read in interface TokenizerSourcecbuf - buffer to receive dataoffset - position from where the data should be inserted in cbufmaxChars - maximum number of characters to be read into cbufjava.lang.Exception - anything that could happen during read, most likely IOExceptionpublic char charAt(int index)
CharSequence.charAt(int) for this class. Note that
the given index is relative to the offset that was passed when this instance
was constructed (CharArraySource(char[], int, int))charAt in interface java.lang.CharSequenceindex - which character to retrievepublic int length()
CharSequence.length() for this class.length in interface java.lang.CharSequencepublic java.lang.CharSequence subSequence(int start,
int end)
CharSequence.subSequence(int, int) for this class.subSequence in interface java.lang.CharSequencestart - the new CharSequence contains the characters
from and including this positionend - the new CharSequence contains the characters
up to and excluding this positionCharSequencepublic java.lang.String toString()
CharArraySource according
to the CharSequence interface contract.toString in interface java.lang.CharSequencetoString in class java.lang.ObjectCharArraySource