src/java.desktop/share/classes/javax/imageio/stream/MemoryCache.java

Print this page

        

@@ -80,10 +80,12 @@
     /**
      * Ensures that at least <code>pos</code> bytes are cached,
      * or the end of the source is reached.  The return value
      * is equal to the smaller of <code>pos</code> and the
      * length of the source.
+     * 
+     * @throws IOException if there is no more memory for cache
      */
     public long loadFromStream(InputStream stream, long pos)
         throws IOException {
         // We've already got enough data cached
         if (pos < length) {

@@ -141,10 +143,12 @@
      *
      * @exception IndexOutOfBoundsException if any portion of
      * the requested data is not in the cache (including if <code>pos</code>
      * is in a block already disposed), or if either <code>pos</code> or
      * <code>len</code> is < 0.
+     * @throws IOException if there is an I/O exception while writing to the
+     * stream
      */
     public void writeToStream(OutputStream stream, long pos, long len)
         throws IOException {
         if (pos + len > length) {
             throw new IndexOutOfBoundsException("Argument out of cache");

@@ -175,10 +179,12 @@
         }
     }
 
     /**
      * Ensure that there is space to write a byte at the given position.
+     * 
+     * throws IOException if there is no more memory left for cache
      */
     private void pad(long pos) throws IOException {
         long currIndex = cacheStart + cache.size() - 1;
         long lastIndex = pos/BUFFER_LENGTH;
         long numNewBuffers = lastIndex - currIndex;

@@ -195,18 +201,19 @@
      * Overwrites and/or appends the cache from a byte array.
      * The length of the cache will be extended as needed to hold
      * the incoming data.
      *
      * @param b an array of bytes containing data to be written.
-     * @param off the starting offset withing the data array.
+     * @param off the starting offset within the data array.
      * @param len the number of bytes to be written.
      * @param pos the cache position at which to begin writing.
      *
      * @exception NullPointerException if <code>b</code> is <code>null</code>.
      * @exception IndexOutOfBoundsException if <code>off</code>,
      * <code>len</code>, or <code>pos</code> are negative,
      * or if <code>off+len > b.length</code>.
+     * @throws IOException if there is an I/O error while writing to the cache
      */
     public void write(byte[] b, int off, int len, long pos)
         throws IOException {
         if (b == null) {
             throw new NullPointerException("b == null!");

@@ -246,10 +253,11 @@
      * @param b an <code>int</code> whose 8 least significant bits
      * will be written.
      * @param pos the cache position at which to begin writing.
      *
      * @exception IndexOutOfBoundsException if <code>pos</code> is negative.
+     * @throws IOException if there is an I/O error while writing to the cache
      */
     public void write(int b, long pos) throws IOException {
         if (pos < 0) {
             throw new ArrayIndexOutOfBoundsException("pos < 0");
         }

@@ -277,10 +285,13 @@
 
     /**
      * Returns the single byte at the given position, as an
      * <code>int</code>.  Returns -1 if this position has
      * not been cached or has been disposed.
+     * 
+     * @throws IOException if an I/O error occurs while reading from the byte
+     * array
      */
     public int read(long pos) throws IOException {
         if (pos >= length) {
             return -1;
         }

@@ -302,10 +313,12 @@
      * @exception IndexOutOfBoundsException if <code>off</code>,
      * <code>len</code> or <code>pos</code> are negative or if
      * <code>off + len > b.length</code> or if any portion of the
      * requested data is not in the cache (including if
      * <code>pos</code> is in a block that has already been disposed).
+     * @throws IOException if an I/O exception occurs while reading from the
+     * byte array
      */
     public void read(byte[] b, int off, int len, long pos)
         throws IOException {
         if (b == null) {
             throw new NullPointerException("b == null!");