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
CharSource
to throwUncheckedIOException
instead ofIOException
.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
BeanCharSource()
Creates an instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BeanByteSource
asByteSource(Charset charset)
BeanByteSource
asByteSourceUtf8()
Converts this char source to a byte source in UTF-8.void
forEachLine(Consumer<? super String> action)
Optional<String>
getFileName()
Gets the file name of the source.String
getFileNameOrThrow()
Gets the file name of the source.boolean
isEmpty()
long
length()
Stream<String>
lines()
StringCharSource
load()
Loads the content of the source into memory.String
read()
String
readFirstLine()
ImmutableList<String>
readLines()
<T> T
readLines(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:
lines
in classCharSource
-
isEmpty
public boolean isEmpty()
- Overrides:
isEmpty
in classCharSource
-
length
public long length()
- Overrides:
length
in classCharSource
-
read
public String read()
- Overrides:
read
in classCharSource
-
readFirstLine
public String readFirstLine()
- Overrides:
readFirstLine
in classCharSource
-
readLines
public ImmutableList<String> readLines()
- Overrides:
readLines
in classCharSource
-
readLines
public <T> T readLines(LineProcessor<T> processor)
- Overrides:
readLines
in classCharSource
-
forEachLine
public void forEachLine(Consumer<? super String> action)
- Overrides:
forEachLine
in 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:
asByteSource
in classCharSource
-
-