com.borland.primetime.node
Class ProjectStorage

java.lang.Object
  |
  +--com.borland.primetime.node.ProjectStorage

public abstract class ProjectStorage
extends java.lang.Object

Provides standard interface and support for implementations which know how to read/write each of the registered project types. There is one instance for each project which has been opened.


Field Summary
protected  Project project
          Project instance whose storage is being managed by this object.
 
Constructor Summary
ProjectStorage(Project project)
          ProjectStorage instances all have an associated project that they read / write.
 
Method Summary
 boolean canWriteProject()
          Describes whether or not a ProjectStorage is capable of writing a project file.
protected  FileNode createParentedFileNode(Project project, Node parent, Url url)
          Creates a FileNode for this project using the given parent.
 byte[] getBufferContent()
          Returns current content of the project.
static Url getDefaultProjectUrl()
          Returns a reference to the default project to be used if need to create project.
 void initializeProject()
          Initializes project by either reading it from a previously saved version if that exists, or else by reading the default project.
protected abstract  void readProject(java.io.InputStream inputStream, Url rootUrl)
          Hook for reading project.
static void registerStorageClass(java.lang.String extension, java.lang.String description, java.lang.Class storageClass)
          Add a new storage type to the registry of known types and their associated extensions.
static void setDefaultProjectUrl(Url defaultProjectUrl)
          Saves a reference to the default project to be used if need to create project.
protected  void writeProject(java.io.OutputStream outputStream, Url rootUrl, java.util.List nodes)
          Hook for writing project.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

project

protected Project project
Project instance whose storage is being managed by this object.
Constructor Detail

ProjectStorage

public ProjectStorage(Project project)
ProjectStorage instances all have an associated project that they read / write.
Parameters:
project - Project this object is to be associated with.
Method Detail

setDefaultProjectUrl

public static void setDefaultProjectUrl(Url defaultProjectUrl)
Saves a reference to the default project to be used if need to create project.
Parameters:
defaultProjectUrl - Url of the default project.

getDefaultProjectUrl

public static Url getDefaultProjectUrl()
Returns a reference to the default project to be used if need to create project.
Returns:
Returns Url of the default project.

createParentedFileNode

protected FileNode createParentedFileNode(Project project,
                                          Node parent,
                                          Url url)
                                   throws DuplicateNodeException
Creates a FileNode for this project using the given parent.
Parameters:
project - Project to contain node.
parent - Parent for node, may be null.
url - Url of file.
Returns:
Returns a FileNode matching registered file extension.
Throws:
DuplicateNodeException -  

readProject

protected abstract void readProject(java.io.InputStream inputStream,
                                    Url rootUrl)
                             throws java.lang.Exception
Hook for reading project.
Parameters:
inputStream - Content of a previously saved project.
rootUrl - Location of the project.
Throws:
java.lang.Exception -  

initializeProject

public void initializeProject()
Initializes project by either reading it from a previously saved version if that exists, or else by reading the default project.
Throws:
AssertionException - if an error occurs

canWriteProject

public boolean canWriteProject()

Describes whether or not a ProjectStorage is capable of writing a project file. This method is primarily intended for use by ProjectStorage subclasses that provide read-only access to a particular project file format.

The basic ProjectStorage implementation for this method returns false.

Returns:
True if writeProject can be called on this ProjectStorage instance, false otherwise.

writeProject

protected void writeProject(java.io.OutputStream outputStream,
                            Url rootUrl,
                            java.util.List nodes)
                     throws java.io.IOException
Hook for writing project.
Parameters:
outputStream - Where to write.
rootUrl - Location of the project.
nodes - List of nodes that are members of the project.
Throws:
java.io.IOException -  
ReadOnlyException -  

getBufferContent

public byte[] getBufferContent()
Returns current content of the project.
Returns:
Returns an array of bytes.
Throws:
AssertionException - if an error occurs

registerStorageClass

public static void registerStorageClass(java.lang.String extension,
                                        java.lang.String description,
                                        java.lang.Class storageClass)
Add a new storage type to the registry of known types and their associated extensions.
Parameters:
extension - The extension that this registration is associated with. Extensions are case-insensitive and do not include the leading period character.
description - Not used.
storageClass - A subclass of ProjectStorage that should be instantiated to load and save projects with the matching extension.