com.webmethods.caf.faces.data.export
Class CSVExportBean

java.lang.Object
  extended by com.webmethods.caf.faces.data.export.CSVExportBean
All Implemented Interfaces:
IFileExportBean, IFileExportBeanEx

public class CSVExportBean
extends Object
implements IFileExportBeanEx

Writes the content of an ITableContentProvider as a csv file. The ITableContentProvider must specify the list of available columns via its IContentProvider.getPropertyKeys() method.


Field Summary
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
           
 
Fields inherited from interface com.webmethods.caf.faces.bean.IFileExportBean
UNKNOWN_CONTENT_LENGTH
 
Constructor Summary
CSVExportBean()
           
CSVExportBean(ITableContentProvider contentProvider)
           
CSVExportBean(ITableContentProvider contentProvider, String exportFileName)
           
 
Method Summary
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.
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RE_SHOULD_ESCAPE

protected Pattern RE_SHOULD_ESCAPE

RE_REPLACE_QUOTES

protected Pattern RE_REPLACE_QUOTES

m_downloadForced

protected boolean m_downloadForced
True to force file download dialog.


m_exportFileName

protected String m_exportFileName
Default filename in file download dialog.


m_exportCharacterEncoding

protected String m_exportCharacterEncoding
Export character encoding.


m_contentProvider

protected ITableContentProvider m_contentProvider
Export content provider.

Constructor Detail

CSVExportBean

public CSVExportBean()

CSVExportBean

public CSVExportBean(ITableContentProvider contentProvider)

CSVExportBean

public CSVExportBean(ITableContentProvider contentProvider,
                     String exportFileName)
Method Detail

isDownloadForced

public boolean isDownloadForced()
Description copied from interface: IFileExportBean
Return true to send the response headers that will force the user to choose what to do with the file (Open vs. Save).

Specified by:
isDownloadForced in interface IFileExportBean
Returns:
true to force a download

getExportFileName

public String getExportFileName()
Description copied from interface: IFileExportBean
Return the file name for the exported data

Specified by:
getExportFileName in interface IFileExportBean
Returns:
file name for the exported file

getExportContentType

public String getExportContentType()
Description copied from interface: IFileExportBean
Gets the content type of the response being sent to the client. The content type may include the type of character encoding used, for example, text/html; charset=ISO-8859-4.

Specified by:
getExportContentType in interface IFileExportBean
Returns:
content type of the exported content

getExportContentLength

public int getExportContentLength()
Description copied from interface: IFileExportBean
Return the length of the content that is to be exported.

Specified by:
getExportContentLength in interface IFileExportBean
Returns:
the length of the content or return IFileExportBean.UNKNOWN_CONTENT_LENGTH if it is not known

isExportBinary

public boolean isExportBinary()
Description copied from interface: IFileExportBean
Return true if the export will be sending binary data to the response, false if the export will be sending text.

Specified by:
isExportBinary in interface IFileExportBean
Returns:
true for binary export, false for text

writeExportText

public void writeExportText(PrintWriter writer)
Description copied from interface: IFileExportBean
Invoked to allow the bean to write the export text to the output writer.

Specified by:
writeExportText in interface IFileExportBean
Parameters:
writer - the output writer

writeExportBytes

public void writeExportBytes(OutputStream outStream)
                      throws IOException
Description copied from interface: IFileExportBean
Invoked to allow the bean to write binary data to the output stream.

Specified by:
writeExportBytes in interface IFileExportBean
Parameters:
outStream - the output stream
Throws:
IOException - thrown if there is an I/O exception during the export

escapeValue

protected String escapeValue(Object o)
Converts the specified object to a string and escapes it as a csv field value. Returns "" if the specified object is null.


setDownloadForced

public void setDownloadForced(boolean value)

setExportFileName

public void setExportFileName(String value)

getExportCharacterEncoding

public String getExportCharacterEncoding()
Description copied from interface: IFileExportBeanEx
Returns character encoding for this export file content (valid only when isExportBinary() == false)

Specified by:
getExportCharacterEncoding in interface IFileExportBeanEx
Returns:
java character encoding name

setExportCharacterEncoding

public void setExportCharacterEncoding(String value)

getContentProvider

public ITableContentProvider getContentProvider()

setContentProvider

public void setContentProvider(ITableContentProvider value)