Class AbstractOnDemandInputStream<T extends OutputStream>

java.lang.Object
java.io.InputStream
org.jboss.shrinkwrap.impl.base.exporter.AbstractOnDemandInputStream<T>
All Implemented Interfaces:
Closeable, AutoCloseable

public abstract class AbstractOnDemandInputStream<T extends OutputStream> extends InputStream
Base for on-demand input streams. Encodes data on the fly, when read method is executed.
Author:
Michal Matloka
  • Field Details

    • outputStream

      protected T extends OutputStream outputStream
      Created by abstract method.
  • Constructor Details

    • AbstractOnDemandInputStream

      public AbstractOnDemandInputStream(Archive<?> archive)
      Creates stream directly from archive.
      Parameters:
      archive - The archive from which the stream is created
  • Method Details

    • read

      public int read() throws IOException
      Specified by:
      read in class InputStream
      Throws:
      IOException
    • createOutputStream

      protected abstract T createOutputStream(OutputStream outputStream) throws IOException
      Creates the real OutputStream to which we'll write, wrapping the provided target.
      Parameters:
      outputStream - The underlying output stream to be wrapped
      Returns:
      The created output stream
      Throws:
      IOException - If an error occurred in creating the stream
    • putNextEntry

      protected abstract void putNextEntry(T outputStream, String context, Asset asset) throws IOException
      Writes the next entry (demarcates a new file/folder is to be written).
      Parameters:
      outputStream - The output stream to write to
      context - The context or path of the entry
      asset - The asset to be written
      Throws:
      IOException - If an error occurred writing the entry
    • closeEntry

      protected abstract void closeEntry(T outputStream) throws IOException
      Closes the current entry context for the specified OutputStream.
      Parameters:
      outputStream - The output stream to close the entry for
      Throws:
      IOException