com.f1j.ss
Class DocumentSaveCallback

java.lang.Object
  |
  +--com.f1j.ss.DocumentSaveCallback

public class DocumentSaveCallback
extends java.lang.Object

This class may be extended to provide custom handling of conditions that arise while saving a file, and to customize some behaviors of the save operation.

Since:
12.0

Constructor Summary
DocumentSaveCallback()
          Constructs a default DocumentSaveCallback.
 
Method Summary
protected  void fileExists(boolean readOnly)
          Called if the save operation will overwrite an existing file.
protected  void foreignFileFormatLosesData()
          Called if the save operation will lose data because the file is being written in a non-Actuate file format that does not support all of the workbook's data.
 BookView getBookView()
          Called to determine which view's state will be saved with the workbook.
 java.io.OutputStream getCacheStream()
          Returns a stream to which the data cache is to be written, instead of writing it to the workbook file itself.
 Sheet getSheet()
          Called when the file format only supports saving a single sheet.
protected  boolean isWriteQueryCache()
          This dictates whether the data cache should be included in the file.
protected  void notifyGUID(java.lang.String guid)
          Called by the e.Spreadsheet engine to provide the workbook file's GUID to the application.
 

Constructor Detail

DocumentSaveCallback

public DocumentSaveCallback()
Constructs a default DocumentSaveCallback.
Method Detail

fileExists

protected void fileExists(boolean readOnly)
                   throws DocumentCancelException

Called if the save operation will overwrite an existing file.

If this method returns normally, the existing file will be overwritten. However, the save operation may still fail if the existing file is read-only and the rules of the underlying filesystem do not allow it to be replaced.

The default implementation of this method throws a DocumentCancelException if the existing file is read-only.

Parameters:
readOnly - true if the existing file is read-only.
Throws:
DocumentCancelException - To explicitly cancel the save operation.

foreignFileFormatLosesData

protected void foreignFileFormatLosesData()
                                   throws DocumentCancelException

Called if the save operation will lose data because the file is being written in a non-Actuate file format that does not support all of the workbook's data.

If this method returns normally, the save will proceed.

Throws:
DocumentCancelException - To explicitly cancel the save operation.

getSheet

public Sheet getSheet()

Called when the file format only supports saving a single sheet. This method may be overridden to specify which sheet is to be saved.

If this method returns null, or if the sheet returned is invalid or not part of the book being saved, e.Spreadsheet will attempt to pick the best sheet to saved based on any available information. For example, if getViewInfo() is implemented, the active sheet will be used.

The default implementation of this method returns null.


getBookView

public BookView getBookView()

Called to determine which view's state will be saved with the workbook.

When multiple BookModel or JBook instances refer to the same workbook, each has its own view state. This method picks a view state to be saved in the file.

If this method returns null, or if the BookView returned is not part of the book being saved, e.Spreadsheet will use the default, headless view. The headless view is not directly accessible via the API, but its state may be set to that of any BookModel by calling the saveViewInfo method. However, that method is deprecated and its use is not recommended.

If DocumentSaveCallback was created using a cosntructor that specifies a BookView or a ViewContainer, then the default implementation of this method returns the approrpiate BookView object. Otherwise, the default implementation returns null.

See Also:
BookModel.getBookView()

getCacheStream

public java.io.OutputStream getCacheStream()
                                    throws java.io.IOException

Returns a stream to which the data cache is to be written, instead of writing it to the workbook file itself.

This is an advanced overridable used by certain applications to implement special caching of query results. By default, this method returns null, and the cache is stored in the workbook file.

Throws:
java.io.IOException -  

notifyGUID

protected void notifyGUID(java.lang.String guid)

Called by the e.Spreadsheet engine to provide the workbook file's GUID to the application.

This is an advanced overridable used by certain applications to implement caching of workbooks. The default implementation of this method does nothing.

Parameters:
guid - A string object representing the workbook file's GUID.

isWriteQueryCache

protected boolean isWriteQueryCache()
This dictates whether the data cache should be included in the file. By default, the cache is included.
Returns:
whether the data cache should be included in the file.