Class FileEntryIterator

java.lang.Object
org.eclipse.sisu.space.FileEntryIterator
All Implemented Interfaces:
Iterator<String>

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

    • rootPath

      private final String rootPath
    • entryNames

      private final Deque<String> entryNames
    • recurse

      private final boolean recurse
  • Constructor Details

    • FileEntryIterator

      FileEntryIterator(URL url, 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 Details

    • hasNext

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

      public String next()
      Specified by:
      next in interface Iterator<String>
    • remove

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

      static File toFile(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(String subPath)
      Appends entries from the given sub-path to the cached list of named entries.
      Parameters:
      subPath - The sub path
    • normalizePath

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