Package org.moeaframework.analysis.store
Interface Blob
public interface Blob
Reference to a blob, which is simply a piece of data identified by its container and name.
-
Method Summary
Modifier and TypeMethodDescriptionboolean
delete()
Deletes this blob if it exists.boolean
exists()
Returnstrue
if the blob exists;false
otherwise.default void
Extracts the content of this blob to a file.default void
extract
(OutputStream out) Transfers the content of this blob to an output stream.default void
Transfers the content of this blob to a writer.default void
Extracts the content of this blob to a path.default void
extract
(InputStreamCallback callback) Executes a callback with anInputStream
for reading this blob.default void
extract
(ReaderCallback callback) Executes a callback with aReader
for reading this blob.default boolean
extractIfFound
(InputStreamCallback callback) Executes the callback with anInputStream
for reading this blob, but only if the blob exists.default boolean
extractIfFound
(ReaderCallback callback) Executes the callback with aReader
for reading this blob, but only if the blob exists.default Object
Extracts the blob and deserializes the content.default <T> T
extractObject
(Class<T> type) Extracts the blob and deserializes the content.Gets the container for this blob.getName()
Gets the name of this blob.default boolean
ifFound
(IOCallback<Blob> callback) Executes the callback function if this blob exists.default boolean
ifMissing
(IOCallback<Blob> callback) Executes the callback function if this blob is missing.Returns the last modified time of the blob.Creates and returns anInputStream
for reading binary data from this blob.Creates and returns aTransactionalOutputStream
for writing binary data to this blob.Creates and returns aReader
for reading text from this blob.Creates and returns aTransactionalWriter
for writing text to this blob.default void
Stores the contents of a file to this blob.default void
store
(InputStream in) Stores the content read from an input stream to this this blob.default void
Stores the content read from a reader to this this blob.default void
Stores the contents of a path to this blob.default void
store
(Population population) Stores the givenPopulation
object to this blob as a result file.default void
store
(Formattable<?> formattable) Stores the givenFormattable
object to this blob using theTableFormat.Plaintext
format.default void
store
(Formattable<?> formattable, TableFormat tableFormat) Stores the givenFormattable
object to this blob using the specified table format.default void
store
(OutputStreamCallback callback) Executes a callback with anOutputStream
for writing to this blob.default void
store
(PrintStreamCallback callback) Executes a callback with aPrintStream
for writing to this blob.default void
store
(WriterCallback callback) Executes a callback with aWriter
for writing to this blob.default boolean
storeIfMissing
(OutputStreamCallback callback) Executes the callback with anOutputStream
for writing to this blob, but only if the blob does not already exist.default boolean
storeIfMissing
(PrintStreamCallback callback) Executes the callback with aPrintStream
for writing to this blob, but only if the blob does not already exist.default boolean
storeIfMissing
(WriterCallback callback) Executes the callback with aWriter
for writing to this blob, but only if the blob does not already exist.default void
storeObject
(Object value) Stores a serializable object to the blob.
-
Method Details
-
getName
String getName()Gets the name of this blob.- Returns:
- the blo name
-
getContainer
Container getContainer()Gets the container for this blob.- Returns:
- the container
-
exists
Returnstrue
if the blob exists;false
otherwise.- Returns:
true
if the blob exists;false
otherwise- Throws:
IOException
- if an I/O error occurred
-
delete
Deletes this blob if it exists.- Returns:
true
if the blob was deleted;false
if the blob does not exist- Throws:
IOException
- if an I/O error occurred
-
lastModified
Returns the last modified time of the blob.- Returns:
- the last modified time
- Throws:
IOException
- if an I/O error occurred
-
openReader
Creates and returns aReader
for reading text from this blob. The caller is responsible for closing the reader when finished.- Returns:
- a reader for this blob
- Throws:
IOException
- if an I/O error occurred
-
openInputStream
Creates and returns anInputStream
for reading binary data from this blob. The caller is responsible for closing the stream when finished.- Returns:
- an input stream for this blob
- Throws:
IOException
- if an I/O error occurred
-
openWriter
Creates and returns aTransactionalWriter
for writing text to this blob. The caller is responsible for committing and closing the writer when finished. If the writer is closed before being committed, any written content is discarded.- Returns:
- the writer for this blob
- Throws:
IOException
- if an I/O error occurred
-
openOutputStream
Creates and returns aTransactionalOutputStream
for writing binary data to this blob. The caller is responsible for committing and closing the stream when finished. If the stream is closed before being committed, any written content is discarded.- Returns:
- the output stream for this blob
- Throws:
IOException
- if an I/O error occurred
-
ifMissing
Executes the callback function if this blob is missing.- Parameters:
callback
- the callback function- Returns:
true
if the blob is missing and the callback was invoked;false
otherwise- Throws:
IOException
- if an I/O error occurred
-
ifFound
Executes the callback function if this blob exists.- Parameters:
callback
- the callback function- Returns:
true
if the blob exists and the callback was invoked;false
otherwise- Throws:
IOException
- if an I/O error occurred
-
extract
Extracts the content of this blob to a file.- Parameters:
file
- the destination file- Throws:
IOException
- if an I/O error occurred
-
extract
Extracts the content of this blob to a path.- Parameters:
path
- the destination path- Throws:
IOException
- if an I/O error occurred
-
extract
Transfers the content of this blob to an output stream.- Parameters:
out
- the output stream- Throws:
IOException
- if an I/O error occurred
-
extract
Transfers the content of this blob to a writer.- Parameters:
out
- the writer- Throws:
IOException
- if an I/O error occurred
-
extract
Executes a callback with anInputStream
for reading this blob. The input stream is automatically closed when the callback returns.- Parameters:
callback
- the callback function- Throws:
IOException
- if an I/O error occurred
-
extract
Executes a callback with aReader
for reading this blob. The reader is automatically closed when the callback returns.- Parameters:
callback
- the callback function- Throws:
IOException
- if an I/O error occurred
-
extractIfFound
Executes the callback with anInputStream
for reading this blob, but only if the blob exists. The stream is automatically closed when the callback returns.- Parameters:
callback
- the callback function- Returns:
true
if the blob exists and the callback was invoked;false
otherwise- Throws:
IOException
- if an I/O error occurred
-
extractIfFound
Executes the callback with aReader
for reading this blob, but only if the blob exists. The reader is automatically closed when the callback returns.- Parameters:
callback
- the callback function- Returns:
true
if the blob exists and the callback was invoked;false
otherwise- Throws:
IOException
- if an I/O error occurred
-
extractObject
Extracts the blob and deserializes the content.- Returns:
- the deserialized object
- Throws:
IOException
- if an I/O error occurredClassNotFoundException
- if the class of the serialized object could not be found
-
extractObject
Extracts the blob and deserializes the content.- Type Parameters:
T
- the return type- Parameters:
type
- the type of the object- Returns:
- the deserialized object cast to the given type
- Throws:
IOException
- if an I/O error occurredClassNotFoundException
- if the class of the serialized object could not be found
-
store
Stores the contents of a file to this blob.- Parameters:
file
- the source file- Throws:
IOException
- if an I/O error occurred
-
store
Stores the contents of a path to this blob.- Parameters:
path
- the source path- Throws:
IOException
- if an I/O error occurred
-
store
Stores the givenPopulation
object to this blob as a result file.- Parameters:
population
- the population to store- Throws:
IOException
- if an I/O error occurred
-
store
Stores the givenFormattable
object to this blob using theTableFormat.Plaintext
format.- Parameters:
formattable
- the formattable object to store- Throws:
IOException
- if an I/O error occurred
-
store
Stores the givenFormattable
object to this blob using the specified table format.- Parameters:
formattable
- the formattable object to storetableFormat
- the table format- Throws:
IOException
- if an I/O error occurred
-
store
Stores the content read from an input stream to this this blob.- Parameters:
in
- the input stream- Throws:
IOException
- if an I/O error occurred
-
store
Stores the content read from a reader to this this blob.- Parameters:
reader
- the reader- Throws:
IOException
- if an I/O error occurred
-
store
Executes a callback with anOutputStream
for writing to this blob. The output stream is automatically closed when the callback returns.- Parameters:
callback
- the callback function- Throws:
IOException
- if an I/O error occurred
-
store
Executes a callback with aPrintStream
for writing to this blob. The output stream is automatically closed when the callback returns.- Parameters:
callback
- the callback function- Throws:
IOException
- if an I/O error occurred
-
store
Executes a callback with aWriter
for writing to this blob. The output stream is automatically closed when the callback returns.- Parameters:
callback
- the callback function- Throws:
IOException
- if an I/O error occurred
-
storeIfMissing
Executes the callback with anOutputStream
for writing to this blob, but only if the blob does not already exist. The stream is automatically closed when the callback returns.- Parameters:
callback
- the callback function- Returns:
true
if the blob did not exist and the callback was invoked;false
otherwise- Throws:
IOException
- if an I/O error occurred
-
storeIfMissing
Executes the callback with aPrintStream
for writing to this blob, but only if the blob does not already exist. The stream is automatically closed when the callback returns.- Parameters:
callback
- the callback function- Returns:
true
if the blob did not exist and the callback was invoked;false
otherwise- Throws:
IOException
- if an I/O error occurred
-
storeIfMissing
Executes the callback with aWriter
for writing to this blob, but only if the blob does not already exist. The stream is automatically closed when the callback returns.- Parameters:
callback
- the callback function- Returns:
true
if the blob did not exist and the callback was invoked;false
otherwise- Throws:
IOException
- if an I/O error occurred
-
storeObject
Stores a serializable object to the blob.- Parameters:
value
- the object to store- Throws:
IOException
- if an I/O error occurredNotSerializableException
- if the object is not serializable
-