public abstract class BeanByteSource extends ByteSource implements org.joda.beans.ImmutableBean
See ArrayByteSource, UriByteSource and FileByteSource.
| Modifier | Constructor and Description |
|---|---|
protected |
BeanByteSource()
Creates an instance.
|
| Modifier and Type | Method and Description |
|---|---|
CharSource |
asCharSourceUtf8()
Returns a
CharSource for the same bytes, converted to UTF-8. |
CharSource |
asCharSourceUtf8UsingBom()
Returns a
CharSource for the File, converted to UTF-8 using a Byte-Order Mark if available. |
Optional<String> |
getFileName()
Gets the file name of the source.
|
HashCode |
hash(HashFunction hashFunction) |
boolean |
isEmpty()
Checks if the byte source is empty, throwing an unchecked exception.
|
ArrayByteSource |
load()
Loads the content of the byte source into memory.
|
byte[] |
read()
Reads the source as a byte array, throwing an unchecked exception.
|
String |
readUtf8()
Reads the source, converting to UTF-8.
|
String |
readUtf8UsingBom()
Reads the source, converting to UTF-8 using a Byte-Order Mark if available.
|
long |
size()
Gets the size of the byte source, throwing an unchecked exception.
|
ArrayByteSource |
toBase64()
Encodes the byte source using base-64.
|
String |
toBase64String()
Encodes the byte source using base-64, returning a string.
|
ArrayByteSource |
toHash(HashFunction hashFunction)
Returns a new byte source containing the hash of the content of this byte source.
|
String |
toHashString(HashFunction hashFunction)
Returns a new byte source containing the hash of the content of this byte source.
|
asCharSource, concat, concat, concat, contentEquals, copyTo, copyTo, empty, openBufferedStream, openStream, read, sizeIfKnown, slice, wrappublic Optional<String> getFileName()
Most sources originate from a file-based location. This is captured and returned here where available.
public boolean isEmpty()
This overrides ByteSource to throw UncheckedIOException instead of IOException.
isEmpty in class ByteSourceUncheckedIOException - if an IO error occurspublic long size()
This overrides ByteSource to throw UncheckedIOException instead of IOException.
size in class ByteSourceUncheckedIOException - if an IO error occurspublic byte[] read()
This overrides ByteSource to throw UncheckedIOException instead of IOException.
read in class ByteSourceUncheckedIOException - if an IO error occurspublic String readUtf8()
UncheckedIOException - if an IO error occurspublic String readUtf8UsingBom()
UncheckedIOException - if an IO error occurspublic CharSource asCharSourceUtf8()
CharSource for the same bytes, converted to UTF-8.
This does not read the underlying source.
CharSourcepublic CharSource asCharSourceUtf8UsingBom()
CharSource for the File, converted to UTF-8 using a Byte-Order Mark if available.CharSourcepublic ArrayByteSource load()
UncheckedIOException - if an IO error occurspublic HashCode hash(HashFunction hashFunction)
hash in class ByteSourcepublic ArrayByteSource toHash(HashFunction hashFunction)
The returned hash is in byte form.
hashFunction - the hash function to use, see HashingUncheckedIOException - if an IO error occurspublic String toHashString(HashFunction hashFunction)
The returned hash is in string form.
This form is intended to be compatible with tools like the UNIX md5sum command.
hashFunction - the hash function to use, see HashingUncheckedIOException - if an IO error occurspublic ArrayByteSource toBase64()
UncheckedIOException - if an IO error occurspublic String toBase64String()
Equivalent to toBase64().readUtf8().
Copyright 2009-Present by OpenGamma Inc. and individual contributors
Apache v2 licensed
Additional documentation can be found at strata.opengamma.io.