Package org.apache.jackrabbit.core.fs
Class FileSystemResource
- java.lang.Object
-
- org.apache.jackrabbit.core.fs.FileSystemResource
-
public class FileSystemResource extends Object
AFileSystemResourcerepresents a resource (i.e. file) in aFileSystem.
-
-
Field Summary
Fields Modifier and Type Field Description protected FileSystemfsprotected Stringpath
-
Constructor Summary
Constructors Constructor Description FileSystemResource(FileSystem fs, String path)Creates a newFileSystemResource
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddelete()Deletes this resource.voiddelete(boolean pruneEmptyParentDirs)Deletes this resource.booleanequals(Object obj)booleanexists()FileSystemgetFileSystem()Returns theFileSystemwhere this resource is located.InputStreamgetInputStream()StringgetName()Returns the name of this resource.OutputStreamgetOutputStream()StringgetParentDir()Returns the parent directory of this resource.StringgetPath()Returns the path of this resource.inthashCode()Returns zero to satisfy the Object equals/hashCode contract.longlastModified()longlength()voidmakeParentDirs()Creates the parent directory of this resource, including any necessary but nonexistent parent directories.voidspool(OutputStream out)Spools this resource to the given output stream.StringtoString()Returns the path string of this resource.
-
-
-
Field Detail
-
fs
protected final FileSystem fs
-
path
protected final String path
-
-
Constructor Detail
-
FileSystemResource
public FileSystemResource(FileSystem fs, String path)
Creates a newFileSystemResource- Parameters:
fs- theFileSystemwhere the resource is locatedpath- the path of the resource in theFileSystem
-
-
Method Detail
-
getFileSystem
public FileSystem getFileSystem()
Returns theFileSystemwhere this resource is located.- Returns:
- the
FileSystemwhere 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 FileSystemExceptionCreates the parent directory of this resource, including any necessary but nonexistent parent directories.- Throws:
FileSystemException
-
delete
public void delete() throws FileSystemExceptionDeletes this resource. Same asdelete(boolean)called withfalse.- Throws:
FileSystemException- See Also:
FileSystem.deleteFile(java.lang.String)
-
delete
public void delete(boolean pruneEmptyParentDirs) throws FileSystemExceptionDeletes this resource.- Parameters:
pruneEmptyParentDirs- iftrue, 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 obtainedIOException- 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)
-
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)
-
toString
public String toString()
Returns the path string of this resource. This is just the string returned by themethod.getPath()
-
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.- Overrides:
hashCodein classObject- Returns:
- always zero
- See Also:
Object.hashCode()
-
-