org.openide.filesystems
Class MultiFileSystem

java.lang.Object
  |
  +--org.openide.filesystems.FileSystem
        |
        +--org.openide.filesystems.MultiFileSystem
All Implemented Interfaces:
Serializable

public class MultiFileSystem
extends FileSystem

The base for all filesystems that are build above a top of other ones. This system expects at most one filesystem it should write to and any number of filesystems to read from. If there is more versions of one file than the one from writable file system is prefered or the read only systems are scanned in the given order.

See Also:
Serialized Form

Inner classes inherited from class org.openide.filesystems.FileSystem
FileSystem.AtomicAction, FileSystem.Environment, FileSystem.Status
 
Fields inherited from class org.openide.filesystems.FileSystem
PROP_HIDDEN, PROP_READ_ONLY, PROP_ROOT, PROP_SYSTEM_NAME, PROP_VALID
 
Constructor Summary
protected MultiFileSystem()
          Creates new empty MultiFileSystem.
  MultiFileSystem(FileSystem[] fileSystems)
          Creates new MultiFileSystem.
 
Method Summary
 void addNotify()
          Notifies all encapsulated file systems in advance to superclass behaviour.
protected  Set createLocksOn(String name)
          When a file is about to be locked this method is consulted to choose which delegates should be locked.
protected  FileSystem createWritableOn(String name)
          Finds the system to create writable version of the file on.
