com.borland.primetime.node
Class FileNode

java.lang.Object
  |
  +--com.borland.primetime.node.Node
        |
        +--com.borland.primetime.node.UrlNode
              |
              +--com.borland.primetime.node.FileNode
Direct Known Subclasses:
BinaryResourceFileNode, ClassFileNode, ImageFileNode, TextFileNode

public class FileNode
extends UrlNode

FileNode instances represent nodes within a project that are associated with storage outside the project file. Each FileNode has a single associated Url that represents storage available to the node, and no two FileNode instances in the same project may be associated with the same Url.

See Also:
LightweightNode

Fields inherited from class com.borland.primetime.node.Node
EMPTY_ARRAY, nodeListeners
 
Constructor Summary
FileNode(Project project, Node parent, Url url)
          All FileNode subtypes must expose this constructor signature.
 
Method Summary
 void check()
          Performs any periodic task required to keep the node's state up to date.
 Buffer findBuffer()
           
static java.lang.Class findFileNodeClass(java.lang.String extension, boolean includeBackups)
          Searches the node class registry to attempt to match a file extension with a node type.
static java.lang.Class findFileNodeClass(Url url)
          Searches the node class registry to attempt to match a file extension with a node type assuming that backup files should be matched to the original file's node type.
static java.lang.Class findFileNodeClass(Url url, boolean includeBackups)
          Searches the node class registry to attempt to match a file extension with a node type.
 Buffer getBuffer()
          Provide lazy buffer loading by requesting a Buffer instance using the VFS the first time it is required and then caching the result.
 javax.swing.Icon getDisplayIcon()
          Provides an image to be used for graphical representation of the node.
 java.lang.String getDisplayName()
          Uses the the FileNode's underlying Url to derive a display name.
 int getDisplaySequence()
          Describes the logical group the node belongs to for ordering purposes.
 java.io.InputStream getInputStream()
          Create an input stream to read from the underlying Url.
 java.lang.String getLongDisplayName()
          Use the Url's file component for display purposes except for the NewFilesystem where the full path is meaningless.
 java.io.OutputStream getOutputStream()
          Create an output stream to write to the underlying Url.
 long getTimestamp()
           
 Url getUrl()
          Returns the node's associated Url.
 boolean isModified()
          Describes the modified state of the node's underlying storage.
 boolean isNew()
          BWS-
 boolean isPersistant()
          Determines whether or not the node definition and its properties will be saved with in a project file.
 boolean isReadOnly()
           
static void registerFileNodeClass(java.lang.String extension, java.lang.String description, java.lang.Class nodeClass, javax.swing.Icon icon)
          Add a new node type to the registry of known types and their assocaited extensions.
 void rename(Url url)
          rename cannot change the type of a FileNode.
 void revert()
           
 void save()
           
 void saveAs(Url url)
          saveAs cannot change the type of a FileNode.
protected  void setUrl(Url url)
          Changes the node's associated Url.
 
Methods inherited from class com.borland.primetime.node.UrlNode
getSuggestedUrl
 
Methods inherited from class com.borland.primetime.node.Node
addNodeListener, compareTo, dumpNodes, dumpNodes, dumpNodes, equals, fireNodeRenamed, getChildren, getDisplayChildren, getNodeID, getParent, getProject, getProperties, getProperty, getProperty, getProperty, hasChildren, hasDisplayChildren, hashCode, removeNodeListener, setParent, setProperty, setProperty, setProperty, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FileNode

public FileNode(Project project,
                Node parent,
                Url url)
         throws DuplicateNodeException
All FileNode subtypes must expose this constructor signature.
Parameters:
project - The project that the newly created node belongs to. This value must not be null.
parent - The immediate parent of this node. If this value is not null the parent node must belong to the same project.
url - The storage available to this node.
Method Detail

getUrl

public Url getUrl()
Returns the node's associated Url.
Overrides:
getUrl in class UrlNode
Returns:
The Url associated with this FileNode.

setUrl

protected void setUrl(Url url)
               throws DuplicateNodeException
Changes the node's associated Url. Most code should avoid using this method directly and call rename or saveAs instead.
Parameters:
url - The new Url to associate with this FileNode.
Throws:
DuplicateNodeException - If another node belonging to the same project is already associated with the new Url.

registerFileNodeClass

public static void registerFileNodeClass(java.lang.String extension,
                                         java.lang.String description,
                                         java.lang.Class nodeClass,
                                         javax.swing.Icon icon)
Add a new node type to the registry of known types and their assocaited extensions.
Parameters:
type - The extension that this registration is associated with. Extensions are case-insensitive and do not include the leading period character.
description - A user-viewable description of the file type.
bufferClass - A subclass of Node that NodeSystem should instantiate to represent files with the appropriate extension.

findFileNodeClass

public static java.lang.Class findFileNodeClass(Url url)
Searches the node class registry to attempt to match a file extension with a node type assuming that backup files should be matched to the original file's node type.
Parameters:
url - The Url for which a suitable Node subclass should be found.
Returns:
A subclass of Node that should be used to manage the Url in question. If no node classes are registered for the Url's extension then the class com.borland.primetime.node.FileNode is returned.

