Class FileEntryIterator

  • All Implemented Interfaces:
    java.util.Iterator<java.lang.String>

    final class FileEntryIterator
    extends java.lang.Object
    implements java.util.Iterator<java.lang.String>
    Iterator that iterates over named entries beneath a file-system directory.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.Deque<java.lang.String> entryNames  
      private boolean recurse  
      private java.lang.String rootPath  
    • Constructor Summary

      Constructors 
      Constructor Description
      FileEntryIterator​(java.net.URL url, java.lang.String subPath, boolean recurse)
      Creates an iterator that iterates over entries beneath the given file URL and sub-path.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private void appendEntries​(java.lang.String subPath)
      Appends entries from the given sub-path to the cached list of named entries.
      boolean hasNext()  
      java.lang.String next()  
      private static java.lang.String normalizePath​(java.io.File file)
      Returns the normalized URI path of the given file.
      void remove()  
      (package private) static java.io.File toFile​(java.net.URL url)
      Converts a URL into a File converting slashes and encoded characters where appropriate.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.util.Iterator

        forEachRemaining
    • Field Detail

      • rootPath

        private final java.lang.String rootPath
      • entryNames

        private final java.util.Deque<java.lang.String> entryNames
      • recurse

        private final boolean recurse
    • Constructor Detail

      • FileEntryIterator

        FileEntryIterator​(java.net.URL url,
                          java.lang.String subPath,
                          boolean recurse)
        Creates an iterator that iterates over entries beneath the given file URL and sub-path.
        Parameters:
        url - The root file URL
        subPath - The path below the root URL
        recurse - When true include sub-directories; otherwise don't
    • Method Detail

      • hasNext

        public boolean hasNext()
        Specified by:
        hasNext in interface java.util.Iterator<java.lang.String>
      • next

        public java.lang.String next()
        Specified by:
        next in interface java.util.Iterator<java.lang.String>
      • remove

        public void remove()
        Specified by:
        remove in interface java.util.Iterator<java.lang.String>
      • toFile

        static java.io.File toFile​(java.net.URL url)
        Converts a URL into a File converting slashes and encoded characters where appropriate.
        Parameters:
        url - The file URL
        Returns:
        File instance for the given URL
      • appendEntries

        private void appendEntries​(java.lang.String subPath)
        Appends entries from the given sub-path to the cached list of named entries.
        Parameters:
        subPath - The sub path
      • normalizePath

        private static java.lang.String normalizePath​(java.io.File file)
        Returns the normalized URI path of the given file.
        Parameters:
        file - The file to normalize
        Returns:
        Normalized URI path