public class CachingDirectory extends Object
Constructor and Description |
---|
CachingDirectory(File directory)
Constructor, where recursive is false.
|
CachingDirectory(File directory,
boolean recursive)
Constructor.
|
CachingDirectory(File directory,
SubDirectoryCreator subDirectoryCreator)
Constructor with recursive set to
true . |
Modifier and Type | Method and Description |
---|---|
int |
delete()
Delete everything inside the "directory" which matches the filter and recursive.
|
boolean |
equals(Object obj)
Equals if the both is of class CachingDirectory and has the same directory.
|
File |
getDirectory()
The caching directory of which must exists and be of type directory.
|
Logger |
getLogger()
Gets the logger
|
File |
getSubDirectory(String key)
From a filename "String" (which is the key) construct a subdirectory if needed to put the value files in different directories.
This could be to limit the the number of files in a directory, or be able to view a sub directory with certain type of values. This will use the "SubDirectoryCreator" (if any) to a create a sub directory to store the value file in, this is only allowed is recursive is true .The default behaviour is that there is no "SubDirectoryCreator", and all files will be stored directly in the caching directory. |
SubDirectoryCreator |
getSubDirectoryCreator()
Gets the SubDirectoryCreator
|
int |
hashCode() |
boolean |
isRecursive()
If the caching directory has multiple levels or not.
|
void |
setSubDirectoryCreator(SubDirectoryCreator subDirectoryCreator)
Sets the SubDirectoryCreator
|
int |
size()
The number of files and directories in the directory, not resursive.
|
void |
validate()
Validates that this "instance" is valid.
|
public CachingDirectory(File directory)
directory
- the root directory, must exists and must be a directory.File.isDirectory()
,
File.exists()
public CachingDirectory(File directory, boolean recursive)
directory
- the root directory, must exists and must be a directory.recursive
- if the directory has multiple levels or not.public CachingDirectory(File directory, SubDirectoryCreator subDirectoryCreator)
true
.directory
- the root directory, must exists and must be a directory.subDirectoryCreator
- the SubDirectoryCreatorpublic void validate() throws IllegalArgumentException, NullPointerException
IllegalArgumentException
- if "getDirectory().getAbsolutePath()" is do not exists, is not a directory, is not readable or writeable.NullPointerException
- "getDirectory()" is null
.ยจgetDirectory()
,
File.exists()
,
File.isDirectory()
,
File.canRead()
,
File.canWrite()
public final boolean isRecursive()
true
, if sub directories is involved, otherwise false
.getSubDirectoryCreator()
public final File getDirectory()
File.exists()
,
File.isDirectory()
public final int size()
getDirectory()
public final int delete()
getDirectory()
,
isRecursive()
public final SubDirectoryCreator getSubDirectoryCreator()
null
is allowed, and the caching directory is used, this is default behaviour.getDirectory()
public final void setSubDirectoryCreator(SubDirectoryCreator subDirectoryCreator)
subDirectoryCreator
- the SubDirectoryCreatorpublic final File getSubDirectory(String key)
true
.key
- the key which is the filename.File.getName()
,
getDirectory()
,
getSubDirectoryCreator()
public final boolean equals(Object obj)
equals
in class Object
getDirectory()
public Logger getLogger()
Copyright © 2016. All rights reserved.