Interface StringSplitter
- All Known Subinterfaces:
StringSplitter.Async
- All Known Implementing Classes:
StringSplitter.Shell
A function that splits a string into multiple components.
- Since:
- 1.0
- Version:
- 1.0
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceA splitter that is capable of processing the split in an asynchronous manner.static interfaceAn iterator over the elements split by a splitter.static classA splitter that uses a shell-like splitting algorithm, where components are separated by spaces, with the option of one or more components being delimited by quotes (single or double) to allow for the inclusion of spaces. -
Method Summary
Modifier and TypeMethodDescriptionObtains a string that can be used to delimit two elements according to this splitter.default StringSplitter.IteratorCreates an empty iterator for this splitter.default StringSplitter.IteratorCreates a smart iterator that iterates over the components obtained by splitting the given raw string.Splits the given string into components.
-
Method Details
-
split
Splits the given string into components.- Parameters:
raw- The string to split.- Returns:
- The split components.
-
delimiter
Obtains a string that can be used to delimit two elements according to this splitter.Note that there is no guarantee that the value returned by this method is the only delimiter supported by this splitter, only that it is a valid delimiter.
In other words, the guarantee offered by this method is that, given some string
strand splitterspl, andl = spl.split(str), thenspl.split(String.join(spl.delimiter(), l)).equals(l)istrue.This implies that, for any sequence of strings
s1, s2, s3, ..., thenspl.split(String.join(spl.delimiter(), s1, s2, s3, ...))gives the same result as concatenatingspl.split(s1), spl.split(s2), spl.split(s3), ...- Returns:
- The delimiter.
- API Note:
- This method
-
apply
-
iterate
Creates a smart iterator that iterates over the components obtained by splitting the given raw string. The returned iterator is functionally equivalent to callingSmartIterator.from(List)on the result ofsplit(String), but may (depending on implementation) split components lazily on demand.- Parameters:
raw- The string to split.- Returns:
- A smart iterator over the split components.
- Implementation Requirements:
- The default implementation delegates to
split(String)andSmartIterator.from(List).
-
emptyIterator
Creates an empty iterator for this splitter.- Returns:
- The iterator.
-