Class ByteArrayFileResult
java.lang.Object
com.inet.taskplanner.server.api.result.ByteArrayFileResult
- All Implemented Interfaces:
FileResult
,Result
A result that is based on in memory byte array.
- Since:
- taskplanner 3.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
cleanup()
When result-handling is finished, then this method is called to clean up used system resources, i.e.@Nonnull InputStream
Get a stream to access the data of this result.Get the MIME type this result has.@Nonnull String
Returns a human readable name of this result, typically a file name.long
Returns the size of this result in bytes.@Nonnull List<ResultFlavor>
Defined the types of data this Result contains.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.inet.taskplanner.server.api.result.Result
supportsFlavor, supportsOneFlavorOf
-
Constructor Details
-
ByteArrayFileResult
Create a new instance.- Parameters:
name
- the name of the contentdata
- the content data- Throws:
IllegalArgumentException
- if the given file is a directory- Since:
- taskplanner 3.0
-
-
Method Details
-
getFlavors
Defined the types of data this Result contains.- Specified by:
getFlavors
in interfaceFileResult
- Specified by:
getFlavors
in interfaceResult
- Returns:
- the
ResultFlavor
of this Result.
-
getFileName
Returns a human readable name of this result, typically a file name.It depends on the
Result
-implementation and on theResultAction
whether and where this appears. E.g. in an email this will be the name of the attached file of this is aLocalFileResult
, if this is aStringTextResult
it will not appear in the email.- Specified by:
getFileName
in interfaceFileResult
- Returns:
- a name for this result.
-
getFileSize
public long getFileSize()Returns the size of this result in bytes.- Specified by:
getFileSize
in interfaceFileResult
- Returns:
- the size in bytes
-
getFileContent
Get a stream to access the data of this result.Note that this method is called multiple times when more than one
action
processed this result. Those calls come one after another: the first has finished it's work (closed the stream) when the second calls this method.The caller will close the Stream.
- Specified by:
getFileContent
in interfaceFileResult
- Returns:
- an InputStream which can transfer the data of this result
- Throws:
IOException
-
cleanup
public void cleanup()When result-handling is finished, then this method is called to clean up used system resources, i.e. to delete a created file.This is also called if no appropriate
ResultAction
handled this Result. -
getFileContentType
Get the MIME type this result has.- Specified by:
getFileContentType
in interfaceFileResult
- Returns:
- the content type of this result. When null, 'application/octet-stream' is to be used.
- Throws:
IOException
-