Class LazyInputStreamFileResult
java.lang.Object
com.inet.taskplanner.server.api.result.LazyInputStreamFileResult
- All Implemented Interfaces:
FileResult,Result
This is a file result that takes in the input stream as is
and allows to simply forward it as file result.
Since we do not know what kind of data it will deliver, there is no file size
This should be used for large results whose results are in-determined
- Since:
- 24.10
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceInterface for supplier ofInputStreaminstances. -
Constructor Summary
ConstructorsConstructorDescriptionLazyInputStreamFileResult(@Nonnull String name, @Nonnull LazyInputStreamFileResult.InputStreamSupplier supplier) Create the lazy stream file result, just with a name and the stream -
Method Summary
Modifier and TypeMethodDescriptionvoidcleanup()When result-handling is finished, then this method is called to clean up used system resources, i.e.@Nonnull InputStreamGet a stream to access the data of this result.@Nonnull StringGet the MIME type this result has.@Nonnull StringReturns a human readable name of this result, typically a file name.longReturns the size of this result in bytes.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.inet.taskplanner.server.api.result.FileResult
getFlavorsMethods inherited from interface com.inet.taskplanner.server.api.result.Result
supportsFlavor, supportsOneFlavorOf
-
Constructor Details
-
LazyInputStreamFileResult
public LazyInputStreamFileResult(@Nonnull @Nonnull String name, @Nonnull @Nonnull LazyInputStreamFileResult.InputStreamSupplier supplier) Create the lazy stream file result, just with a name and the stream- Parameters:
name- the name of the result filesupplier- supplier of the input stream to use- Since:
- 24.10
-
-
Method Details
-
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
ResultActionhandled this Result. -
getFileSize
Returns the size of this result in bytes.- Specified by:
getFileSizein interfaceFileResult- Returns:
- the size in bytes
- Throws:
Exception- if the result data makes problems
-
getFileContent
Get a stream to access the data of this result.Note that this method is called multiple times when more than one
actionprocessed 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:
getFileContentin interfaceFileResult- Returns:
- an InputStream which can transfer the data of this result
- Throws:
Exception- if there is a problem accessing the data
-
getFileContentType
Get the MIME type this result has.- Specified by:
getFileContentTypein interfaceFileResult- Returns:
- the content type of this result. When null, 'application/octet-stream' is to be used.
- Throws:
Exception- if the type is could not be determined due to an IO problem
-
getFileName
Returns a human readable name of this result, typically a file name.It depends on the
Result-implementation and on theResultActionwhether 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 aStringTextResultit will not appear in the email.- Specified by:
getFileNamein interfaceFileResult- Returns:
- a name for this result.
-