public class CSVExportBean extends Object implements IFileExportBeanEx
ITableContentProvider
as a csv file.
The ITableContentProvider must specify the list of available columns
via its IContentProvider.getPropertyKeys()
method.Modifier and Type | Field and Description |
---|---|
protected ITableContentProvider |
m_contentProvider
Export content provider.
|
protected boolean |
m_downloadForced
True to force file download dialog.
|
protected String |
m_exportCharacterEncoding
Export character encoding.
|
protected String |
m_exportFileName
Default filename in file download dialog.
|
protected Pattern |
RE_REPLACE_QUOTES |
protected Pattern |
RE_SHOULD_ESCAPE |
protected Pattern |
RE_SHOULD_PREFIX |
UNKNOWN_CONTENT_LENGTH
Constructor and Description |
---|
CSVExportBean() |
CSVExportBean(ITableContentProvider contentProvider) |
CSVExportBean(ITableContentProvider contentProvider,
String exportFileName) |
Modifier and Type | Method and Description |
---|---|
protected String |
escapeValue(Object o)
Converts the specified object to a string and escapes it as a csv field value.
|
ITableContentProvider |
getContentProvider() |
String |
getExportCharacterEncoding()
Returns character encoding for this export file content (valid only when isExportBinary() == false)
|
int |
getExportContentLength()
Return the length of the content that is to be exported.
|
String |
getExportContentType()
Gets the content type of the response being sent to the client.
|
String |
getExportFileName()
Return the file name for the exported data
|
boolean |
isDownloadForced()
Return true to send the response headers that will force the user
to choose what to do with the file (Open vs.
|
boolean |
isExportBinary()
Return true if the export will be sending binary data to the response, false if
the export will be sending text.
|
protected String |
prefixValue(Object o)
Converts the specified object to a string and prefix a single quote for every formula
|
void |
setContentProvider(ITableContentProvider value) |
void |
setDownloadForced(boolean value) |
void |
setExportCharacterEncoding(String value) |
void |
setExportFileName(String value) |
void |
writeExportBytes(OutputStream outStream)
Invoked to allow the bean to write binary data to
the output stream.
|
void |
writeExportText(PrintWriter writer)
Invoked to allow the bean to write the export text
to the output writer.
|
protected Pattern RE_SHOULD_ESCAPE
protected Pattern RE_REPLACE_QUOTES
protected Pattern RE_SHOULD_PREFIX
protected boolean m_downloadForced
protected String m_exportFileName
protected String m_exportCharacterEncoding
protected ITableContentProvider m_contentProvider
public CSVExportBean()
public CSVExportBean(ITableContentProvider contentProvider)
public CSVExportBean(ITableContentProvider contentProvider, String exportFileName)
public boolean isDownloadForced()
IFileExportBean
isDownloadForced
in interface IFileExportBean
public String getExportFileName()
IFileExportBean
getExportFileName
in interface IFileExportBean
public String getExportContentType()
IFileExportBean
getExportContentType
in interface IFileExportBean
public int getExportContentLength()
IFileExportBean
getExportContentLength
in interface IFileExportBean
IFileExportBean.UNKNOWN_CONTENT_LENGTH
if it is not knownpublic boolean isExportBinary()
IFileExportBean
isExportBinary
in interface IFileExportBean
public void writeExportText(PrintWriter writer)
IFileExportBean
writeExportText
in interface IFileExportBean
writer
- the output writerpublic void writeExportBytes(OutputStream outStream) throws IOException
IFileExportBean
writeExportBytes
in interface IFileExportBean
outStream
- the output streamIOException
- thrown if there is an I/O exception during the exportprotected String escapeValue(Object o)
protected String prefixValue(Object o)
public void setDownloadForced(boolean value)
public void setExportFileName(String value)
public String getExportCharacterEncoding()
IFileExportBeanEx
getExportCharacterEncoding
in interface IFileExportBeanEx
public void setExportCharacterEncoding(String value)
public ITableContentProvider getContentProvider()
public void setContentProvider(ITableContentProvider value)