private static class CharSource.CharSequenceCharSource extends CharSource
| Modifier and Type | Field and Description |
|---|---|
private static Splitter |
LINE_SPLITTER |
private java.lang.CharSequence |
seq |
| Modifier | Constructor and Description |
|---|---|
protected |
CharSequenceCharSource(java.lang.CharSequence seq) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
isEmpty()
Returns whether the source has zero chars.
|
private java.lang.Iterable<java.lang.String> |
lines()
Returns an iterable over the lines in the string.
|
java.io.Reader |
openStream()
Opens a new
Reader for reading from this source. |
java.lang.String |
read()
Reads the contents of this source as a string.
|
java.lang.String |
readFirstLine()
Reads the first link of this source as a string.
|
ImmutableList<java.lang.String> |
readLines()
Reads all the lines of this source as a list of strings.
|
<T> T |
readLines(LineProcessor<T> processor)
Reads lines of text from this source, processing each line as it is read using the given
processor. |
java.lang.String |
toString() |
concat, concat, concat, copyTo, copyTo, empty, openBufferedStream, wrapprivate static final Splitter LINE_SPLITTER
private final java.lang.CharSequence seq
protected CharSequenceCharSource(java.lang.CharSequence seq)
public java.io.Reader openStream()
CharSourceReader for reading from this source. This method should return a new,
independent reader each time it is called.
The caller is responsible for ensuring that the returned reader is closed.
openStream in class CharSourcepublic java.lang.String read()
CharSourceread in class CharSourcepublic boolean isEmpty()
CharSourceisEmpty in class CharSourceprivate java.lang.Iterable<java.lang.String> lines()
public java.lang.String readFirstLine()
CharSourcenull if this source is empty.
Like BufferedReader, this method breaks lines on any of \n, \r or
\r\n, does not include the line separator in the returned line and does not consider
there to be an extra empty line at the end if the content is terminated with a line separator.
readFirstLine in class CharSourcepublic ImmutableList<java.lang.String> readLines()
CharSourceLike BufferedReader, this method breaks lines on any of \n, \r or
\r\n, does not include the line separator in the returned lines and does not consider
there to be an extra empty line at the end if the content is terminated with a line separator.
readLines in class CharSourcepublic <T> T readLines(LineProcessor<T> processor) throws java.io.IOException
CharSourceprocessor. Stops when all lines have been processed or the processor
returns false and returns the result produced by the processor.
Like BufferedReader, this method breaks lines on any of \n, \r or
\r\n, does not include the line separator in the lines passed to the processor
and does not consider there to be an extra empty line at the end if the content is terminated
with a line separator.
readLines in class CharSourcejava.io.IOException - if an I/O error occurs in the process of reading from this source or if
processor throws an IOExceptionpublic java.lang.String toString()
toString in class java.lang.Object