com.webmethods.caf.faces.bean
Class SimpleFileExportBean

java.lang.Object
  extended by com.webmethods.caf.faces.bean.SimpleFileExportBean
All Implemented Interfaces:
IFileExportBean, IFileExportBeanEx

public class SimpleFileExportBean
extends Object
implements IFileExportBeanEx

This is a simple implementation of IFileExportBeanEx that is java bean compatible. If created as a bean then exportFileName, exportContentType and either binaryData or textData properties must be set. For textData, exportCharactersEncoding should be set as well.


Field Summary
protected  byte[] binaryData
          The data to be exported as byte []
protected  String charactersEncoding
          Character encoding for export of file content.
protected  int contentLength
          The length of data.
protected  String contentType
          The content type, see SimpleFileExportBean.setExportContentType(String).
protected  String fileName
          Name of the file to be exported.
protected  boolean forceDownload
          boolean for force download, see SimpleFileExportBean.setDownloadForced(boolean).
protected  boolean isBinary
          boolean that denotes that the content is binary.
protected  String textData
          The data to be exported as String
 
Fields inherited from interface com.webmethods.caf.faces.bean.IFileExportBean
UNKNOWN_CONTENT_LENGTH
 
Constructor Summary
SimpleFileExportBean()
          Bean empty constructor
SimpleFileExportBean(String fileName, String contentType, int contentLength, boolean forceDownload, byte[] binaryData)
          Constructor.
SimpleFileExportBean(String fileName, String contentType, int contentLength, boolean forceDownload, String textData)
          Constructor.
 
Method Summary
 byte[] getBinaryData()
          Returns the binary data.
 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
 String getTextData()
          Returns the text 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 setBinaryData(byte[] binaryData)
          Sets the binary data for export.
 void setDownloadForced(boolean forceDownload)
          Sets force download to send the response headers that will force the user to choose what to do with the file (Open vs.
 void setExportCharacterEncoding(String encoding)
          Sets character encoding for this export file content (valid only when isExportBinary() == false)
 void setExportContentType(String contentType)
          Sets the content type of the response being sent to the client.
 void setExportFileName(String fileName)
          Return the file name for the exported data.
 void setTextData(String textData)
          Sets the text data for export.
 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

forceDownload

protected boolean forceDownload
boolean for force download, see SimpleFileExportBean.setDownloadForced(boolean).


fileName

protected String fileName
Name of the file to be exported.


contentType

protected String contentType
The content type, see SimpleFileExportBean.setExportContentType(String).


contentLength

protected int contentLength
The length of data.


isBinary

protected boolean isBinary
boolean that denotes that the content is binary.


binaryData

protected byte[] binaryData
The data to be exported as byte []


textData

protected String textData
The data to be exported as String


charactersEncoding

protected String charactersEncoding
Character encoding for export of file content.

Default: UTF-8

Constructor Detail

SimpleFileExportBean

public SimpleFileExportBean()
Bean empty constructor


SimpleFileExportBean

public SimpleFileExportBean(String fileName,
                            String contentType,
                            int contentLength,
                            boolean forceDownload,
                            byte[] binaryData)
Constructor.

Parameters:
fileName - name of the file to be exported
contentType - the content type, see SimpleFileExportBean.setExportContentType(String)
contentLength - the length of data
forceDownload - force download, see SimpleFileExportBean.setDownloadForced(boolean)
binaryData - the data to be exported as byte []

SimpleFileExportBean

public SimpleFileExportBean(String fileName,
                            String contentType,
                            int contentLength,
                            boolean forceDownload,
                            String textData)
Constructor.

Parameters:
fileName - name of the file to be exported
contentType - the content type, see SimpleFileExportBean.setExportContentType(String)
contentLength - the length of data
forceDownload - force download, see SimpleFileExportBean.setDownloadForced(boolean)
textData - the data to be exported as String
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

setDownloadForced

public void setDownloadForced(boolean forceDownload)
Sets force download to send the response headers that will force the user to choose what to do with the file (Open vs. Save).

Parameters:
forceDownload - The forceDownload to set.

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

setExportFileName

public void setExportFileName(String fileName)
Return the file name for the exported data.

Parameters:
fileName - name for the 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

setExportContentType

public void setExportContentType(String contentType)
Sets 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.

Parameters:
contentType -

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

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 encoding)
Sets character encoding for this export file content (valid only when isExportBinary() == false)

Parameters:
encoding - Java character encoding name

getBinaryData

public byte[] getBinaryData()
Returns the binary data.

Returns:
binary data, or null if not set.

setBinaryData

public void setBinaryData(byte[] binaryData)
Sets the binary data for export. Also, forces the data to be exported as binary (character encoding will not apply).

Parameters:
binaryData - binary data as byte []

getTextData

public String getTextData()
Returns the text data.

Returns:
text data, or null if not set.

setTextData

public void setTextData(String textData)
Sets the text data for export. Also, forces the data to be exported with character encoding (binary export will not apply).

Parameters:
textData - text data as String