Class DownloadOutput
java.lang.Object
com.invirgance.convirgance.web.output.DownloadOutput
- All Implemented Interfaces:
com.invirgance.convirgance.output.Output
@Wiring
public class DownloadOutput
extends Object
implements com.invirgance.convirgance.output.Output
A wrapper to force the user's browser to download the output instead of
opening it. This is typically used to force a download of spreadsheet formats
like CSV, though it can be used to wrap browser formats like JSON.
A filename can be optionally specified to set the name of the file to
download. Curly braces can be used to inject parameters into the filename. For
example, setting filename to
"Report {generate_date}.csv" would
replace {generate_date} with the value from the parameters list.- Author:
- jbanes
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the MIME type of the wrappedOutputobject.The name of the downloaded file.com.invirgance.convirgance.output.OutputReturns theOutputobject being wrapped.voidsetFilename(String filename) Set the name of the downloaded file.voidsetOutput(com.invirgance.convirgance.output.Output output) Set theOutputobject to wrap.com.invirgance.convirgance.output.OutputCursorwrite(com.invirgance.convirgance.target.Target target) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.invirgance.convirgance.output.Output
write
-
Constructor Details
-
DownloadOutput
public DownloadOutput()
-
-
Method Details
-
getOutput
public com.invirgance.convirgance.output.Output getOutput()Returns theOutputobject being wrapped.- Returns:
- the wrapped output
-
setOutput
public void setOutput(com.invirgance.convirgance.output.Output output) Set theOutputobject to wrap.- Parameters:
output- generates the data downloaded by the client
-
getFilename
The name of the downloaded file.- Returns:
- the name of the downloaded file or null if no filename was set
-
setFilename
Set the name of the downloaded file. Values from the parameters list can be injected using curly braces. For example, setting filename to"Report {generate_date}.csv"would replace{generate_date}with the value from the parameters list.- Parameters:
filename- the name of the downloaded file
-
write
public com.invirgance.convirgance.output.OutputCursor write(com.invirgance.convirgance.target.Target target) - Specified by:
writein interfacecom.invirgance.convirgance.output.Output
-
getContentType
Returns the MIME type of the wrappedOutputobject.- Specified by:
getContentTypein interfacecom.invirgance.convirgance.output.Output- Returns:
- the MIME type of the output
-