Package digilib.io

Class DocuDirectory

  • All Implemented Interfaces:
    Iterable<DocuDirent>
    Direct Known Subclasses:
    CdstarArchiveDocuDirectory, FsDocuDirectory

    public abstract class DocuDirectory
    extends Object
    implements Iterable<DocuDirent>
    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 Detail

      • logger

        protected org.slf4j.Logger logger
      • fileClass

        protected FileOps.FileClass fileClass
        type of files in this DocuDirectory
      • isValid

        protected boolean isValid
        directory object is valid (exists on disk)
      • dirName

        protected String dirName
        directory name (digilib canonical form)
      • meta

        protected DirMeta meta
        directory metadata
      • objectATime

        protected long objectATime
        time of last access of this object (not the filesystem)
      • dirMTime

        protected long dirMTime
        time directory was last modified on the file system
    • Constructor Detail

      • DocuDirectory

        public DocuDirectory()
    • Method Detail

      • configure

        public void configure​(String path,
                              FileOps.FileClass fileClass,
                              DigilibConfiguration dlConfig)
        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 name
        fileClass - type of files in this DocuDirectory
        dlConfig - digilib config
        See Also:
        readDir()
      • size

        public int size()
        number of DocuFiles in this directory.
        Returns:
        the size
      • get

        public DocuDirent get​(int index)
        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

        public int indexOf​(String fn)
        Searches for the file with the name fn. Searches the directory for the file with the name fn and returns its index. Returns -1 if the file cannot be found.
        Parameters:
        fn - filename
        Returns:
        int index of file fn
      • isBasenameAt

        protected boolean isBasenameAt​(List<DocuDirent> fileList,
                                       int idx,
                                       String fn)
        Checks if the basename of the DocuDirent in fileList at the position idx matches fn.
        Parameters:
        fileList -
        idx -
        fn -
        Returns:
      • isPrefixBasenameAt

        protected boolean isPrefixBasenameAt​(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.
        Parameters:
        fileList -
        idx -
        fn -
        Returns:
      • find

        public DocuDirent find​(String fn)
        Finds the DocuDirent with the name fn. Searches the directory for the DocuDirent with the name fn and returns it. Returns null if the file cannot be found.
        Parameters:
        fn - filename
        Returns:
        the DocuDirent
      • getDirName

        public String 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

        public DirMeta getMeta()
        Returns:
        the DirMeta
      • createParentName

        public abstract String createParentName​(String fn)
        Returns a possible parent directory name for path fn.
        Parameters:
        fn - the fn
        Returns:
        the parent name
      • createFilename

        public abstract String createFilename​(String fn)
        Returns a possible file name for path fn.
        Parameters:
        fn - the fn
        Returns:
        the name
      • getParent

        public DocuDirectory getParent()
        Returns the parent DocuDirectory.
        Returns:
        the DocuDirectory
      • setParent

        public void setParent​(DocuDirectory pd)
        Sets the parent DocuDirectory.
        Parameters:
        pd - the DocuDirectory