public interface DataProvider
This interface supplies the nessecary methods for a DataMapper
or its
subinterfaces (WhitespaceHandler
, SeparatorHandler
, PatternHandler
KeywordHandler
and SequenceHandler
) to perform its operations
like checking for whitespaces, special sequences etc. Instances of the interface
are created by Tokenizer
implementations.
A Tokenizer
implementation will either implement the
DataProvider
interface itself or has an associated - probably
non-public - implementing class.
Note:: Each implementation of this interface should also
override the method Object.toString()
. The implementation of
toString
should return a string composed of all characters of a
DataProvider
between getStartPosition()
(including) and
getStartPosition()
+ getLength()
(excluding).
Note:: This interface will eventually be deprecated in favour
of the new JDK 1.4 interface CharSequence
.
Tokenizer
,
TokenizerProperties
,
DataMapper
Modifier and Type | Method and Description |
---|---|
char |
getCharAt(int index)
This method retrieves a single character from the available data.
|
char[] |
getData()
Deprecated.
use subsequent calls to
getCharAt(int) or toString
instead |
char[] |
getDataCopy()
Deprecated.
use subsequent calls to
getCharAt(int) or toString
instead |
int |
getLength()
Retrieving the number of characters that a
DataProvider can
provide. |
int |
getStartPosition()
Deprecated.
use indexes for
getCharAt(int) starting with 0 up to
getLength() (excluding). |
char getCharAt(int index)
index
start from 0 and are smaller
than getLength()
.
getData()
and getDataCopy
whereever possible.index
- an index between 0 and getLength()
char[] getData()
getCharAt(int)
or toString
insteadDataMapper
should
use for its operations. The calling method of the DataMapper
should be aware that the provided array is probably the input buffer of the
Tokenizer
. It should therefore treat it as a
read-only object.
getStartPosition()
and getLength()
.
Characters outside this range are invalid.
getDataCopy()
to retrieve a copy of the valid character range.
getData
is equivalent to getDataCopy()
.char[] getDataCopy()
getCharAt(int)
or toString
insteadTokenizer
providing the DataProvider
into a character buffer. Use this
method if data should be modified.
getStartPosition()
or
getLength()
on this copy.
Object.toString()
which
should therefore be overridden in implementations of this interface.DataProvider
getData()
int getStartPosition()
getCharAt(int)
starting with 0 up to
getLength()
(excluding).getData()
. The calling DataMapper
must not access data
prior to this index in the character array.getData()
, where data startsint getLength()
DataProvider
can
provide. The return value should be a positive integer.DataProvider
contains.
false
otherwise