org.openide.filesystems
Class LocalFileSystem

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

public class LocalFileSystem
extends AbstractFileSystem

Local file system. Provides access to files on local disk.

See Also:
Serialized Form

Inner Class Summary
static class LocalFileSystem.Impl
          The implementation class that implements List, Info and Change interfaces and delegates all the methods to appropriate methods of LocalFileSystem.
 
Inner classes inherited from class org.openide.filesystems.AbstractFileSystem
AbstractFileSystem.Attr, AbstractFileSystem.Change, AbstractFileSystem.Info, AbstractFileSystem.List, AbstractFileSystem.Transfer
 
Inner classes inherited from class org.openide.filesystems.FileSystem
FileSystem.AtomicAction, FileSystem.Environment, FileSystem.Status
 
Fields inherited from class org.openide.filesystems.AbstractFileSystem
attr, change, info, list, transfer
 
Fields inherited from class org.openide.filesystems.FileSystem
PROP_HIDDEN, PROP_READ_ONLY, PROP_ROOT, PROP_SYSTEM_NAME, PROP_VALID
 
Constructor Summary
LocalFileSystem()
          Constructor.
LocalFileSystem(FileSystemCapability cap)
          Constructor.
 
Method Summary
protected  String[] children(String name)
          Scans children for given name
protected  String computeSystemName(File rootFile)
          Compute the system name of this file system for a given root directory.
protected  void createData(String name)
          Create new data file.
protected  void createFolder(String name)
          Creates new folder named name.
protected  void delete(String name)
          Delete the file.
protected  boolean folder(String name)
          Test if the file is folder or contains data.
 String getDisplayName()
          Provides a name for the system that can be presented to the user.
 File getRootDirectory()
          Get the root directory of the file system.
protected  InputStream inputStream(String name)
          Get input stream.
 boolean isReadOnly()
          Test if the filesystem is read-only or not.
protected  Date lastModified(String name)
          Get last modification time.
protected  void lock(String name)
          Does nothing to lock the file.
protected  void markUnimportant(String name)
          Does nothing to mark the file as unimportant.
protected  String mimeType(String name)
          Get the MIME type of the file.
protected  OutputStream outputStream(String name)
          Get output stream.
 void prepareEnvironment(FileSystem.Environment environment)
          Prepare environment by adding the root directory of the file system to the class path.
protected  boolean readOnly(String name)
          Test whether this file can be written to or not.
protected  void rename(String oldName, String newName)
          Renames a file.
 void setReadOnly(boolean flag)
          Set whether the file system should be read only.
 void setRootDirectory(File r)
          Set the root directory of the file system.
protected  long size(String name)
          Get the size of the file.
protected  void unlock(String name)
          Does nothing to unlock the file.
 
Methods inherited from class org.openide.filesystems.AbstractFileSystem
createReference, existingFileObjects, find, findReference, findResource, getActions, getRefreshTime, getRoot, refreshResource, refreshRoot, setRefreshTime
 
Methods inherited from class org.openide.filesystems.FileSystem
addFileStatusListener, addNotify, addPropertyChangeListener, addVetoableChangeListener, fireFileStatusChanged, firePropertyChange, fireVetoableChange, getActions, getCapability, getStatus, getSystemName, isDefault, isHidden, isPersistent, isValid, removeFileStatusListener, removeNotify, 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

LocalFileSystem

public LocalFileSystem()
Constructor.

LocalFileSystem

public LocalFileSystem(FileSystemCapability cap)
Constructor. Allows user to provide own capabilities for this file system.
Parameters:
cap - capabilities for this file system
Method Detail

getDisplayName

public String getDisplayName()
Description copied from class: FileSystem
Provides a name for the system that can be presented to the user.
Overrides:
getDisplayName in class AbstractFileSystem
Following copied from class: org.openide.filesystems.FileSystem
Returns:
user presentable name of the file system

setRootDirectory

public void setRootDirectory(File r)
                      throws PropertyVetoException,
                             IOException
