Package digilib.io
Class DocuDirCache
java.lang.Object
digilib.io.DocuDirCache
- Direct Known Subclasses:
AliasingDocuDirCache
- Author:
- casties
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected FileOps.FileClassallowed file class (image/text)protected AtomicIntegernumber of cache hitsprotected static org.slf4j.Loggergeneral logger for this classprotected ConcurrentMap<String, DocuDirectory> HashMap of directoriesprotected AtomicIntegernumber of cache missesprotected AtomicIntegernumber of files in the whole cache (approximate) -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.DocuDirCache(FileOps.FileClass fc, DigilibConfiguration dlConfig) Constructor with digilib configuration and file class. -
Method Summary
Modifier and TypeMethodDescriptiongetDirectory(String fn) Returns the DocuDirectory indicated by the pathnamefn.Returns the DocuDirent with the pathnamefnand the indexin.getFile(String fn, int in, FileOps.FileClass fc) Deprecated.intgetHits()intintput(DocuDirectory newdir) Add a DocuDirectory to the cache.putDir(DocuDirectory newDir) Add a directory to the cache and check its parents.voidsetFileClass(FileOps.FileClass fileClass) intsize()The number of directories in the cache.
-
Field Details
-
logger
protected static org.slf4j.Logger loggergeneral logger for this class -
map
HashMap of directories -
fileClass
allowed file class (image/text) -
numFiles
number of files in the whole cache (approximate) -
hits
number of cache hits -
misses
number of cache misses
-
-
Constructor Details
-
DocuDirCache
Constructor with digilib configuration and file class.- Parameters:
fc- the FileClassdlConfig- the DigilibConfiguration
-
DocuDirCache
public DocuDirCache()Default constructor. Uses FileClass.IMAGE.
-
-
Method Details
-
size
public int size()The number of directories in the cache.- Returns:
- the size
-
put
Add a DocuDirectory to the cache. Always returns the correct Object from the cache, either newdir one or another one.- Parameters:
newdir- the DocuDirectory- Returns:
- dir the DocuDirectory
-
putDir
Add a directory to the cache and check its parents. Always returns the correct Object from the cache, either newDir or the cached one.- Parameters:
newDir- the DocuDirectory- Returns:
- the DocuDirectory
-
getFile
Deprecated.UsegetFile(String fn, int in)instead.Returns the DocuDirent with the pathnamefnand the indexinof FileClass fc. Iffnis a file then the corresponding DocuDirent is returned and the index is ignored.- Parameters:
fn- digilib pathnamein- file indexfc- file class- Returns:
- the DocuDirent
-
getFile
Returns the DocuDirent with the pathnamefnand the indexin. Iffnrepresents a file then the corresponding DocuDirent is returned and the number is ignored.- Parameters:
fn- digilib pathnamepn- file number- Returns:
- the DocuDirent
-
getDirectory
Returns the DocuDirectory indicated by the pathnamefn. Iffnrepresents a file then its parent directory is returned.- Parameters:
fn- digilib pathname- Returns:
- the DocuDirectory
-
getNumFiles
public int getNumFiles()- Returns:
- long the num files
-
getHits
public int getHits()- Returns:
- long the hits
-
getMisses
public int getMisses()- Returns:
- long the misses
-
getFileClass
- Returns:
- the FileClass
-
setFileClass
- Parameters:
fileClass- the FileClass
-
getFile(String fn, int in)instead.