Class LazyInputStreamFileResult
java.lang.Object
com.inet.taskplanner.server.api.result.LazyInputStreamFileResult
- All Implemented Interfaces:
FileResult, Result
This file result obtains its content from an input-stream supplier and forwards it as a file result.
Since the content is supplied lazily, its size is unknown.
This should be used for large results whose size is undetermined.
- Since:
- 24.10
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceInterface for supplier ofInputStreaminstances. -
Constructor Summary
ConstructorsConstructorDescriptionLazyInputStreamFileResult(@Nonnull String name, @Nonnull LazyInputStreamFileResult.InputStreamSupplier supplier) Creates a lazy stream file result with a name and an input-stream supplier. -
Method Summary
Modifier and TypeMethodDescriptionvoidcleanup()When result handling is finished, this method is called to release resources held by the result.@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 Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface FileResult
getFlavorsMethods inherited from interface Result
supportsFlavor, supportsOneFlavorOf
-
Constructor Details
-
LazyInputStreamFileResult
public LazyInputStreamFileResult(@Nonnull String name, @Nonnull LazyInputStreamFileResult.InputStreamSupplier supplier) Creates a lazy stream file result with a name and an input-stream supplier.- 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, this method is called to release resources held by the result.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
actionprocesses this result. Those calls come one after another: the first action has finished its work (and closed the stream) before the second calls this method.The caller will close the Stream.
- Specified by:
getFileContentin interfaceFileResult- Returns:
- an input stream that 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 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. For example, in an email, this can be used as the name of an attached file.- Specified by:
getFileNamein interfaceFileResult- Returns:
- a name for this result.
-