public final class Split
extends org.dmfs.iterators.AbstractBaseIterator<java.lang.CharSequence>
Iterator that iterates the elements of a CharSequence of a comma (or other character) separated value list .
Example:
Iterator<CharSequence> i = new Split("a, b,def,123", ',');
i.next(); // returns "a"
i.next(); // returns " b"
i.next(); // returns "def"
i.next(); // returns "123"
i.hasNext(); // false
Iterating an empty CharSequence or a CharSequence without (unquoted) separators will return exactly one element.
Example:
Iterator<CharSequence> i = new Split("", ',');
i.next(); // returns ""
i.hasNext(); // false
TODO: replace with the implementation in Iterators once it has been released
| Constructor and Description |
|---|
Split(java.lang.CharSequence value,
char separator)
Creates an
Iterator that iterates all segments of the given CharSequence which are separated by the given separator. |
Split(java.lang.CharSequence value,
char separator,
int maxSplits)
Creates an
Iterator that iterates all segments of the given CharSequence which are separated by the given separator. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
hasNext() |
java.lang.CharSequence |
next() |
public Split(java.lang.CharSequence value,
char separator)
Iterator that iterates all segments of the given CharSequence which are separated by the given separator.value - The CharSequence that contains a list of values.separator - The separator that separates the values.public Split(java.lang.CharSequence value,
char separator,
int maxSplits)
Iterator that iterates all segments of the given CharSequence which are separated by the given separator.value - The CharSequence that contains a separated list of values.separator - The separator to scan for.maxSplits - The maximum number of splits to perform. The iterator will return at most this number +1 elements (the last iterated element containing the rest
of the CharSequence.