Class LfsFactory.LfsInputStream

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable
    Enclosing class:
    LfsFactory

    public static final class LfsFactory.LfsInputStream
    extends java.io.InputStream
    Encapsulate a potentially exchanged InputStream along with the expected stream content length.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private long length
      The expected stream content length.
      private java.io.InputStream stream
      The actual stream.
    • Constructor Summary

      Constructors 
      Constructor Description
      LfsInputStream​(java.io.InputStream stream, long length)
      Create a new wrapper around a certain stream
      LfsInputStream​(TemporaryBuffer buffer)
      Create a new wrapper around a temporary buffer.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      long getLength()  
      int read()  
      int read​(byte[] b, int off, int len)  
      • Methods inherited from class java.io.InputStream

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

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

      • stream

        private java.io.InputStream stream
        The actual stream.
      • length

        private long length
        The expected stream content length.
    • Constructor Detail

      • LfsInputStream

        public LfsInputStream​(java.io.InputStream stream,
                              long length)
        Create a new wrapper around a certain stream
        Parameters:
        stream - the stream to wrap. the stream will be closed on close().
        length - the expected length of the stream
      • LfsInputStream

        public LfsInputStream​(TemporaryBuffer buffer)
                       throws java.io.IOException
        Create a new wrapper around a temporary buffer.
        Parameters:
        buffer - the buffer to initialize stream and length from. The buffer will be destroyed on close()
        Throws:
        java.io.IOException - in case of an error opening the stream to the buffer.
    • Method Detail

      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class java.io.InputStream
        Throws:
        java.io.IOException
      • read

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

        public int read​(byte[] b,
                        int off,
                        int len)
                 throws java.io.IOException
        Overrides:
        read in class java.io.InputStream
        Throws:
        java.io.IOException
      • getLength

        public long getLength()
        Returns:
        the length of the stream