org.tigris.scarab.screens
Class DataExport

java.lang.Object
  extended byorg.apache.turbine.modules.Module
      extended byorg.apache.turbine.modules.SecureModule
          extended byorg.apache.turbine.modules.screens.TemplateSecureScreen
              extended byorg.apache.turbine.TemplateSecureScreen
                  extended byorg.tigris.scarab.screens.Default
                      extended byorg.tigris.scarab.screens.DataExport
Direct Known Subclasses:
IssueListExport, ReportExport

class DataExport
extends Default

Sends file contents directly to the output stream, setting the Content-Type and writing back to the browser a tab-delimited file (Excel digests this fine). We used to use POI to compose an Excel binary data file, but its outrageous memory consumption didn't scale for large result sets. POI assembles the its output in memory. After study of the native OLE2 Excel file format, it appears very difficult to generate the file in another fashion.

Regards output encoding, for now we're assuming the response stream is appropriately set upon fetching. Also, we're assuming that Excel will do the right thing on receipt of our TSV file with Japanese or other multibyte characters (we're not setting an encoding on the Content-Type we return). Both of the above to be verified.

Since:
Scarab 1.0
Author:
John McNally, St.Ack, Daniel Rall

Nested Class Summary
protected  class DataExport.TSVPrinter
          Uses a PrintWriter internally to do actual writing.
 
Field Summary
protected static java.lang.String NO_CONTENT
          What to show if a cell is empty.
 
Constructor Summary
(package private) DataExport()
           
 
Method Summary
protected  boolean containsElements(java.util.List l)
           
 void doBuildTemplate(org.apache.turbine.RunData data, org.apache.turbine.TemplateContext context)
          Sets the Content-Type header for the response.
protected  java.lang.String escapeCommas(java.lang.String s)
          Escape any commas in passed string.
protected  java.lang.String getEncodingForExport(org.apache.turbine.RunData data)
          This function encapsulates the logic of determining which encoding to use.
protected  java.io.Writer getWriter(org.apache.turbine.RunData data)
          This function is available to subclasses -- it is used to provide a Writer based on the current request and the site configuration, taking encoding issues into consideration.
 
Methods inherited from class org.tigris.scarab.screens.Default
checkAuthorized, doBuild, getLocalizationTool, getScarabRequestTool, getTitle, isAuthorized, setTargetLogin, setTargetSelectModule
 
Methods inherited from class org.apache.turbine.modules.SecureModule
doBuildTemplate
 
Methods inherited from class org.apache.turbine.modules.Module
build, evaluate, execute, getPullService, getTemplateContext, getTemplateService, getTool, handleRequest, handleRequest, requestFinished, setTarget, setTemplate, templateExists
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NO_CONTENT

protected static final java.lang.String NO_CONTENT
What to show if a cell is empty. The empty string is dealt with best by spreadsheet applications.

See Also:
Constant Field Values
Constructor Detail

DataExport

DataExport()
Method Detail

doBuildTemplate

public void doBuildTemplate(org.apache.turbine.RunData data,
                            org.apache.turbine.TemplateContext context)
                     throws java.lang.Exception
Sets the Content-Type header for the response. Since this assumes we're writing the reponse ourself, indicates no target to render by setting it to null.

Overrides:
doBuildTemplate in class Default
Throws:
java.lang.Exception

getEncodingForExport

protected java.lang.String getEncodingForExport(org.apache.turbine.RunData data)
This function encapsulates the logic of determining which encoding to use. Right now, the encoding isn't per-request, but that should be changed.


getWriter

protected java.io.Writer getWriter(org.apache.turbine.RunData data)
                            throws java.io.IOException
This function is available to subclasses -- it is used to provide a Writer based on the current request and the site configuration, taking encoding issues into consideration.

Throws:
java.io.IOException

escapeCommas

protected java.lang.String escapeCommas(java.lang.String s)
Escape any commas in passed string.

Parameters:
s - String to check.
Returns:
Passed string with commas escaped.

containsElements

protected final boolean containsElements(java.util.List l)


Copyright © 2000-2004 Tigris.org. All Rights Reserved.