Class LocalDirectoryLister

    • Field Detail

      • m_StopFile

        protected String m_StopFile
        the name of the "stop file" which results in an empty list to be returned.
      • m_StopFileEncountered

        protected boolean m_StopFileEncountered
        whether the stop file was encountered.
      • m_SkipLockedFiles

        protected boolean m_SkipLockedFiles
        whether to skip locked files.
      • m_MinFileTimestamp

        protected BaseDateTime m_MinFileTimestamp
        the minimum file timestamp ("last modified").
      • m_MaxFileTimestamp

        protected BaseDateTime m_MaxFileTimestamp
        the maximum file timestamp ("last modified").
      • m_UseRelativePaths

        protected boolean m_UseRelativePaths
        whether to output relative paths.
    • Constructor Detail

      • LocalDirectoryLister

        public LocalDirectoryLister()
        Initializes the object.
    • Method Detail

      • setStopFile

        public void setStopFile​(String value)
        Sets the name of the stop file which results in returning an empty list.
        Parameters:
        value - the name of the file
      • getStopFile

        public String getStopFile()
        Returns the name of the stop file which results in returning an empty list.
        Returns:
        the name of the file
      • setSkipLockedFiles

        public void setSkipLockedFiles​(boolean value)
        Sets whether to skip locked files. Depends on the underlying OS, whether a file is flagged as locked. E.g., in a JVM under Linux, one would have to lock the file explicitly using java.nio.channels.FileChannel.lock(), since simply opening it for writing does not lock it.
        Parameters:
        value - if true then locked files will be skipped
      • getSkipLockedFiles

        public boolean getSkipLockedFiles()
        Returns whether locked files are skipped.
        Returns:
        true if locked files are skipped
      • setMinFileTimestamp

        public void setMinFileTimestamp​(BaseDateTime value)
        Sets the minimum file timestamp ("last modified") that the files need to have.
        Parameters:
        value - the minimum timestamp
      • getMinFileTimestamp

        public BaseDateTime getMinFileTimestamp()
        Returns the minimum file timestamp ("last modified") that the files need to have.
        Returns:
        the minimum timestamp
      • setMaxFileTimestamp

        public void setMaxFileTimestamp​(BaseDateTime value)
        Sets the maximum file timestamp ("last modified") that the files need to have.
        Parameters:
        value - the maximum timestamp
      • getMaxFileTimestamp

        public BaseDateTime getMaxFileTimestamp()
        Returns the maximum file timestamp ("last modified") that the files need to have.
        Returns:
        the maximum timestamp
      • setUseRelativePaths

        public void setUseRelativePaths​(boolean value)
        Sets whether to output relative paths.
        Specified by:
        setUseRelativePaths in interface RelativeDirectoryLister
        Parameters:
        value - true if to output relative paths
      • getUseRelativePaths

        public boolean getUseRelativePaths()
        Returns whether to output relative paths.
        Specified by:
        getUseRelativePaths in interface RelativeDirectoryLister
        Returns:
        true if to output relative paths
      • hasStopFileEncountered

        public boolean hasStopFileEncountered()
        Returns whether the stop file was encountered or not.
        Returns:
        true if stop file encountered
      • isFileLocked

        protected boolean isFileLocked​(File file)
        Checks whether the file is currently locked by another process.
        Parameters:
        file - the file to check
        Returns:
        true if the file is locked
      • isLocal

        public boolean isLocal()
        Returns whether the directory lister operates locally or remotely.
        Specified by:
        isLocal in interface DirectoryLister
        Returns:
        true if local lister
      • hasParentDirectory

        public boolean hasParentDirectory()
        Returns whether the watch directory has a parent directory.
        Specified by:
        hasParentDirectory in interface DirectoryLister
        Returns:
        true if parent directory available
      • newDirectory

        public LocalFileObject newDirectory​(String dir)
        Returns a new directory relative to the watch directory.
        Specified by:
        newDirectory in interface DirectoryLister
        Parameters:
        dir - the directory name
        Returns:
        the new wrapper
      • newDirectory

        public LocalFileObject newDirectory​(String parent,
                                            String dir)
        Returns a new directory generated from parent and sub-directory.
        Specified by:
        newDirectory in interface DirectoryLister
        Parameters:
        parent - the parent directory
        dir - the directory name
        Returns:
        the new wrapper
      • search

        protected void search​(File current,
                              List<SortContainer> files,
                              int depth)
        Performs the recursive search. Search goes deeper if != 0 (use -1 to start with for infinite search).
        Parameters:
        current - the current directory
        files - the files collected so far
        depth - the depth indicator (searched no deeper, if 0)
      • list

        public String[] list()
        Returns the list of files/directories in the watched directory. In case the execution gets stopped, this method returns a 0-length array.
        Specified by:
        list in interface DirectoryLister
        Returns:
        the list of absolute file/directory names
      • listObjects

        public FileObject[] listObjects()
        Returns the list of files/directories in the watched directory. In case the execution gets stopped, this method returns a 0-length array.
        Specified by:
        listObjects in interface DirectoryLister
        Returns:
        the list of file/directory wrappers
      • main

        public static void main​(String[] args)
                         throws Exception
        For testing only.
        Parameters:
        args - ignored
        Throws:
        Exception - if something goes wrong