Class AbstractContainerScannerPlugin<I,E,D extends FileContainerDescriptor>

Type Parameters:
I - The container type.
E - The element type.
D - The descriptor type.
All Implemented Interfaces:
ScannerPlugin<I,D>, com.buschmais.jqassistant.core.shared.lifecycle.ContextualConfigurableLifecycleAware<ScannerContext,Map<String,Object>>, com.buschmais.jqassistant.core.shared.lifecycle.LifecycleAware
Direct Known Subclasses:
AbstractArchiveInputStreamScannerPlugin, AbstractDirectoryScannerPlugin, ZipFileScannerPlugin

public abstract class AbstractContainerScannerPlugin<I,E,D extends FileContainerDescriptor> extends AbstractResourceScannerPlugin<I,D>
Abstract base implementation for scanner plugins that handle containers of elements like directories, archives, etc.
  • Constructor Details

    • AbstractContainerScannerPlugin

      public AbstractContainerScannerPlugin()
  • Method Details

    • scan

      public final D scan(I container, String path, Scope scope, Scanner scanner) throws IOException
      Throws:
      IOException
    • getContainerDescriptor

      protected abstract D getContainerDescriptor(I container, ScannerContext scannerContext)
      Return the descriptor representing the artifact.
      Parameters:
      container - The container.
      scannerContext - The scanner context.
      Returns:
      The artifact descriptor.
    • getEntries

      protected abstract Iterable<? extends E> getEntries(I container) throws IOException
      Return an iterable which delivers the entries of the container.

      The entries must not contain the relative root element, i.e. "/".

      Parameters:
      container - The container.
      Returns:
      The iterable of entries.
      Throws:
      IOException - If the entries cannot be determined.
    • getContainerPath

      protected abstract String getContainerPath(I container, String path)
      Return the normalized path to the container.
      Parameters:
      container - The container.
      Returns:
      The normalized path.
    • getRelativePath

      protected abstract String getRelativePath(I container, E entry)
      Return the relative path of an element within the container.

      The following conditions must be considered:

      • The separator to use is "/".
      • The path must start with "/".
      • The path must not end with "/".

      Parameters:
      container - The container.
      entry - The entry.
      Returns:
      The relative path.
    • enterContainer

      protected abstract void enterContainer(I container, D containerDescriptor, ScannerContext scannerContext) throws IOException
      Create a scope depending on the container type, e.g. a JAR file should return classpath scope.
      Parameters:
      container - The container.
      containerDescriptor - The container descriptor.
      scannerContext - The scanner context.
      Throws:
      IOException
    • leaveContainer

      protected abstract void leaveContainer(I container, D containerDescriptor, ScannerContext scannerContext) throws IOException
      Destroy the container dependent scope.
      Parameters:
      container - The container.
      containerDescriptor - The container descriptor
      scannerContext - The scanner context.
      Throws:
      IOException
    • getEntry

      protected abstract Resource getEntry(I container, E entry)
      Return a Resource representing an entry.
      Parameters:
      container - The container.
      entry - The entry.
      Returns:
      The FileResource .