Package com.opengamma.strata.collect.io
Class BeanCharSource
- java.lang.Object
-
- com.google.common.io.CharSource
-
- com.opengamma.strata.collect.io.BeanCharSource
-
- All Implemented Interfaces:
org.joda.beans.Bean,org.joda.beans.ImmutableBean
- Direct Known Subclasses:
StringCharSource
public abstract class BeanCharSource extends CharSource implements org.joda.beans.ImmutableBean
A char source implementation that is also a Joda-Bean.See
StringCharSource.Various methods override
CharSourceto throwUncheckedIOExceptioninstead ofIOException.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedBeanCharSource()Creates an instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BeanByteSourceasByteSource(Charset charset)BeanByteSourceasByteSourceUtf8()Converts this char source to a byte source in UTF-8.voidforEachLine(Consumer<? super String> action)Optional<String>getFileName()Gets the file name of the source.StringgetFileNameOrThrow()Gets the file name of the source.booleanisEmpty()longlength()Stream<String>lines()StringCharSourceload()Loads the content of the source into memory.Stringread()StringreadFirstLine()ImmutableList<String>readLines()<T> TreadLines(LineProcessor<T> processor)-
Methods inherited from class com.google.common.io.CharSource
concat, concat, concat, copyTo, copyTo, empty, lengthIfKnown, openBufferedStream, openStream, wrap
-
-
-
-
Method Detail
-
getFileName
public Optional<String> getFileName()
Gets the file name of the source.Most sources originate from a file-based location. This is captured and returned here where available.
- Returns:
- the file name, empty if not known
-
getFileNameOrThrow
public String getFileNameOrThrow()
Gets the file name of the source.Most sources originate from a file-based location. This is captured and returned here where available.
- Returns:
- the file name
- Throws:
IllegalArgumentException- if the file name is not known
-
lines
public Stream<String> lines()
- Overrides:
linesin classCharSource
-
isEmpty
public boolean isEmpty()
- Overrides:
isEmptyin classCharSource
-
length
public long length()
- Overrides:
lengthin classCharSource
-
read
public String read()
- Overrides:
readin classCharSource
-
readFirstLine
public String readFirstLine()
- Overrides:
readFirstLinein classCharSource
-
readLines
public ImmutableList<String> readLines()
- Overrides:
readLinesin classCharSource
-
readLines
public <T> T readLines(LineProcessor<T> processor)
- Overrides:
readLinesin classCharSource
-
forEachLine
public void forEachLine(Consumer<? super String> action)
- Overrides:
forEachLinein classCharSource
-
load
public StringCharSource load()
Loads the content of the source into memory.- Returns:
- the string-based source
- Throws:
UncheckedIOException- if an IO error occurs
-
asByteSourceUtf8
public BeanByteSource asByteSourceUtf8()
Converts this char source to a byte source in UTF-8.- Returns:
- the equivalent byte source
-
asByteSource
public BeanByteSource asByteSource(Charset charset)
- Overrides:
asByteSourcein classCharSource
-
-