Class MetadataExtractor.RandomAccessStreamReader

    • Field Detail

      • _stream

        private final java.io.InputStream _stream
      • _chunkLength

        private final int _chunkLength
      • _chunks

        private final java.util.ArrayList<byte[]> _chunks
      • _isStreamFinished

        private boolean _isStreamFinished
      • _streamLength

        private long _streamLength
    • Constructor Detail

      • RandomAccessStreamReader

        public RandomAccessStreamReader​(java.io.InputStream stream)
      • RandomAccessStreamReader

        public RandomAccessStreamReader​(java.io.InputStream stream,
                                        int chunkLength)
      • RandomAccessStreamReader

        public RandomAccessStreamReader​(java.io.InputStream stream,
                                        int chunkLength,
                                        long streamLength)
    • Method Detail

      • validateIndex

        protected void validateIndex​(int index,
                                     int bytesRequested)
                              throws java.io.IOException
        Ensures that the buffered bytes extend to cover the specified index. If not, an attempt is made to read to that point.

        If the stream ends before the point is reached, a MetadataExtractor.BufferBoundsException is raised.

        Specified by:
        validateIndex in class MetadataExtractor.RandomAccessReader
        Parameters:
        index - the index from which the required bytes start
        bytesRequested - the number of bytes which are required
        Throws:
        MetadataExtractor.BufferBoundsException - if the stream ends before the required number of bytes are acquired
        java.io.IOException - if the stream ends before the required number of bytes are acquired
      • getByte

        public byte getByte​(int index)
                     throws java.io.IOException
        Description copied from class: MetadataExtractor.RandomAccessReader
        Gets the byte value at the specified byte index.

        Implementations should not perform any bounds checking in this method. That should be performed in validateIndex and isValidIndex.

        Specified by:
        getByte in class MetadataExtractor.RandomAccessReader
        Parameters:
        index - The index from which to read the byte
        Returns:
        The read byte value
        Throws:
        MetadataExtractor.BufferBoundsException - if the requested byte is beyond the end of the underlying data source
        java.io.IOException - if the byte is unable to be read
      • getBytes

        public byte[] getBytes​(int index,
                               int count)
                        throws java.io.IOException
        Description copied from class: MetadataExtractor.RandomAccessReader
        Returns the required number of bytes from the specified index from the underlying source.
        Specified by:
        getBytes in class MetadataExtractor.RandomAccessReader
        Parameters:
        index - The index from which the bytes begins in the underlying source
        count - The number of bytes to be returned
        Returns:
        The requested bytes
        Throws:
        MetadataExtractor.BufferBoundsException - if the requested bytes extend beyond the end of the underlying data source
        java.io.IOException - if the byte is unable to be read