Class JarFileScanner

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

    public final class JarFileScanner
    extends AbstractResourceFinderAdapter
    A utility class that scans entries in jar files.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static char JAR_FILE_SEPARATOR  
      private java.util.jar.JarInputStream jarInputStream  
      private static java.util.logging.Logger LOGGER  
      private java.util.jar.JarEntry next  
      private java.lang.String parent  
      private boolean recursive  
    • Constructor Summary

      Constructors 
      Constructor Description
      JarFileScanner​(java.io.InputStream inputStream, java.lang.String parent, boolean recursive)
      Create new JAR file scanner.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      Default implementation of #close() which does nothing.
      boolean hasNext()  
      java.lang.String next()  
      java.io.InputStream open()
      Open current resource.
      void reset()
      Reset the ResourceFinder instance.
      • 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

      • LOGGER

        private static final java.util.logging.Logger LOGGER
      • jarInputStream

        private final java.util.jar.JarInputStream jarInputStream
      • parent

        private final java.lang.String parent
      • recursive

        private final boolean recursive
      • next

        private java.util.jar.JarEntry next
    • Constructor Detail

      • JarFileScanner

        public JarFileScanner​(java.io.InputStream inputStream,
                              java.lang.String parent,
                              boolean recursive)
                       throws java.io.IOException
        Create new JAR file scanner.
        Parameters:
        inputStream - JAR file input stream
        parent - JAR file entry prefix.
        recursive - if (true the packages will be scanned recursively together with any nested packages, if false only the explicitly listed packages will be scanned.
        Throws:
        java.io.IOException - if wrapping given input stream into JarInputStream failed.
    • Method Detail

      • hasNext

        public boolean hasNext()
      • next

        public java.lang.String next()
      • reset

        public void reset()
        Description copied from interface: ResourceFinder
        Reset the ResourceFinder instance.

        Upon calling this method the implementing class MUST reset its internal state to the initial state.

      • open

        public java.io.InputStream open()
        Description copied from interface: ResourceFinder
        Open current resource.
        Returns:
        input stream from which current resource can be loaded.