Package digilib.io
Class DocuDirectory
java.lang.Object
digilib.io.DocuDirectory
- All Implemented Interfaces:
Iterable<DocuDirent>
- Direct Known Subclasses:
CdstarArchiveDocuDirectory,FsDocuDirectory
Class representing a directory containing (image) files.
Files can be access by index or name. All files are of the same FileClass.
The DocuDirectory holds DirMeta.
Subclasses of DocuDirectory can also hold multiple scaled versions of an image file.
- Author:
- casties
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected longtime directory was last modified on the file systemprotected Stringdirectory name (digilib canonical form)protected FileOps.FileClasstype of files in this DocuDirectoryprotected List<DocuDirent> list of files (DocuDirent)protected booleandirectory object is valid (exists on disk)protected org.slf4j.Loggerprotected DirMetadirectory metadataprotected longtime of last access of this object (not the filesystem)protected DocuDirectoryparent DocuDirectory -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcheck directory metadata.voidconfigure(String path, FileOps.FileClass fileClass, DigilibConfiguration dlConfig) Configure object with digilib directory path and a parent DocuDirCache.abstract StringcreateFilename(String fn) Returns a possible file name for path fn.abstract StringReturns a possible parent directory name for path fn.Finds the DocuDirent with the namefn.get(int index) Returns the ImageFileSet at the index.longlongReturns the digilib canonical name.getMeta()Returns the parent DocuDirectory.intSearches for the file with the namefn.protected booleanisBasenameAt(List<DocuDirent> fileList, int idx, String fn) Checks if the basename of the DocuDirent in fileList at the position idx matches fn.protected booleanisPrefixBasenameAt(List<DocuDirent> fileList, int idx, String fn) Checks if fn is the prefix of the basename of the DocuDirent in fileList at the position idx.booleanisRead()The directory has been read from disk.booleanisValid()The directory is valid (exists on disk).iterator()Returns an Iterator over all DocuDirents in this DocuDirectory in default order.abstract booleanreadDir()Read the filesystem directory and fill this object.voidreadMeta()Read directory metadata.abstract booleanrefresh()Check to see if the directory has been modified and reread if necessary.voidSets the parent DocuDirectory.intsize()number of DocuFiles in this directory.longtouch()Update access time.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
logger
protected org.slf4j.Logger logger -
fileClass
type of files in this DocuDirectory -
parent
parent DocuDirectory -
files
list of files (DocuDirent) -
isValid
protected boolean isValiddirectory object is valid (exists on disk) -
dirName
directory name (digilib canonical form) -
meta
directory metadata -
objectATime
protected long objectATimetime of last access of this object (not the filesystem) -
dirMTime
protected long dirMTimetime directory was last modified on the file system
-
-
Constructor Details
-
DocuDirectory
public DocuDirectory()
-
-
Method Details
-
configure
Configure object with digilib directory path and a parent DocuDirCache. Directory names at the given path are appended to the base directories from the cache. The directory is checked on disk and isValid is set.- Parameters:
path- digilib directory path namefileClass- type of files in this DocuDirectorydlConfig- digilib config- See Also:
-
size
public int size()number of DocuFiles in this directory.- Returns:
- the size
-
get
Returns the ImageFileSet at the index.- Parameters:
index- the index- Returns:
- the DocuDirent
-
readDir
public abstract boolean readDir()Read the filesystem directory and fill this object. Clears the List and (re)reads all files.- Returns:
- boolean the directory exists
-
refresh
public abstract boolean refresh()Check to see if the directory has been modified and reread if necessary.- Returns:
- boolean the directory is valid
-
readMeta
public void readMeta()Read directory metadata. -
checkMeta
public void checkMeta()check directory metadata. -
touch
public long touch()Update access time.- Returns:
- time of last access.
-
indexOf
Searches for the file with the namefn. Searches the directory for the file with the namefnand returns its index. Returns -1 if the file cannot be found.- Parameters:
fn- filename- Returns:
- int index of file
fn
-
isBasenameAt
Checks if the basename of the DocuDirent in fileList at the position idx matches fn.- Parameters:
fileList-idx-fn-- Returns:
-
isPrefixBasenameAt
Checks if fn is the prefix of the basename of the DocuDirent in fileList at the position idx.- Parameters:
fileList-idx-fn-- Returns:
-
find
Finds the DocuDirent with the namefn. Searches the directory for the DocuDirent with the namefnand returns it. Returns null if the file cannot be found.- Parameters:
fn- filename- Returns:
- the DocuDirent
-
getDirName
Returns the digilib canonical name.- Returns:
- the name
-
isValid
public boolean isValid()The directory is valid (exists on disk).- Returns:
- is valid
-
isRead
public boolean isRead()The directory has been read from disk.- Returns:
- is read
-
getAccessTime
public long getAccessTime()- Returns:
- access time
-
getDirMTime
public long getDirMTime()- Returns:
- the mtime
-
getMeta
- Returns:
- the DirMeta
-
iterator
Returns an Iterator over all DocuDirents in this DocuDirectory in default order.- Specified by:
iteratorin interfaceIterable<DocuDirent>- Returns:
- the Iterator
-
createParentName
Returns a possible parent directory name for path fn.- Parameters:
fn- the fn- Returns:
- the parent name
-
createFilename
Returns a possible file name for path fn.- Parameters:
fn- the fn- Returns:
- the name
-
getParent
Returns the parent DocuDirectory.- Returns:
- the DocuDirectory
-
setParent
Sets the parent DocuDirectory.- Parameters:
pd- the DocuDirectory
-