org.apache.jackrabbit.core.fs.local
Class LocalFileSystem

java.lang.Object
  extended byorg.apache.jackrabbit.core.fs.local.LocalFileSystem
All Implemented Interfaces:
FileSystem

public class LocalFileSystem
extends Object
implements FileSystem

A LocalFileSystem ...


Field Summary
 
Fields inherited from interface org.apache.jackrabbit.core.fs.FileSystem
SEPARATOR, SEPARATOR_CHAR
 
Constructor Summary
LocalFileSystem()
          Default constructor
 
Method Summary
 void close()
          Close the file system. After calling this method, the file system is no longer accessible.
 void copy(String srcPath, String destPath)
          Copies a file or folder to a new location.
 void createFolder(String folderPath)
          Creates the folder named by this path, including any necessary but nonexistent parent folders. Note that if this operation fails it may have succeeded in creating some of the necessary parent folders.
 void deleteFile(String filePath)
          Deletes the file denoted by this path.
 void deleteFolder(String folderPath)
          Deletes the folder denoted by this path. Any contents of this folder (folders and files) will be deleted recursively.
 boolean equals(Object obj)
           
 boolean exists(String path)
          Tests whether the file system entry denoted by this path exists.
 String getEnableHandleMonitor()
          Returns true if use of the handle monitor is currently enabled, otherwise returns false.
 InputStream getInputStream(String filePath)
          Returns an input stream of the contents of the file denoted by this path.
 OutputStream getOutputStream(String filePath)
          Returns an output stream for writing bytes to the file denoted by this path. The file will be created if it doesn't exist. If the file exists, its contents will be overwritten.
 String getPath()
           
 RandomAccessOutputStream getRandomAccessOutputStream(String filePath)
          Returns an output stream for writing bytes to the file denoted by this path. The file will be created if it doesn't exist. The current position of the file pointer is set to 0. See also RandomAccessOutputStream.seek(long);
 boolean hasChildren(String path)
          Tests whether the file system entry denoted by this path has child entries.
 int hashCode()
          Returns zero to satisfy the Object equals/hashCode contract.
 void init()
          Initialize the file system
 boolean isFile(String path)
          Tests whether the file system entry denoted by this path is a file.
 boolean isFolder(String path)
          Tests whether the file system entry denoted by this path is a folder.
 long lastModified(String path)
          Returns the time that the file system entry denoted by this path was last modified.
 long length(String filePath)
          Returns the length of the file denoted by this path.
 String[] list(String folderPath)
          Returns an array of strings naming the files and folders in the folder denoted by this path.
 String[] listFiles(String folderPath)
          Returns an array of strings naming the files in the folder denoted by this path.
 String[] listFolders(String folderPath)
          Returns an array of strings naming the folders in the folder denoted by this path.
 void move(String srcPath, String destPath)
          Moves a file or folder to a new location.
 void setEnableHandleMonitor(boolean enable)
          Enables/Disables the use of the handle monitor.
 void setEnableHandleMonitor(String enable)
          Enables/Disables the use of the handle monitor.
 void setPath(String rootPath)
          Sets the path to the root directory of this local filesystem.
 void setRoot(File root)
           
 void touch(String filePath)
          Set the modified time of an existing file to now.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LocalFileSystem

public LocalFileSystem()
Default constructor

Method Detail

getPath

public String getPath()

setPath

public void setPath(String rootPath)
Sets the path to the root directory of this local filesystem. please note that this method can be called via reflection during initialization and must not be altered.

Parameters:
rootPath - the path to the root directory

setRoot

public void setRoot(File root)

setEnableHandleMonitor

public void setEnableHandleMonitor(String enable)
Enables/Disables the use of the handle monitor.

Parameters:
enable -

setEnableHandleMonitor

public void setEnableHandleMonitor(boolean enable)
Enables/Disables the use of the handle monitor.

Parameters:
enable - flag

getEnableHandleMonitor

public String getEnableHandleMonitor()
Returns true if use of the handle monitor is currently enabled, otherwise returns false.

See Also:
setEnableHandleMonitor(boolean)

equals

public boolean equals(Object obj)

hashCode

public int hashCode()
Returns zero to satisfy the Object equals/hashCode contract. This class is mutable and not meant to be used as a hash key.

Returns:
always zero
See Also:
Object.hashCode()

init

public void init()
          throws FileSystemException
Initialize the file system

Specified by:
init in interface FileSystem
Throws:
FileSystemException - if the file system initialization fails

close

public void close()
           throws FileSystemException
Close the file system. After calling this method, the file system is no longer accessible.

Specified by:
close in interface FileSystem
Throws:
FileSystemException

copy

public void copy(String srcPath,
                 String destPath)
          throws FileSystemException
Copies a file or folder to a new location.

Specified by:
copy in interface FileSystem
Parameters:
srcPath - the path of the file or folder to be copied.
destPath - the destination path to which the file or folder is to be copied.
Throws:
FileSystemException - if the copy fails

createFolder

public void createFolder(String folderPath)
                  throws FileSystemException
Creates the folder named by this path, including any necessary but nonexistent parent folders. Note that if this operation fails it may have succeeded in creating some of the necessary parent folders.

Specified by:
createFolder in interface FileSystem
Parameters:
folderPath - the path of the folder to be created.
Throws:
FileSystemException - if a file system entry denoted by path already exists or if another error occurs.

deleteFile

public void deleteFile(String filePath)
                throws FileSystemException
Deletes the file denoted by this path.

Specified by:
deleteFile in interface FileSystem
Parameters:
filePath - the path of the file to be deleted.
Throws:
FileSystemException - if this path does not denote a file or if another error occurs.

