Interface StreamCache

  • All Known Implementing Classes:
    InMemoryStreamCache, TempFileStreamCache

    public interface StreamCache
    Interface used to store the bytes for a PDFStream. It's actually a generic cached byte array. There's a factory that returns either an in-memory or tempfile based implementation based on a cacheToFile setting.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void clear()
      Clears and resets the cache.
      java.io.OutputStream getOutputStream()
      Get the current OutputStream.
      int getSize()
      Returns the current size of the stream.
      int outputContents​(java.io.OutputStream out)
      Outputs the cached bytes to the given stream.
      void write​(byte[] data)
      Convenience method for writing data to the stream cache.
    • Method Detail

      • getOutputStream

        java.io.OutputStream getOutputStream()
                                      throws java.io.IOException
        Get the current OutputStream. Do not store it - it may change from call to call.
        Returns:
        an output stream for this cache
        Throws:
        java.io.IOException - if there is an IO error
      • write

        void write​(byte[] data)
            throws java.io.IOException
        Convenience method for writing data to the stream cache.
        Parameters:
        data - byte array to write
        Throws:
        java.io.IOException - if there is an IO error
      • outputContents

        int outputContents​(java.io.OutputStream out)
                    throws java.io.IOException
        Outputs the cached bytes to the given stream.
        Parameters:
        out - the stream to write to
        Returns:
        the number of bytes written
        Throws:
        java.io.IOException - if there is an IO error
      • getSize

        int getSize()
             throws java.io.IOException
        Returns the current size of the stream.
        Returns:
        the size of the cache
        Throws:
        java.io.IOException - if there is an IO error
      • clear

        void clear()
            throws java.io.IOException
        Clears and resets the cache.
        Throws:
        java.io.IOException - if there is an IO error