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 interface
Interface for supplier ofInputStream
instances. -
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 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.@Nonnull String
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.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.FileResult
getFlavors
Methods 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
ResultAction
handled this Result. -
getFileSize
Returns the size of this result in bytes.- Specified by:
getFileSize
in 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
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:
Exception
- if there is a problem accessing the data
-
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:
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 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.
-