Class LocalFileResult
java.lang.Object
com.inet.taskplanner.server.api.result.LocalFileResult
- All Implemented Interfaces:
FileResult, Result
A result that is based on a file.
- Since:
- taskplanner 3.0
-
Constructor Summary
ConstructorsConstructorDescriptionLocalFileResult(@Nonnull File file, boolean deleteOnCleanUp) Creates a new instance. -
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.Get 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.@Nonnull List<ResultFlavor> Defines the types of data this result contains.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Result
supportsFlavor, supportsOneFlavorOf
-
Constructor Details
-
LocalFileResult
Creates a new instance.- Parameters:
file- the underlying file. Cannot be a directory.deleteOnCleanUp- iftrue, the file will be deleted after processing all results (even if this result was not used)- Throws:
IllegalArgumentException- if the given file is a directoryNullPointerException- if file is null- Since:
- taskplanner 3.0
-
-
Method Details
-
getFlavors
Defines the types of data this result contains.- Specified by:
getFlavorsin interfaceFileResult- Specified by:
getFlavorsin interfaceResult- Returns:
- the
ResultFlavorvalues of this result
-
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.
-
getFileSize
public long getFileSize()Returns the size of this result in bytes.- Specified by:
getFileSizein 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
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:
IOException
-
cleanup
public void 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. -
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:
IOException
-