org.apache.jackrabbit.core.fs
Class FileSystemResource

java.lang.Object
  extended byorg.apache.jackrabbit.core.fs.FileSystemResource

public class FileSystemResource
extends Object

A FileSystemResource represents a resource (i.e. file) in a FileSystem.


Field Summary
protected  FileSystem fs
           
protected  String path
           
 
Constructor Summary
FileSystemResource(FileSystem fs, String path)
          Creates a new FileSystemResource
 
Method Summary
 void delete()
          Deletes this resource.
 void delete(boolean pruneEmptyParentDirs)
          Deletes this resource.
 boolean equals(Object obj)
           
 boolean exists()
           
 FileSystem getFileSystem()
          Returns the FileSystem where this resource is located.
 InputStream getInputStream()
           
 String getName()
          Returns the name of this resource.
 OutputStream getOutputStream()
           
 String getParentDir()
          Returns the parent directory of this resource.
 String getPath()
          Returns the path of this resource.
 RandomAccessOutputStream getRandomAccessOutputStream()
           
 int hashCode()
          Returns zero to satisfy the Object equals/hashCode contract.
 long lastModified()
           
 long length()
           
 void makeParentDirs()
          Creates the parent directory of this resource, including any necessary but nonexistent parent directories.
 void move(String destPath)
           
 void spool(OutputStream out)
          Spools this resource to the given output stream.
 String toString()
          Returns the path string of this resource.
 void touch()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

fs

protected final FileSystem fs

path

protected final String path
Constructor Detail

FileSystemResource

public FileSystemResource(FileSystem fs,
                          String path)
Creates a new FileSystemResource

Parameters:
fs - the FileSystem where the resource is located
path - the path of the resource in the FileSystem
Method Detail

getFileSystem

public FileSystem getFileSystem()
Returns the FileSystem where this resource is located.

Returns:
the FileSystem where this resource is located.

getPath

public String getPath()
Returns the path of this resource.

Returns:
the path of this resource.

getParentDir

public String getParentDir()
Returns the parent directory of this resource.

Returns:
the parent directory.

getName

public String getName()
Returns the name of this resource.

Returns:
the name.

makeParentDirs

public void makeParentDirs()
                    throws FileSystemException
Creates the parent directory of this resource, including any necessary but nonexistent parent directories.

Throws:
FileSystemException

delete

public void delete()
            throws FileSystemException
Deletes this resource. Same as #delete(false).

Throws:
FileSystemException
See Also:
FileSystem.deleteFile(java.lang.String)

delete

public void delete(boolean pruneEmptyParentDirs)
            throws FileSystemException
Deletes this resource.

Parameters:
pruneEmptyParentDirs - if true, empty parent folders will automatically be deleted
Throws:
FileSystemException
See Also:
FileSystem.deleteFile(java.lang.String)

exists

public boolean exists()
               throws FileSystemException
Throws:
FileSystemException
See Also:
FileSystem.exists(java.lang.String)

getInputStream

public InputStream getInputStream()
                           throws FileSystemException
Throws:
FileSystemException
See Also:
FileSystem.getInputStream(java.lang.String)

spool

public void spool(OutputStream out)
           throws FileSystemException,
                  IOException
Spools this resource to the given output stream.

Parameters:
out - output stream where to spool the resource
Throws:
FileSystemException - if the input stream for this resource could not be obtained
IOException - if an error occurs while while spooling
See Also:
FileSystem.getInputStream(java.lang.String)

getOutputStream

public OutputStream getOutputStream()
                             throws FileSystemException
Throws:
FileSystemException
See Also:
FileSystem.getOutputStream(java.lang.String)

getRandomAccessOutputStream

public RandomAccessOutputStream getRandomAccessOutputStream()
                                                     throws FileSystemException
Throws:
FileSystemException
See Also:
FileSystem.getRandomAccessOutputStream(java.lang.String)

lastModified

public long lastModified()
                  throws FileSystemException
Throws:
FileSystemException
See Also:
FileSystem.lastModified(java.lang.String)

length

public long length()
            throws FileSystemException
Throws:
FileSystemException
See Also:
FileSystem.length(java.lang.String)

touch

public void touch()
           throws FileSystemException
Throws:
FileSystemException
See Also:
FileSystem.touch(java.lang.String)

move

public void move(String destPath)
          throws FileSystemException
Throws:
FileSystemException
See Also:
FileSystem.move(java.lang.String, java.lang.String)

toString

public String toString()
Returns the path string of this resource. This is just the string returned by the getPath() method.

Returns:
The path string of this resource

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()


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