Package digilib.io
Class DocuDirCache
java.lang.Object
digilib.io.DocuDirCache
- Direct Known Subclasses:
AliasingDocuDirCache
- Author:
- casties
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected FileOps.FileClass
allowed file class (image/text)protected AtomicInteger
number of cache hitsprotected static org.slf4j.Logger
general logger for this classprotected ConcurrentMap
<String, DocuDirectory> HashMap of directoriesprotected AtomicInteger
number of cache missesprotected AtomicInteger
number 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 pathnamefn
and the indexin
.getFile
(String fn, int in, FileOps.FileClass fc) Deprecated.int
getHits()
int
int
put
(DocuDirectory newdir) Add a DocuDirectory to the cache.putDir
(DocuDirectory newDir) Add a directory to the cache and check its parents.void
setFileClass
(FileOps.FileClass fileClass) int
size()
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 pathnamefn
and the indexin
of FileClass fc. Iffn
is 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 pathnamefn
and the indexin
. Iffn
represents 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
. Iffn
represents 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.