Set the root directory of the file system.
Parameters:
r - file to set root to
Throws:
PropertyVetoException - if the value if vetoed by someone else (usually by the Repository)
IOException - if the root does not exists or some other error occured

getRootDirectory

public File getRootDirectory()
Get the root directory of the file system.
Returns:
root directory

setReadOnly

public void setReadOnly(boolean flag)
Set whether the file system should be read only.
Parameters:
flag - true if it should

isReadOnly

public boolean isReadOnly()
Description copied from class: FileSystem
Test if the filesystem is read-only or not.
Overrides:
isReadOnly in class FileSystem
Following copied from class: org.openide.filesystems.FileSystem
Returns:
true if the system is read-only

prepareEnvironment

public void prepareEnvironment(FileSystem.Environment environment)
Prepare environment by adding the root directory of the file system to the class path.
Overrides:
prepareEnvironment in class FileSystem
Parameters:
environment - the environment to add to

computeSystemName

protected String computeSystemName(File rootFile)
Compute the system name of this file system for a given root directory.

The default implementation simply returns the filename separated by slashes.

Parameters:
rootFile - root directory for the filesystem
Returns:
system name for the filesystem
See Also:
FileSystem.setSystemName(java.lang.String)

children

protected String[] children(String name)
Scans children for given name

createFolder

protected void createFolder(String name)
                     throws IOException
Creates new folder named name.
Parameters:
name - name of folder
Throws:
IOException - if operation fails

createData

protected void createData(String name)
                   throws IOException
Create new data file.
Parameters:
name - name of the file
Returns:
the new data file object
Throws:
IOException - if the file cannot be created (e.g. already exists)

rename

protected void rename(String oldName,
                      String newName)
               throws IOException
Renames a file.
Parameters:
oldName - old name of the file
newName - new name of the file

delete

protected void delete(String name)
               throws IOException
Delete the file.
Parameters:
name - name of file
Throws:
IOException - if the file could not be deleted

lastModified

protected Date lastModified(String name)
Get last modification time.
Parameters:
name - the file to test
Returns:
the date

folder

protected boolean folder(String name)
Test if the file is folder or contains data.
Parameters:
name - name of the file
Returns:
true if the file is folder, false otherwise

readOnly

protected boolean readOnly(String name)
Test whether this file can be written to or not.
Parameters:
name - the file to test
Returns:
true if file is read-only

mimeType

protected String mimeType(String name)
Get the MIME type of the file. If filesystem has no special support for MIME types then can simply return null. FileSystem can register MIME types for a well-known extensions: FileUtil.setMIMEType(String ext, String mimeType) or together with filesystem supply some resolvers subclassed from MIMEResolver.
Parameters:
name - the file to test
Returns:
the MIME type textual representation (e.g. "text/plain") or null if no special support for recognizing MIME is implemented.

size

protected long size(String name)
Get the size of the file.
Parameters:
name - the file to test
Returns:
the size of the file in bytes or zero if the file does not contain data (does not exist or is a folder).

inputStream

protected InputStream inputStream(String name)
                           throws FileNotFoundException
Get input stream.
Parameters:
name - the file to test
Returns:
an input stream to read the contents of this file
Throws:
FileNotFoundException - if the file does not exists or is invalid

outputStream

protected OutputStream outputStream(String name)
                             throws IOException
Get output stream.
Parameters:
name - the file to test
Returns:
output stream to overwrite the contents of this file
Throws:
IOException - if an error occures (the file is invalid, etc.)

lock

protected void lock(String name)
             throws IOException
Does nothing to lock the file.
Parameters:
name - name of the file

unlock

protected void unlock(String name)
Does nothing to unlock the file.
Parameters:
name - name of the file

markUnimportant

protected void markUnimportant(String name)
Does nothing to mark the file as unimportant.
Parameters:
name - the file to mark


Built on February 22 2001.  |  Portions Copyright 1997-2000 Sun Microsystems, Inc. All rights reserved.