Class AbstractOnDemandInputStream<T extends OutputStream>

java.lang.Object
java.io.InputStream
org.jboss.shrinkwrap.impl.base.exporter.AbstractOnDemandInputStream<T>
All Implemented Interfaces:
Closeable, AutoCloseable
Direct Known Subclasses:
TarBz2OnDemandInputStream, TarGzOnDemandInputStream, TarOnDemandInputStreamBase, ZipOnDemandInputStream

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.
  • Field Details

    • BUFFER_LENGTH

      private static final int BUFFER_LENGTH
      Number of bytes kept in buffer.
      See Also:
    • nodesIterator

      private final Iterator<Node> nodesIterator
      Iterator over nodes contained in base archive.
    • outputStream

      protected T extends OutputStream outputStream
      Created by abstract method.
    • bufferedOutputStream

      private final ByteArrayOutputStream bufferedOutputStream
      Base for outputStream.
    • currentNodeStream

      private InputStream currentNodeStream
      Stream of currently processed Node.
    • bufferInputStream

      private ByteArrayInputStream bufferInputStream
      Stream to the buffer.
    • outputStreamClosed

      private boolean outputStreamClosed
      If output stream was closed - we should finish.
    • currentPath

      private ArchivePath currentPath
      Currently processed archive path - for displaying exception.
  • Constructor Details

    • AbstractOnDemandInputStream

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

    • read

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

      private void doCopy() throws IOException
      Performs copy operation between currentNodeStream and outputStream using buffer length.
      Throws:
      IOException
    • startAsset

      private void startAsset(String path) throws IOException
      Start entry in stream.
      Parameters:
      path -
      Throws:
      IOException
    • endAsset

      private void endAsset() throws IOException
      Close entry in stream.
      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 -
      Returns:
      Throws:
      IOException - If an error occurred in creating the stream
    • putNextEntry

      protected abstract void putNextEntry(T outputStream, String context) throws IOException
      Writes the next entry (demarcates a new file/folder is to be written).
      Parameters:
      outputStream -
      context -
      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 -
      Throws:
      IOException