deleteFolder

public void deleteFolder(String folderPath)
                  throws FileSystemException
Deletes the folder denoted by this path. Any contents of this folder (folders and files) will be deleted recursively.

Specified by:
deleteFolder in interface FileSystem
Parameters:
folderPath - the path of the folder to be deleted.
Throws:
FileSystemException - if this path does not denote a folder or if another error occurs.

exists

public boolean exists(String path)
               throws FileSystemException
Tests whether the file system entry denoted by this path exists.

Specified by:
exists in interface FileSystem
Parameters:
path - the path of a file system entry.
Returns:
true if the file system entry at path is a file; false otherwise.
Throws:
FileSystemException

getInputStream

public InputStream getInputStream(String filePath)
                           throws FileSystemException
Returns an input stream of the contents of the file denoted by this path.

Specified by:
getInputStream in interface FileSystem
Parameters:
filePath - the path of the file.
Returns:
an input stream of the contents of the file.
Throws:
FileSystemException - if the file does not exist or if it cannot be read from

getOutputStream

public OutputStream getOutputStream(String filePath)
                             throws FileSystemException
Returns an output stream for writing bytes to the file denoted by this path. The file will be created if it doesn't exist. If the file exists, its contents will be overwritten.

Specified by:
getOutputStream in interface FileSystem
Parameters:
filePath - the path of the file.
Returns:
an output stream for writing bytes to the file.
Throws:
FileSystemException - if the file cannot be written to or created

getRandomAccessOutputStream

public RandomAccessOutputStream getRandomAccessOutputStream(String filePath)
                                                     throws FileSystemException
Returns an output stream for writing bytes to the file denoted by this path. The file will be created if it doesn't exist. The current position of the file pointer is set to 0. See also RandomAccessOutputStream.seek(long);

Specified by:
getRandomAccessOutputStream in interface FileSystem
Parameters:
filePath - the path of the file.
Returns:
an random access output stream for writing bytes to the file.
Throws:
FileSystemException - if the file could not be created or if the output stream cannot be obtained.

hasChildren

public boolean hasChildren(String path)
                    throws FileSystemException
Tests whether the file system entry denoted by this path has child entries.

Specified by:
hasChildren in interface FileSystem
Parameters:
path - the path of a file system entry.
Returns:
true if the file system entry at path has child entries; false otherwise.
Throws:
FileSystemException

isFile

public boolean isFile(String path)
               throws FileSystemException
Tests whether the file system entry denoted by this path is a file.

Specified by:
isFile in interface FileSystem
Parameters:
path - the path of a file system entry.
Returns:
true if the file system entry at path is a file; false otherwise.
Throws:
FileSystemException

isFolder

public boolean isFolder(String path)
                 throws FileSystemException
Tests whether the file system entry denoted by this path is a folder.

Specified by:
isFolder in interface FileSystem
Parameters:
path - the path of a file system entry.
Returns:
true if the file system entry at path is a folder; false otherwise.
Throws:
FileSystemException

lastModified

public long lastModified(String path)
                  throws FileSystemException
Returns the time that the file system entry denoted by this path was last modified.

Specified by:
lastModified in interface FileSystem
Parameters:
path - the path of a file system entry.
Returns:
A long value representing the time the file system entry was last modified, measured in milliseconds since the epoch (00:00:00 GMT, January 1, 1970), or 0L if the modification time can't be determined.
Throws:
FileSystemException - if the file system entry does not exist.

length

public long length(String filePath)
            throws FileSystemException
Returns the length of the file denoted by this path.

Specified by:
length in interface FileSystem
Parameters:
filePath - the path of the file.
Returns:
The length, in bytes, of the file denoted by this path, or -1L if the length can't be determined.
Throws:
FileSystemException - if the path does not denote an existing file.

touch

public void touch(String filePath)
           throws FileSystemException
Set the modified time of an existing file to now.

Specified by:
touch in interface FileSystem
Parameters:
filePath - the path of the file.
Throws:
FileSystemException - if the path does not denote an existing file.

list

public String[] list(String folderPath)
              throws FileSystemException
Returns an array of strings naming the files and folders in the folder denoted by this path.

Specified by:
list in interface FileSystem
Parameters:
folderPath - the path of the folder whose contents is to be listed.
Returns:
an array of strings naming the files and folders in the folder denoted by this path.
Throws:
FileSystemException - if this path does not denote a folder or if another error occurs.

listFiles

public String[] listFiles(String folderPath)
                   throws FileSystemException
Returns an array of strings naming the files in the folder denoted by this path.

Specified by:
listFiles in interface FileSystem
Parameters:
folderPath - the path of the folder whose contents is to be listed.
Returns:
an array of strings naming the files in the folder denoted by this path.
Throws:
FileSystemException - if this path does not denote a folder or if another error occurs.

listFolders

public String[] listFolders(String folderPath)
                     throws FileSystemException
Returns an array of strings naming the folders in the folder denoted by this path.

Specified by:
listFolders in interface FileSystem
Parameters:
folderPath - the path of the folder whose contents is to be listed.
Returns:
an array of strings naming the folders in the folder denoted by this path.
Throws:
FileSystemException - if this path does not denote a folder or if another error occurs.

move

public void move(String srcPath,
                 String destPath)
          throws FileSystemException
Moves a file or folder to a new location.

Specified by:
move in interface FileSystem
Parameters:
srcPath - the path of the file or folder to be moved.
destPath - the destination path to which the file or folder is to be moved.
Throws:
FileSystemException - if the move fails


Copyright © 2004-2006 The Apache Software Foundation. All Rights Reserved.