Class SmartLinksDirectoryWalker

  • Direct Known Subclasses:
    Deleter.RecursiveDeleter

    public abstract class SmartLinksDirectoryWalker
    extends org.apache.commons.io.DirectoryWalker<String>
    A DirectoryWalker which provides convenience methods to initiate traversal, and (optionally) does not follow symbolic links.
    • Nested Class Summary

      • Nested classes/interfaces inherited from class org.apache.commons.io.DirectoryWalker

        org.apache.commons.io.DirectoryWalker.CancelException
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private boolean mFollowLinks  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected SmartLinksDirectoryWalker​(boolean followLinks)
      Constructor mirroring superclass constructor.
      protected SmartLinksDirectoryWalker​(boolean followLinks, FileFilter filter, int depthLimit)
      Constructor mirroring superclass constructor.
      protected SmartLinksDirectoryWalker​(boolean followLinks, org.apache.commons.io.filefilter.IOFileFilter directoryFilter, org.apache.commons.io.filefilter.IOFileFilter fileFilter, int depthLimit)
      Constructor mirroring superclass constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void apply​(File root)
      Traverses the file tree rooted at the given root.
      void apply​(File root, Collection<String> results)
      Traverses the file tree rooted at the given root.
      void apply​(String name)
      Traverses the file tree rooted at the file with the given name.
      void apply​(String name, Collection<String> results)
      Traverses the file tree rooted at the file with the given name.
      boolean getFollowLinks()
      Returns true if symbolic links to directories should be followed during traversal.
      protected boolean handleDirectory​(File directory, int depth, Collection<String> results)
      Returns false if the given directory is a symbolic link to a directory, and links are not to be followed, thereby blocking following the link during traversal.
      • Methods inherited from class org.apache.commons.io.DirectoryWalker

        checkIfCancelled, filterDirectoryContents, handleCancelled, handleDirectoryEnd, handleDirectoryStart, handleEnd, handleFile, handleIsCancelled, handleRestricted, handleStart, walk
    • Field Detail

      • mFollowLinks

        private boolean mFollowLinks
    • Constructor Detail

      • SmartLinksDirectoryWalker

        protected SmartLinksDirectoryWalker​(boolean followLinks)
        Constructor mirroring superclass constructor.
        Parameters:
        followLinks - True if links should be followed.
        See Also:
        DirectoryWalker()
      • SmartLinksDirectoryWalker

        protected SmartLinksDirectoryWalker​(boolean followLinks,
                                            FileFilter filter,
                                            int depthLimit)
        Constructor mirroring superclass constructor.
        Parameters:
        followLinks - True if links should be followed.
        filter - The filter to apply. It may be null, meaning visit all files.
        depthLimit - Controls to what depth the hierarchy is navigated. Less than 0 means unlimited.
        See Also:
        DirectoryWalker(FileFilter,int)
      • SmartLinksDirectoryWalker

        protected SmartLinksDirectoryWalker​(boolean followLinks,
                                            org.apache.commons.io.filefilter.IOFileFilter directoryFilter,
                                            org.apache.commons.io.filefilter.IOFileFilter fileFilter,
                                            int depthLimit)
        Constructor mirroring superclass constructor.
        Parameters:
        followLinks - True if links should be followed.
        directoryFilter - The filter to apply to directories. It may be null, meaning visit all directories.
        fileFilter - The filter to apply to files. It may be null, meaning visit all directories.
        depthLimit - Controls to what depth the hierarchy is navigated. Less than 0 means unlimited.
        See Also:
        DirectoryWalker(IOFileFilter,IOFileFilter,int)
    • Method Detail

      • handleDirectory

        protected boolean handleDirectory​(File directory,
                                          int depth,
                                          Collection<String> results)
                                   throws IOException
        Returns false if the given directory is a symbolic link to a directory, and links are not to be followed, thereby blocking following the link during traversal. In this case, it also invokes DirectoryWalker.handleFile(File,int,Collection) on the link.
        Overrides:
        handleDirectory in class org.apache.commons.io.DirectoryWalker<String>
        Throws:
        IOException
        See Also:
        DirectoryWalker.handleDirectory(File,int,Collection)
      • getFollowLinks

        public boolean getFollowLinks()
        Returns true if symbolic links to directories should be followed during traversal.
        Returns:
        True if so.
      • apply

        public void apply​(File root,
                          Collection<String> results)
                   throws IOException
        Traverses the file tree rooted at the given root. The root may be nonexistent (no-op) or a plain file (which becomes the only file visited).
        Parameters:
        root - The root.
        results - An object passed intact into DirectoryWalker callbacks.
        Throws:
        IOException - Thrown if an I/O error occurs.
      • apply

        public void apply​(File root)
                   throws IOException
        Traverses the file tree rooted at the given root. The root may be nonexistent (no-op) or a plain file (which becomes the only file visited). The results argument in all DirectoryWalker callbacks will be null.
        Parameters:
        root - The root.
        Throws:
        IOException - Thrown if an I/O error occurs.
      • apply

        public void apply​(String name,
                          Collection<String> results)
                   throws IOException
        Traverses the file tree rooted at the file with the given name. The root may be nonexistent (no-op) or a plain file (which becomes the only file visited).
        Parameters:
        name - The file name.
        results - An object passed intact into DirectoryWalker callbacks.
        Throws:
        IOException - Thrown if an I/O error occurs.
      • apply

        public void apply​(String name)
                   throws IOException
        Traverses the file tree rooted at the file with the given name. The root may be nonexistent (no-op) or a plain file (which becomes the only file visited). The results argument in all DirectoryWalker callbacks will be null.
        Parameters:
        name - The file name.
        Throws:
        IOException - Thrown if an I/O error occurs.