Package org.apache.jackrabbit.core.fs
Class FileSystemResource
- java.lang.Object
-
- org.apache.jackrabbit.core.fs.FileSystemResource
-
public class FileSystemResource extends Object
AFileSystemResource
represents a resource (i.e. file) in aFileSystem
.
-
-
Field Summary
Fields Modifier and Type Field Description protected FileSystem
fs
protected String
path
-
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 void
delete()
Deletes this resource.void
delete(boolean pruneEmptyParentDirs)
Deletes this resource.boolean
equals(Object obj)
boolean
exists()
FileSystem
getFileSystem()
Returns theFileSystem
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.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
spool(OutputStream out)
Spools this resource to the given output stream.String
toString()
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
- theFileSystem
where the resource is locatedpath
- the path of the resource in theFileSystem
-
-
Method Detail
-
getFileSystem
public FileSystem getFileSystem()
Returns theFileSystem
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 asdelete(boolean)
called withfalse
.- Throws:
FileSystemException
- See Also:
FileSystem.deleteFile(java.lang.String)
-
delete
public void delete(boolean pruneEmptyParentDirs) throws FileSystemException
Deletes 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 the
method.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:
hashCode
in classObject
- Returns:
- always zero
- See Also:
Object.hashCode()
-
-