Class AbstractCachedSeekableStream.StreamCache

    • Constructor Summary

      Constructors 
      Constructor Description
      StreamCache()
      Creates a StreamCache.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) abstract void close()  
      (package private) void flush​(long pPosition)
      Optionally flushes any data prior to the given position.
      (package private) abstract long getPosition()
      Returns the current cache read/write position.
      (package private) abstract int read()
      Reads a single byte a the current read/write position.
      (package private) int read​(byte[] pBuffer, int pOffset, int pLength)
      Writes a series of bytes at the current read/write position.
      (package private) abstract void seek​(long pPosition)
      Repositions the current cache read/write position to the given position.
      (package private) void write​(byte[] pBuffer, int pOffset, int pLength)
      Writes a series of bytes at the current read/write position.
      (package private) abstract void write​(int pByte)
      Writes a single byte at the current read/write position.
      • Methods inherited from class java.lang.Object

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

      • StreamCache

        StreamCache()
        Creates a StreamCache.
    • Method Detail

      • write

        abstract void write​(int pByte)
                     throws java.io.IOException
        Writes a single byte at the current read/write position. The read/write position will be increased by one.
        Parameters:
        pByte - the byte value to write.
        Throws:
        java.io.IOException - if an I/O exception occurs in the cache backing mechanism.
      • write

        void write​(byte[] pBuffer,
                   int pOffset,
                   int pLength)
            throws java.io.IOException
        Writes a series of bytes at the current read/write position. The read/write position will be increased by pLength.

        This implementation invokes write(int) pLength times. Subclasses may override this method for performance.

        Parameters:
        pBuffer - the bytes to write.
        pOffset - the starting offset into the buffer.
        pLength - the number of bytes to write from the buffer.
        Throws:
        java.io.IOException - if an I/O exception occurs in the cache backing mechanism.
      • read

        abstract int read()
                   throws java.io.IOException
        Reads a single byte a the current read/write position. The read/write position will be increased by one.
        Returns:
        the value read, or -1 to indicate EOF.
        Throws:
        java.io.IOException - if an I/O exception occurs in the cache backing mechanism.
      • read

        int read​(byte[] pBuffer,
                 int pOffset,
                 int pLength)
          throws java.io.IOException
        Writes a series of bytes at the current read/write position. The read/write position will be increased by pLength.

        This implementation invokes read() pLength times. Subclasses may override this method for performance.

        Parameters:
        pBuffer - the bytes to write
        pOffset - the starting offset into the buffer.
        pLength - the number of bytes to write from the buffer.
        Returns:
        the number of bytes read, or -1 to indicate EOF.
        Throws:
        java.io.IOException - if an I/O exception occurs in the cache backing mechanism.
      • seek

        abstract void seek​(long pPosition)
                    throws java.io.IOException
        Repositions the current cache read/write position to the given position.
        Parameters:
        pPosition - the new read/write position
        Throws:
        java.io.IOException - if an I/O exception occurs in the cache backing mechanism.
      • flush

        void flush​(long pPosition)
        Optionally flushes any data prior to the given position.

        Attempting to perform a seek operation, and/or a read or write operation to a position equal to or before the flushed position may result in exceptions or undefined behaviour.

        Subclasses should override this method for performance reasons, to avoid holding on to unnecessary resources. This implementation does nothing.

        Parameters:
        pPosition - the last position to flush.
      • getPosition

        abstract long getPosition()
                           throws java.io.IOException
        Returns the current cache read/write position.
        Returns:
        the current cache read/write postion.
        Throws:
        java.io.IOException - if the position can't be determined because of a problem in the cache backing mechanism.
      • close

        abstract void close()
                     throws java.io.IOException
        Throws:
        java.io.IOException