Class AbstractOnDemandInputStream<T extends java.io.OutputStream>

    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected abstract void closeEntry​(T outputStream)
      Closes the current entry context for the specified OutputStream.
      protected abstract T createOutputStream​(java.io.OutputStream outputStream)
      Creates the real OutputStream to which we'll write, wrapping the provided target.
      private void doCopy()
      Performs copy operation between currentNodeStream and outputStream using buffer length.
      private void endAsset()
      Close entry in stream.
      protected abstract void putNextEntry​(T outputStream, java.lang.String context)
      Writes the next entry (demarcates a new file/folder is to be written).
      int read()  
      private void startAsset​(java.lang.String path)
      Start entry in stream.
      • Methods inherited from class java.io.InputStream

        available, close, mark, markSupported, read, read, reset, skip
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • BUFFER_LENGTH

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

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

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

        private final java.io.ByteArrayOutputStream bufferedOutputStream
        Base for outputStream.
      • currentNodeStream

        private java.io.InputStream currentNodeStream
        Stream of currently processed Node.
      • bufferInputStream

        private java.io.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 Detail

      • AbstractOnDemandInputStream

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

      • read

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

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

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

        private void endAsset()
                       throws java.io.IOException
        Close entry in stream.
        Throws:
        java.io.IOException
      • createOutputStream

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

        protected abstract void putNextEntry​(T outputStream,
                                             java.lang.String context)
                                      throws java.io.IOException
        Writes the next entry (demarcates a new file/folder is to be written).
        Parameters:
        outputStream -
        context -
        Throws:
        java.io.IOException - If an error occurred writing the entry
      • closeEntry

        protected abstract void closeEntry​(T outputStream)
                                    throws java.io.IOException
        Closes the current entry context for the specified OutputStream.
        Parameters:
        outputStream -
        Throws:
        java.io.IOException