Overview Package Class Tree Deprecated Index Help
PREV CLASS NEXT CLASS FRAMES NO FRAMES All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD

diva.gui
Interface StoragePolicy

All Known Implementing Classes:
AbstractStoragePolicy

public interface StoragePolicy

StoragePolicy captures the notion of how an application deals with persistent storage. For example, suppose a user selects the Close entry on a menu. The application typically needs to check whether the document has been edited, and if so, it needs to decide what to do about it. Two choices are:

  1. Prompt the user asking whether to save the document first.
  2. Save it anyway.
  3. Save it but checkpoint the current state of the document so it can be undone later.
  4. Sing "Daisy"
Each of these is an example of a storage policy. Because different applications may need different policies, yet some applications will use the same policies as other application, the concept of a storage policy has been reified into this interface and a set of implementing classes.

Version:
$Id: StoragePolicy.java,v 1.9 2005年07月08日 19:55:12 cxh Exp $
Author:
John Reekie

Method Summary
boolean close(Document d)
Close the document.
Document open(Application app)
Open a new document.
Document open(java.io.File file, Application app)
Open a file and create a new document.
Document open(java.net.URL url, Application app)
Open a URL and create a new document.
boolean save(Document d)
Save the document.
boolean saveAs(Document d)
Save the document to a user-specified location.

Method Detail

close

public boolean close(Document d)
Close the document. Depending on the policy, this method will probably check whether the document has been edited and annoy the user with dialog boxes. If the document is null, do nothing. Return true if the document closed, otherwise false.


open

public Document open(Application app)
Open a new document. This method will generally prompt the user for a location to open. If a new Document is created, return it, otherwise return null. (Note that if an existing document is re-opened, null is still returned.)


open

public Document open(java.io.File file,
 Application app)
Open a file and create a new document. Depending on the policy, this method may choose to check whether the file has already been opened, and use the existing data, open a read-only view, etc. If it does open the file, it will use the passed DocumentFactory to do so. If a new Document is created, return it, otherwise return null. (Note that if an existing document is re-opened, null is still returned.)


open

public Document open(java.net.URL url,
 Application app)
Open a URL and create a new document. Depending on the policy, this method may choose to check whether the URL has already been opened, and use the existing data, etc. If it does open the file, it will use the passed DocumentFactory to do so. If a new Document is created, return it, otherwise return null. (Note that if an existing document is re-opened, null is still returned.)


save

public boolean save(Document d)
Save the document. Most policies will just save the file if it is possible to do so, but different policies may take different action of the file is write-protected (for example). Do nothing if the document is null. Return true if the file saved, otherwise false.


saveAs

public boolean saveAs(Document d)
Save the document to a user-specified location. Depending on the policy, this may prompt the user for the file or URL location, and may or may not change the file or URL of the document to the new location. Do nothing if the document is null. Return true if the file saved, otherwise false.


Overview Package Class Tree Deprecated Index Help
PREV CLASS NEXT CLASS FRAMES NO FRAMES All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD

AltStyle によって変換されたページ (->オリジナル) /