findFileNodeClass

public static java.lang.Class findFileNodeClass(Url url,
                                                boolean includeBackups)
Searches the node class registry to attempt to match a file extension with a node type.
Parameters:
url - The Url for which a suitable Node subclass should be found.
includeBackups - True if VFS backup files should be matched to the original file's node type.
Returns:
A subclass of Node that should be used to manage the Url in question. If no node classes are registered for the Url's extension then the class com.borland.primetime.node.FileNode is returned.

findFileNodeClass

public static java.lang.Class findFileNodeClass(java.lang.String extension,
                                                boolean includeBackups)
Searches the node class registry to attempt to match a file extension with a node type.
Parameters:
extension - The extension for which a suitable Node subclass should be found.
includeBackups - True if VFS backup files should be matched to the original file's node type.
Returns:
A subclass of Node that should be used to manage the Url in question. If no node classes are registered for the Url's extension then the class com.borland.primetime.node.FileNode is returned.

getBuffer

public Buffer getBuffer()
                 throws java.io.IOException
Provide lazy buffer loading by requesting a Buffer instance using the VFS the first time it is required and then caching the result.
Returns:
The Buffer reference returned is guaranteed to be non-null.
Throws:
java.io.IOException - If the buffer cannot be loaded.

findBuffer

public Buffer findBuffer()

getTimestamp

public long getTimestamp()

getInputStream

public java.io.InputStream getInputStream()
                                   throws java.io.IOException
Create an input stream to read from the underlying Url. This will reflect the current state of the in-memory buffer, if one exists.

getOutputStream

public java.io.OutputStream getOutputStream()
                                     throws java.io.IOException,
                                            VFSException
Create an output stream to write to the underlying Url. This will modify the in-memory buffer, if one exists, but will also modify the file on disk when the stream is closed.

To modify the state of the in-memory buffer without immediately saving the results to disk use getBuffer().getOutputStream() instead.


isReadOnly

public boolean isReadOnly()

isNew

public boolean isNew()
BWS-
Overrides:
isNew in class UrlNode

isModified

public boolean isModified()
Description copied from class: Node
Describes the modified state of the node's underlying storage. Nodes that are not associated with any physical storage are always considered to be unmodified since they have no independant state to preserved, only properties which are saved as a part of the project node.
Overrides:
isModified in class UrlNode
Tags copied from class: Node
Returns:
Always false.

revert

public void revert()
            throws java.io.IOException
Overrides:
revert in class UrlNode

rename

public void rename(Url url)
            throws java.io.IOException,
                   InvalidUrlException,
                   DuplicateNodeException,
                   ReadOnlyException
rename cannot change the type of a FileNode.
Overrides:
rename in class UrlNode

saveAs

public void saveAs(Url url)
            throws java.io.IOException,
                   InvalidUrlException,
                   DuplicateNodeException
saveAs cannot change the type of a FileNode. saveAs will overwrite existing files.
Overrides:
saveAs in class UrlNode

save

public void save()
          throws java.io.IOException,
                 InvalidUrlException
Overrides:
save in class UrlNode

isPersistant

public boolean isPersistant()
Determines whether or not the node definition and its properties will be saved with in a project file. A FileNode whose Url belongs to the NewFilesystem is not persisted.
Overrides:
isPersistant in class Node
Returns:
True if the node should be saved, false otherwise.

getDisplayIcon

public javax.swing.Icon getDisplayIcon()
Description copied from class: Node
Provides an image to be used for graphical representation of the node.
Overrides:
getDisplayIcon in class Node
Tags copied from class: Node
Returns:
An Icon instance.

getDisplayName

public java.lang.String getDisplayName()
Uses the the FileNode's underlying Url to derive a display name.
Overrides:
getDisplayName in class Node
Returns:
The filename of the node's Url with the path component removed.

getLongDisplayName

public java.lang.String getLongDisplayName()
Use the Url's file component for display purposes except for the NewFilesystem where the full path is meaningless.
Overrides:
getLongDisplayName in class Node
Returns:
A full path suitable for end-user display.

getDisplaySequence

public int getDisplaySequence()
Description copied from class: Node
Describes the logical group the node belongs to for ordering purposes. Nodes are divided into groups, then sorted by name within a group of nodes sharing the same grouping value. The groups themselves are ordered by grouping value, with lower numbers appearing earlier. Arbitrary numbers have been chosen to sort nodes in JBuilder as follows: Projects = 100, Folders = 200, Packages = 300, the default = 400, FileNodes = 500, ClassFileNodes = 600.
Overrides:
getDisplaySequence in class Node
Tags copied from class: Node
Returns:
An integer value specifying a grouping value.

check

public void check()
Description copied from class: Node
Performs any periodic task required to keep the node's state up to date. For example, the check method is invoked every time a viewer displaying the node's contents is activated, giving the node a chance to check for changes to the physical storage it represents.
Overrides:
check in class Node