|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.myJava.file.driver.AbstractFileSystemDriver
com.myJava.file.driver.AbstractLinkableFileSystemDriver
com.myJava.file.driver.hash.HashFileSystemDriver
public class HashFileSystemDriver
Paths length cannot exceed 256 characters under Windows.
This due to a limitation of Sun's VM implementation for Windows and a limitation of the windows platform itself.
This Driver computes a hashCode for each component of the files paths, and uses it as physical name.
The advantage of using these hashCodes is that they are smaller than the original name. This original name is stored in a "companion" file
and can thus be retrieved by simply reading the content of this companion file.
This class is particularly useful for EncryptedFileSystemDrivers which may create encrypted paths of greater
length than the original path.
Nested Class Summary | |
---|---|
protected static class |
HashFileSystemDriver.FileFilterAdapter
|
protected static class |
HashFileSystemDriver.FilenameFilterAdapter
|
Field Summary | |
---|---|
protected HashCache |
cache
|
protected java.io.File |
directoryRoot
|
Fields inherited from class com.myJava.file.driver.AbstractLinkableFileSystemDriver |
---|
predecessor |
Fields inherited from class com.myJava.file.driver.AbstractFileSystemDriver |
---|
CHECK_PATH |
Fields inherited from interface com.myJava.file.driver.FileSystemDriver |
---|
ACCESS_EFFICIENCY_AVERAGE, ACCESS_EFFICIENCY_GOOD, ACCESS_EFFICIENCY_POOR |
Constructor Summary | |
---|---|
HashFileSystemDriver(java.io.File directoryRoot)
Constructor |
Method Summary | |
---|---|
void |
applyMetaData(FileMetaData p,
java.io.File f)
Applies the attributes provided as argument |
boolean |
canRead(java.io.File file)
|
boolean |
canWrite(java.io.File file)
|
protected void |
createDecodingFile(java.io.File encoded,
java.lang.String decodedName)
Creates the companion file, which stores the real name of the file/directory. |
boolean |
createNewFile(java.io.File file)
|
protected java.io.File |
decodeFileName(java.io.File file)
Reads the companion file to decode the hashed name |
protected java.lang.String |
decodeFileName(java.io.File parent,
java.lang.String shortName)
Reads the companion file to decode the hashed name |
boolean |
delete(java.io.File file)
|
void |
deleteOnExit(java.io.File f)
|
boolean |
directFileAccessSupported()
No direct file access is supported ! |
protected java.io.File |
encodeFileName(java.io.File file)
Hash the fileName |
protected java.lang.String |
encodeFileName(java.io.File encodedParent,
java.lang.String shortName)
Hash the fileName : - 2 first chars of the original name - length (hexadecimal) of the original name - Java hashCode (see String class) of the original name |
boolean |
equals(java.lang.Object o)
|
boolean |
exists(java.io.File file)
|
java.io.InputStream |
getCachedFileInputStream(java.io.File file)
Ensures that a local copy of the file exists and return an InputStream on this file |
java.io.OutputStream |
getCachedFileOutputStream(java.io.File file)
Returns an OutputStream for the given File This outputStream will be cached, and written only during call to "flush" |
protected java.io.File |
getDecodingFile(java.io.File file)
Computes the companion file's name. |
java.io.File |
getDirectoryRoot()
Return the root of the Driver |
java.io.InputStream |
getFileInputStream(java.io.File file)
|
java.io.OutputStream |
getFileOutputStream(java.io.File file)
|
java.io.OutputStream |
getFileOutputStream(java.io.File file,
boolean append)
|
java.io.OutputStream |
getFileOutputStream(java.io.File file,
boolean append,
OutputStreamListener listener)
|
FileCacheableInformations |
getInformations(java.io.File file)
Returns a global set of file informations (length, lastmodified, ...) |
FileMetaData |
getMetaData(java.io.File f,
boolean onlyBasicAttributes)
Returns the file's attributes |
int |
hashCode()
|
boolean |
isContentSensitive()
Returns true if the driver is sensitive to the content. |
protected boolean |
isDecodingFile(java.io.File f)
Checks wether the file is a "companion" file (which must be ignored by file listing methods) |
protected boolean |
isDecodingFile(java.lang.String f)
Checks wether the file is a "companion" file (which must be ignored by file listing methods) |
boolean |
isDirectory(java.io.File file)
|
boolean |
isFile(java.io.File file)
|
boolean |
isHidden(java.io.File file)
|
long |
lastModified(java.io.File file)
|
long |
length(java.io.File file)
|
java.lang.String[] |
list(java.io.File file)
|
java.lang.String[] |
list(java.io.File file,
java.io.FilenameFilter filter)
|
java.io.File[] |
listFiles(java.io.File file)
|
java.io.File[] |
listFiles(java.io.File file,
java.io.FileFilter filter)
|
java.io.File[] |
listFiles(java.io.File file,
java.io.FilenameFilter filter)
|
boolean |
mkdir(java.io.File file)
|
boolean |
renameTo(java.io.File source,
java.io.File dest)
|
boolean |
setLastModified(java.io.File file,
long time)
|
boolean |
setReadOnly(java.io.File file)
|
java.lang.String |
toString()
|
Methods inherited from class com.myJava.file.driver.AbstractLinkableFileSystemDriver |
---|
flush, getAbsoluteFile, getAbsolutePath, getAccessEfficiency, getCanonicalFile, getCanonicalPath, getName, getParent, getParentFile, getPath, getPredecessor, mount, setPredecessor, supportsLongFileNames, unmount |
Methods inherited from class com.myJava.file.driver.AbstractFileSystemDriver |
---|
checkFilePath, createSymbolicLink, isAbsolute, mkdirs, normalizeIfNeeded |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface com.myJava.file.driver.FileSystemDriver |
---|
createSymbolicLink, isAbsolute, mkdirs |
Field Detail |
---|
protected HashCache cache
protected java.io.File directoryRoot
Constructor Detail |
---|
public HashFileSystemDriver(java.io.File directoryRoot)
Method Detail |
---|
public java.io.File getDirectoryRoot()
public boolean canRead(java.io.File file)
public boolean canWrite(java.io.File file)
public boolean createNewFile(java.io.File file) throws java.io.IOException
createNewFile
in interface FileSystemDriver
createNewFile
in class AbstractFileSystemDriver
java.io.IOException
public boolean delete(java.io.File file)
delete
in interface FileSystemDriver
delete
in class AbstractFileSystemDriver
public boolean exists(java.io.File file)
exists
in interface FileSystemDriver
exists
in class AbstractFileSystemDriver
public boolean isDirectory(java.io.File file)
isDirectory
in interface FileSystemDriver
isDirectory
in class AbstractFileSystemDriver
public boolean isFile(java.io.File file)
isFile
in interface FileSystemDriver
isFile
in class AbstractFileSystemDriver
public boolean isHidden(java.io.File file)
isHidden
in interface FileSystemDriver
isHidden
in class AbstractFileSystemDriver
public long lastModified(java.io.File file)
lastModified
in interface FileSystemDriver
lastModified
in class AbstractFileSystemDriver
public FileCacheableInformations getInformations(java.io.File file)
FileSystemDriver
public FileMetaData getMetaData(java.io.File f, boolean onlyBasicAttributes) throws java.io.IOException
FileSystemDriver
getMetaData
in interface FileSystemDriver
getMetaData
in class AbstractFileSystemDriver
java.io.IOException
public long length(java.io.File file)
length
in interface FileSystemDriver
length
in class AbstractFileSystemDriver
public void deleteOnExit(java.io.File f)
deleteOnExit
in interface FileSystemDriver
deleteOnExit
in class AbstractFileSystemDriver
public java.lang.String[] list(java.io.File file, java.io.FilenameFilter filter)
list
in interface FileSystemDriver
list
in class AbstractFileSystemDriver
public java.lang.String[] list(java.io.File file)
list
in interface FileSystemDriver
list
in class AbstractFileSystemDriver
public java.io.File[] listFiles(java.io.File file, java.io.FileFilter filter)
listFiles
in interface FileSystemDriver
listFiles
in class AbstractFileSystemDriver
public java.io.File[] listFiles(java.io.File file, java.io.FilenameFilter filter)
listFiles
in interface FileSystemDriver
listFiles
in class AbstractFileSystemDriver
public java.io.File[] listFiles(java.io.File file)
listFiles
in interface FileSystemDriver
listFiles
in class AbstractFileSystemDriver
public boolean mkdir(java.io.File file)
mkdir
in interface FileSystemDriver
mkdir
in class AbstractFileSystemDriver
public boolean renameTo(java.io.File source, java.io.File dest)
renameTo
in interface FileSystemDriver
renameTo
in class AbstractFileSystemDriver
public boolean setLastModified(java.io.File file, long time)
setLastModified
in interface FileSystemDriver
setLastModified
in class AbstractFileSystemDriver
public void applyMetaData(FileMetaData p, java.io.File f) throws java.io.IOException
FileSystemDriver
applyMetaData
in interface FileSystemDriver
applyMetaData
in class AbstractFileSystemDriver
java.io.IOException
public boolean setReadOnly(java.io.File file)
setReadOnly
in interface FileSystemDriver
setReadOnly
in class AbstractFileSystemDriver
public java.io.InputStream getCachedFileInputStream(java.io.File file) throws java.io.IOException
FileSystemDriver
java.io.IOException
public java.io.InputStream getFileInputStream(java.io.File file) throws java.io.IOException
java.io.IOException
public java.io.OutputStream getCachedFileOutputStream(java.io.File file) throws java.io.IOException
FileSystemDriver
java.io.IOException
public java.io.OutputStream getFileOutputStream(java.io.File file) throws java.io.IOException
java.io.IOException
public java.io.OutputStream getFileOutputStream(java.io.File file, boolean append) throws java.io.IOException
java.io.IOException
public java.io.OutputStream getFileOutputStream(java.io.File file, boolean append, OutputStreamListener listener) throws java.io.IOException
java.io.IOException
public boolean directFileAccessSupported()
protected java.io.File encodeFileName(java.io.File file)
protected java.lang.String encodeFileName(java.io.File encodedParent, java.lang.String shortName) throws HashCollisionException, java.io.IOException
HashCollisionException
java.io.IOException
protected java.io.File decodeFileName(java.io.File file) throws java.io.IOException
java.io.IOException
protected java.lang.String decodeFileName(java.io.File parent, java.lang.String shortName) throws java.io.IOException
java.io.IOException
protected java.io.File getDecodingFile(java.io.File file)
protected void createDecodingFile(java.io.File encoded, java.lang.String decodedName) throws java.io.IOException
java.io.IOException
protected boolean isDecodingFile(java.io.File f)
protected boolean isDecodingFile(java.lang.String f)
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public java.lang.String toString()
toString
in class AbstractLinkableFileSystemDriver
public boolean isContentSensitive()
FileSystemDriver
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |