public final class UnquotedSplit extends 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 UnquotedSplit("a, b,def,123", ',');
i.next(); // returns "a"
i.next(); // returns " b"
i.next(); // returns "def"
i.next(); // returns "123"
i.hasNext(); // false
Separators between quote characters will be ignored.
Example:
Iterator<CharSequence> i = new UnquotedSplit("\"a, b\",\"def,123\"", ',');
i.next(); // returns "a , b"
i.next(); // returns "def,123"
i.hasNext(); // false
Iterating an empty CharSequence or a CharSequence without (unquoted) separators will return exactly one element.
Example:
Iterator<CharSequence> i = new UnquotedSplit("", ',');
i.next(); // returns ""
i.hasNext(); // false
Iterator<CharSequence> i2 = new UnquotedSplit("\"abc,def\"", ',');
i2.next(); // returns "abc,def"
i2.hasNext(); // false
| Constructor and Description |
|---|
UnquotedSplit(java.lang.CharSequence value,
char separator)
Creates an
Iterator that iterates all elements of the given CharSequence which are separated by the given
separator, except for separators in sections quoted by a " character. |
UnquotedSplit(java.lang.CharSequence value,
char separator,
char quoteChar)
Creates an
Iterator that iterates all elements of the given CharSequence which are separated by the given
separator, except for separators in sections quoted by the given quoting character. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
hasNext() |
java.lang.CharSequence |
next() |
equals, hashCode, removepublic UnquotedSplit(java.lang.CharSequence value,
char separator)
Iterator that iterates all elements of the given CharSequence which are separated by the given
separator, except for separators in sections quoted by a " character.value - The CharSequence that contains a list of values.separator - The separator that separates the values.public UnquotedSplit(java.lang.CharSequence value,
char separator,
char quoteChar)
Iterator that iterates all elements of the given CharSequence which are separated by the given
separator, except for separators in sections quoted by the given quoting character.value - The CharSequence that contains a list of values.separator - The separator that separates the values.quoteChar - The quoting character that starts and ends the quoted sections.