Class ResourceEnumeration

java.lang.Object
org.eclipse.sisu.space.ResourceEnumeration
All Implemented Interfaces:
Enumeration<URL>

final class ResourceEnumeration extends Object implements Enumeration<URL>
Enumeration of resources found by scanning JARs and directories.
  • Field Details

    • NO_ENTRIES

      private static final Iterator<String> NO_ENTRIES
    • urls

      private final URL[] urls
    • subPath

      private final String subPath
    • globber

      private final GlobberStrategy globber
    • globPattern

      private final Object globPattern
    • recurse

      private final boolean recurse
    • index

      private int index
    • currentURL

      private URL currentURL
    • isFolder

      private boolean isFolder
    • entryNames

      private Iterator<String> entryNames
    • nextEntryName

      private String nextEntryName
  • Constructor Details

    • ResourceEnumeration

      ResourceEnumeration(String subPath, String glob, boolean recurse, URL[] urls)
      Creates an Enumeration that scans the given URLs for resources matching the globbed pattern.
      Parameters:
      subPath - An optional path to begin the search from
      glob - The globbed basename pattern
      recurse - When true search paths below the initial search point; otherwise don't
      urls - The URLs containing resources
  • Method Details

    • hasMoreElements

      public boolean hasMoreElements()
      Specified by:
      hasMoreElements in interface Enumeration<URL>
    • nextElement

      public URL nextElement()
      Specified by:
      nextElement in interface Enumeration<URL>
    • normalizeSearchPath

      static String normalizeSearchPath(String path)
      Normalizes the initial search path by removing any duplicate or initial slashes.
      Parameters:
      path - The path to normalize
      Returns:
      Normalized search path
    • scan

      private Iterator<String> scan(URL url)
      Returns the appropriate Iterator to iterate over the contents of the given URL.
      Parameters:
      url - The containing URL
      Returns:
      Iterator that iterates over resources contained inside the given URL
    • findResource

      private URL findResource(String name) throws MalformedURLException
      Returns a URL pointing to the named resource underneath the current search URL.
      Parameters:
      name - The resource name
      Returns:
      URL for the resource
      Throws:
      MalformedURLException
    • matchesRequest

      private boolean matchesRequest(String entryName)
      Compares the given entry name against the normalized search path and compiled glob pattern.
      Parameters:
      entryName - The entry name
      Returns:
      true if the given name matches the search criteria; otherwise false