protected  FileSystem createWritableOnForRename(String oldName, String newName)
          Special case of createWritableOn (@see #createWritableOn).
 FileObject find(String aPackage, String name, String ext)
          Finds file in the filesystem by name.
 FileObject findResource(String name)
          Finds file when its resource name is given.
protected  FileObject findResourceOn(FileSystem fs, String res)
          Finds a resource on given file system.
protected  FileSystem findSystem(FileObject fo)
          For given file object finds the file system that the object is placed on.
 SystemAction[] getActions()
          Merge actions from all delegates.
 SystemAction[] getActions(Set foSet)
           
protected  FileSystem[] getDelegates()
          All filesystem that this system delegates to.
 String getDisplayName()
          The name of the file system.
 boolean getPropagateMasks()
          Will mask files that are not used be listed as children?
 FileObject getRoot()
          Root of the file system.
protected static Enumeration hiddenFiles(FileObject folder, boolean rec)
          Finds all hidden files on given file system.
protected  void hideResource(String res, boolean hide)
          Marks a resource as hidden.
 boolean isReadOnly()
          This file system is readonly if it has not writable system.
protected  void markUnimportant(FileObject fo)
          Notification that a file has been marked unimportant.
protected  void notifyMigration(FileObject fo)
          Notification that a file has migrated from one file system to another.
 void prepareEnvironment(FileSystem.Environment env)
          Lets any sub file systems prepare the environment.
 void removeNotify()
          Notifies all encapsulated file systems in advance to superclass behaviour.
protected  void setDelegates(FileSystem[] fileSystems)
          Changes the filesystems that this system delegates to
protected  void setPropagateMasks(boolean pm)
          Set whether unused mask files should be listed as children.
 
Methods inherited from class org.openide.filesystems.FileSystem
addFileStatusListener, addPropertyChangeListener, addVetoableChangeListener, fireFileStatusChanged, firePropertyChange, fireVetoableChange, getCapability, getStatus, getSystemName, isDefault, isHidden, isPersistent, isValid, removeFileStatusListener, removePropertyChangeListener, removeVetoableChangeListener, runAtomicAction, setCapability, setHidden, setSystemName, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MultiFileSystem

protected MultiFileSystem()
Creates new empty MultiFileSystem. Useful only for subclasses.

MultiFileSystem

public MultiFileSystem(FileSystem[] fileSystems)
Creates new MultiFileSystem.
Parameters:
array - of file systems (can contain nulls)
Method Detail

setDelegates

protected final void setDelegates(FileSystem[] fileSystems)
Changes the filesystems that this system delegates to
Parameters:
arr - array of filesystems

getDelegates

protected final FileSystem[] getDelegates()
All filesystem that this system delegates to.
Returns:
the array of delegates

getPropagateMasks

public final boolean getPropagateMasks()
Will mask files that are not used be listed as children?
Returns:
true if so

setPropagateMasks

protected final void setPropagateMasks(boolean pm)
Set whether unused mask files should be listed as children.
Parameters:
pm - true if so

isReadOnly

public boolean isReadOnly()
This file system is readonly if it has not writable system.
Overrides:
isReadOnly in class FileSystem
Following copied from class: org.openide.filesystems.FileSystem
Returns:
true if the system is read-only

getDisplayName

public String getDisplayName()
The name of the file system.
Overrides:
getDisplayName in class FileSystem
Following copied from class: org.openide.filesystems.FileSystem
Returns:
user presentable name of the file system

getRoot

public FileObject getRoot()
Root of the file system.
Overrides:
getRoot in class FileSystem
Following copied from class: org.openide.filesystems.FileSystem
Returns:
root folder of whole filesystem

getActions

public SystemAction[] getActions()
Merge actions from all delegates.
Overrides:
getActions in class FileSystem
Following copied from class: org.openide.filesystems.FileSystem
Returns:
array of available actions

getActions

public SystemAction[] getActions(Set foSet)
Overrides:
getActions in class FileSystem

find

public FileObject find(String aPackage,
                       String name,
                       String ext)
Description copied from class: FileSystem
Finds file in the filesystem by name.

The default implementation converts dots in the package name into slashes, concatenates the strings, adds any extension prefixed by a dot and calls the findResource method.

Note: when both of name and ext are null then name and extension should be ignored and scan should look only for a package.

Overrides:
find in class FileSystem
Following copied from class: org.openide.filesystems.FileSystem
Parameters:
aPackage - package name where each package component is separated by a dot
name - name of the file (without dots) or null if one wants to obtain a folder (package) and not a file in it
ext - extension of the file (without leading dot) or null if one needs a package and not a file
Returns:
a file object that represents a file with the given name or null if the file does not exist

findResource

public FileObject findResource(String name)
Description copied from class: FileSystem
Finds file when its resource name is given. The name has the usual format for the ClassLoader.getResource(String) method. So it may consist of "package1/package2/filename.ext". If there is no package, it may consist only of "filename.ext".
Overrides:
findResource in class FileSystem
Following copied from class: org.openide.filesystems.FileSystem
Parameters:
name - resource name
Returns:
FileObject that represents file with given name or null if the file does not exist

findSystem

protected final FileSystem findSystem(FileObject fo)
                               throws IllegalArgumentException
For given file object finds the file system that the object is placed on. The object must be created by this file system orherwise IllegalArgumentException is thrown.
Parameters:
fo - file object
Returns:
the file system (from the list we delegate to) the object has file on
Throws:
IllegalArgumentException - if the file object is not represented in this file system

hideResource

protected final void hideResource(String res,
                                  boolean hide)
                           throws IOException
Marks a resource as hidden. It will not be listed in the list of files. Uses createMaskOn method to determine on which file system to mark the file.
Parameters:
res - resource name of file to hide or show
hide - true if we should hide the file/false otherwise
Throws:
IOException - if it is not possible

hiddenFiles

protected static Enumeration hiddenFiles(FileObject folder,
                                         boolean rec)
Finds all hidden files on given file system. The methods scans all files for ones with hidden extension and returns enumeration of names of files that are hidden.
Parameters:
folder - folder to start at
rec - proceed recursivelly
Returns:
enumeration of String with names of hidden files

findResourceOn

protected FileObject findResourceOn(FileSystem fs,
                                    String res)
Finds a resource on given file system. The default implementation simply uses FileSystem.findResource, but subclasses may override this method to hide/show some resources.
Parameters:
fs - the filesystem to scan on
res - the resource name to look for
Returns:
the file object or null

createWritableOn

protected FileSystem createWritableOn(String name)
                               throws IOException
Finds the system to create writable version of the file on.
Parameters:
name - name of the file (full)
Returns:
the first one
Throws:
IOException - if the file system is readonly

createWritableOnForRename

protected FileSystem createWritableOnForRename(String oldName,
                                               String newName)
                                        throws IOException
Special case of createWritableOn (@see #createWritableOn).
Parameters:
oldName - original name of the file (full)
newName - name new of the file (full)
Returns:
the first one
Throws:
IOException - if the file system is readonly
Since:
1.34

createLocksOn

protected Set createLocksOn(String name)
                     throws IOException
When a file is about to be locked this method is consulted to choose which delegates should be locked. By default this method returns only one filesystem; the same returned by createWritableOn.

If an delegate resides on a filesystem returned in the resulting set, it will be locked. All others will remain unlocked.

Parameters:
name - the resource name to lock
Returns:
set of filesystems
Throws:
IOException - if the resource cannot be locked

notifyMigration

protected void notifyMigration(FileObject fo)
Notification that a file has migrated from one file system to another. Usually when somebody writes to file on readonly file system and the file has to be copied to write one.

This method allows subclasses to fire for example FileSystem.PROP_STATUS change to notify that annotation of this file should change.

Parameters:
fo - file object that change its actual file system

markUnimportant

protected void markUnimportant(FileObject fo)
Notification that a file has been marked unimportant.
Parameters:
fo - file object that change its actual file system

prepareEnvironment

public void prepareEnvironment(FileSystem.Environment env)
                        throws EnvironmentNotSupportedException
Lets any sub file systems prepare the environment. If they do not support it, it does not care.
Overrides:
prepareEnvironment in class FileSystem
Following copied from class: org.openide.filesystems.FileSystem
Parameters:
env - the environment to setup
Throws:
EnvironmentNotSupportedException - if external execution and compilation cannot be supported

addNotify

public void addNotify()
Notifies all encapsulated file systems in advance to superclass behaviour.
Overrides:
addNotify in class FileSystem

removeNotify

public void removeNotify()
Notifies all encapsulated file systems in advance to superclass behaviour.
Overrides:
removeNotify in class FileSystem


Built on December 12 2001.  |  Portions Copyright 1997-2001 Sun Microsystems, Inc. All rights reserved.