Package digilib.io
Class DocuDirCache
- java.lang.Object
-
- digilib.io.DocuDirCache
-
- Direct Known Subclasses:
AliasingDocuDirCache
public class DocuDirCache extends Object
- Author:
- casties
-
-
Field Summary
Fields Modifier and Type Field Description protected FileOps.FileClass
fileClass
allowed file class (image/text)protected AtomicInteger
hits
number of cache hitsprotected static org.slf4j.Logger
logger
general logger for this classprotected ConcurrentMap<String,DocuDirectory>
map
HashMap of directoriesprotected AtomicInteger
misses
number of cache missesprotected AtomicInteger
numFiles
number of files in the whole cache (approximate)
-
Constructor Summary
Constructors Constructor Description DocuDirCache()
Default constructor.DocuDirCache(FileOps.FileClass fc, DigilibConfiguration dlConfig)
Constructor with digilib configuration and file class.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description DocuDirectory
getDirectory(String fn)
Returns the DocuDirectory indicated by the pathnamefn
.DocuDirent
getFile(String fn, int pn)
Returns the DocuDirent with the pathnamefn
and the indexin
.DocuDirent
getFile(String fn, int in, FileOps.FileClass fc)
Deprecated.UsegetFile(String fn, int in)
instead.FileOps.FileClass
getFileClass()
int
getHits()
int
getMisses()
int
getNumFiles()
DocuDirectory
put(DocuDirectory newdir)
Add a DocuDirectory to the cache.DocuDirectory
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 Detail
-
logger
protected static org.slf4j.Logger logger
general logger for this class
-
map
protected ConcurrentMap<String,DocuDirectory> map
HashMap of directories
-
fileClass
protected FileOps.FileClass fileClass
allowed file class (image/text)
-
numFiles
protected AtomicInteger numFiles
number of files in the whole cache (approximate)
-
hits
protected AtomicInteger hits
number of cache hits
-
misses
protected AtomicInteger misses
number of cache misses
-
-
Constructor Detail
-
DocuDirCache
public DocuDirCache(FileOps.FileClass fc, DigilibConfiguration dlConfig)
Constructor with digilib configuration and file class.- Parameters:
fc
- the FileClassdlConfig
- the DigilibConfiguration
-
DocuDirCache
public DocuDirCache()
Default constructor. Uses FileClass.IMAGE.
-
-
Method Detail
-
size
public int size()
The number of directories in the cache.- Returns:
- the size
-
put
public DocuDirectory put(DocuDirectory newdir)
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
public DocuDirectory putDir(DocuDirectory newDir)
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
public DocuDirent getFile(String fn, int in, FileOps.FileClass fc)
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
public DocuDirent getFile(String fn, int pn)
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
public DocuDirectory getDirectory(String fn)
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
public FileOps.FileClass getFileClass()
- Returns:
- the FileClass
-
setFileClass
public void setFileClass(FileOps.FileClass fileClass)
- Parameters:
fileClass
- the FileClass
-
-