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 TypeMethodDescriptionbooleandelete()Deletes this blob if it exists.booleanexists()Returnstrueif the blob exists;falseotherwise.default byte[]Extracts the content of this blob to bytes.default <R> RextractInputStream(org.apache.commons.io.function.IOFunction<InputStream, R> function) Executes a function with anInputStreamfor reading this blob.default ObjectExtracts the blob and deserializes the content.default <T> TextractObject(Class<T> type) Extracts the blob and deserializes the content.default PopulationExtracts the content of this blob to aPopulation.default <R> RextractReader(org.apache.commons.io.function.IOFunction<Reader, R> function) Executes a function with aReaderfor reading this blob.default <T extends Stateful>
TextractState(T value) Extracts the state and loads it into theStatefulobject.default StringExtracts the content of this blob to a string.default voidExtracts the content of this blob to a file.default voidextractTo(OutputStream out) Transfers the content of this blob to an output stream.default voidTransfers the content of this blob to a writer.default voidExtracts the content of this blob to a path.Gets the container for this blob.getName()Gets the name of this blob.default URIgetURI()Returns the URI for this blob, which can be used withDataStoreFactory.resolveBlob(java.net.URI).default booleanExecutes the consumer function if this blob exists.default booleanExecutes the consumer function if this blob is missing.Returns the last modified time of the blob.Creates and returns anInputStreamfor reading binary data from this blob.Creates and returns aTransactionalOutputStreamfor writing binary data to this blob.Creates and returns aReaderfor reading text from this blob.Creates and returns aTransactionalWriterfor writing text to this blob.longsize()Returns the size of the blob, in bytes.default voidstoreBytes(byte[] data) Stores the given data to this blob.default voidStores the contents of a file to this blob.default voidstoreFrom(InputStream in) Stores the content read from an input stream to this this blob.default voidStores the content read from a reader to this this blob.default voidStores the contents of a path to this blob.default voidstoreObject(Object value) Stores a serializable object to the blob.default voidstoreOutputStream(org.apache.commons.io.function.IOConsumer<OutputStream> consumer) Executes a consumer with anOutputStreamfor writing to this blob.default voidstorePopulation(Population population) Stores the givenPopulationobject to this blob as a result file.default voidstorePrintStream(org.apache.commons.io.function.IOConsumer<PrintStream> consumer) Executes a consumer with aPrintStreamfor writing to this blob.default <T extends Stateful>
voidstoreState(T value) Stores aStatefulobject to the blob.default voidStores the given string to this blob.default voidstoreText(Formattable<?> formattable) Stores the givenFormattableobject to this blob using theTableFormat.Plaintextformat.default voidstoreText(Formattable<?> formattable, TableFormat tableFormat) Stores the givenFormattableobject to this blob using the specified table format.default voidstoreWriter(org.apache.commons.io.function.IOConsumer<Writer> consumer) Executes a consumer with aWriterfor writing to this blob.default StringtoJSON()Returns a description of this blob formatted as JSON.default StringReturns a description of this blob formatted as JSON.default StringReturns a description of this blob formatted as JSON.
-
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
Returnstrueif the blob exists;falseotherwise.- Returns:
trueif the blob exists;falseotherwise- Throws:
DataStoreException- if an error occurred accessing the data store
-
delete
Deletes this blob if it exists.- Returns:
trueif the blob was deleted;falseif the blob does not exist- Throws:
DataStoreException- if an error occurred accessing the data store
-
size
Returns the size of the blob, in bytes.- Returns:
- the size of the blob
- Throws:
DataStoreException- if an error occurred accessing the data store
-
lastModified
Returns the last modified time of the blob.- Returns:
- the last modified time
- Throws:
DataStoreException- if an error occurred accessing the data store
-
openReader
Creates and returns aReaderfor reading text from this blob. The caller is responsible for closing the reader when finished.- Returns:
- a reader for this blob
- Throws:
DataStoreException- if an error occurred accessing the data store
-
openInputStream
Creates and returns anInputStreamfor reading binary data from this blob. The caller is responsible for closing the stream when finished.- Returns:
- an input stream for this blob
- Throws:
DataStoreException- if an error occurred accessing the data store
-
openWriter
Creates and returns aTransactionalWriterfor 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:
DataStoreException- if an error occurred accessing the data store
-
openOutputStream
Creates and returns aTransactionalOutputStreamfor 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:
DataStoreException- if an error occurred accessing the data store
-
ifMissing
default boolean ifMissing(org.apache.commons.io.function.IOConsumer<Blob> consumer) throws DataStoreException Executes the consumer function if this blob is missing.- Parameters:
consumer- the consumer function- Returns:
trueif the blob is missing and the consumer was invoked;falseotherwise- Throws:
DataStoreException- if an error occurred accessing the data store
-
ifFound
default boolean ifFound(org.apache.commons.io.function.IOConsumer<Blob> consumer) throws DataStoreException Executes the consumer function if this blob exists.- Parameters:
consumer- the consumer function- Returns:
trueif the blob exists and the consumer was invoked;falseotherwise- Throws:
DataStoreException- if an error occurred accessing the data store
-
extractTo
Extracts the content of this blob to a file.- Parameters:
file- the destination file- Throws:
DataStoreException- if an error occurred accessing the data store
-
extractTo
Extracts the content of this blob to a path.- Parameters:
path- the destination path- Throws:
DataStoreException- if an error occurred accessing the data store
-
extractTo
Transfers the content of this blob to an output stream.- Parameters:
out- the output stream- Throws:
DataStoreException- if an error occurred accessing the data store
-
extractTo
Transfers the content of this blob to a writer.- Parameters:
out- the writer- Throws:
DataStoreException- if an error occurred accessing the data store
-
storeFrom
Stores the contents of a file to this blob.- Parameters:
file- the source file- Throws:
DataStoreException- if an error occurred accessing the data store
-
storeFrom
Stores the contents of a path to this blob.- Parameters:
path- the source path- Throws:
DataStoreException- if an error occurred accessing the data store
-
extractText
Extracts the content of this blob to a string.- Returns:
- the content of the blob
- Throws:
DataStoreException- if an error occurred accessing the data store
-
extractBytes
Extracts the content of this blob to bytes.- Returns:
- the content of the blob
- Throws:
DataStoreException- if an error occurred accessing the data store
-
extractPopulation
Extracts the content of this blob to aPopulation.- Returns:
- the content of the blob
- Throws:
DataStoreException- if an error occurred accessing the data store
-
extractInputStream
default <R> R extractInputStream(org.apache.commons.io.function.IOFunction<InputStream, R> function) throws DataStoreExceptionExecutes a function with anInputStreamfor reading this blob. The input stream is automatically closed when the function returns.- Type Parameters:
R- the return type- Parameters:
function- the function- Returns:
- the object read from the stream
- Throws:
DataStoreException- if an error occurred accessing the data store
-
extractReader
default <R> R extractReader(org.apache.commons.io.function.IOFunction<Reader, R> function) throws DataStoreExceptionExecutes a function with aReaderfor reading this blob. The reader is automatically closed when the function returns.- Type Parameters:
R- the return type- Parameters:
function- the function- Returns:
- the object read from the reader
- Throws:
DataStoreException- if an error occurred accessing the data store
-
extractState
default <T extends Stateful> T extractState(T value) throws DataStoreException, ClassNotFoundException Extracts the state and loads it into theStatefulobject.- Type Parameters:
T- the object type- Parameters:
value- the stateful object- Returns:
- the stateful object
- Throws:
DataStoreException- if an error occurred accessing the data storeClassNotFoundException- if the class of the serialized object could not be found
-
extractObject
Extracts the blob and deserializes the content.- Returns:
- the deserialized object
- Throws:
DataStoreException- if an error occurred accessing the data storeClassNotFoundException- 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:
DataStoreException- if an error occurred accessing the data storeClassNotFoundException- if the class of the serialized object could not be found
-
storeText
Stores the given string to this blob.- Parameters:
text- the text to store- Throws:
DataStoreException- if an error occurred accessing the data store
-
storeBytes
Stores the given data to this blob.- Parameters:
data- the data to store- Throws:
DataStoreException- if an error occurred accessing the data store
-
storePopulation
Stores the givenPopulationobject to this blob as a result file.- Parameters:
population- the population to store- Throws:
DataStoreException- if an error occurred accessing the data store
-
storeText
Stores the givenFormattableobject to this blob using theTableFormat.Plaintextformat.- Parameters:
formattable- the formattable object to store- Throws:
DataStoreException- if an error occurred accessing the data store
-
storeText
default void storeText(Formattable<?> formattable, TableFormat tableFormat) throws DataStoreException Stores the givenFormattableobject to this blob using the specified table format.- Parameters:
formattable- the formattable object to storetableFormat- the table format- Throws:
DataStoreException- if an error occurred accessing the data store
-
storeFrom
Stores the content read from an input stream to this this blob.- Parameters:
in- the input stream- Throws:
DataStoreException- if an error occurred accessing the data store
-
storeFrom
Stores the content read from a reader to this this blob.- Parameters:
reader- the reader- Throws:
DataStoreException- if an error occurred accessing the data store
-
storeOutputStream
default void storeOutputStream(org.apache.commons.io.function.IOConsumer<OutputStream> consumer) throws DataStoreException Executes a consumer with anOutputStreamfor writing to this blob. The stream is automatically closed when the consumer returns.- Parameters:
consumer- the consumer- Throws:
DataStoreException- if an error occurred accessing the data store
-
storePrintStream
default void storePrintStream(org.apache.commons.io.function.IOConsumer<PrintStream> consumer) throws DataStoreException Executes a consumer with aPrintStreamfor writing to this blob. The stream is automatically closed when the consumer returns.- Parameters:
consumer- the consumer- Throws:
DataStoreException- if an error occurred accessing the data store
-
storeWriter
default void storeWriter(org.apache.commons.io.function.IOConsumer<Writer> consumer) throws DataStoreException Executes a consumer with aWriterfor writing to this blob. The writer is automatically closed when the consumer returns.- Parameters:
consumer- the consumer function- Throws:
DataStoreException- if an error occurred accessing the data store
-
storeState
Stores aStatefulobject to the blob.- Type Parameters:
T- the object type- Parameters:
value- the stateful object to store- Throws:
DataStoreException- if an error occurred accessing the data store
-
storeObject
Stores a serializable object to the blob.- Parameters:
value- the object to store- Throws:
DataStoreException- if an error occurred accessing the data storeNotSerializableException- if the object is not serializable
-
getURI
Returns the URI for this blob, which can be used withDataStoreFactory.resolveBlob(java.net.URI).- Returns:
- the URI
-
toJSON
Returns a description of this blob formatted as JSON.- Returns:
- the JSON string
-
toJSON
Returns a description of this blob formatted as JSON.- Parameters:
baseURI- the base URI, which is used to produce URLs- Returns:
- the JSON string
-
toJSON
Returns a description of this blob formatted as JSON.- Parameters:
baseURI- the base URI, which is used to produce URLsfull- iftrue, output the full data (can produce large output)- Returns:
- the JSON string
-