db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From krist...@apache.org
Subject svn commit: r545501 - /db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/UpdateableBlobStream.java
Date Fri, 08 Jun 2007 13:31:09 GMT
Author: kristwaa
Date: Fri Jun  8 06:31:08 2007
New Revision: 545501

URL: http://svn.apache.org/viewvc?view=rev&rev=545501
Log:
DERBY-2711: Added missing throw, made variable blob final, misc. JavaDoc/documentation changes.
Patch file: derby-2711-3a-additional.diff

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/UpdateableBlobStream.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/UpdateableBlobStream.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/UpdateableBlobStream.java?view=diff&rev=545501&r1=545500&r2=545501
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/UpdateableBlobStream.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/UpdateableBlobStream.java Fri
Jun  8 06:31:08 2007
@@ -1,4 +1,4 @@
-/* 
+/*
 
    Derby - Class org.apache.derby.impl.jdbc.UpdateableBlobStream
 
@@ -30,36 +30,43 @@
 import org.apache.derby.iapi.services.i18n.MessageService;
 
 /**
- * Updateable blob stream is a wrapper stream over dvd stream 
- * and LOBInputStream. It detects if blob data has moved from 
- * dvd to clob control update itself to point to LOBInputStream.
+ * Updateable blob stream is a wrapper stream over dvd stream
+ * and LOBInputStream.
+ * It detects if blob data has moved from dvd to clob control. If this happens,
+ * it will update itself to point to LOBInputStream and reflect changes made to
+ * the Blob after the current position of the stream.
  */
 class UpdateableBlobStream extends InputStream {
-    //flag to check if its using stream from LOBStreamControl
-    //or from DVD.
+    /**
+     * Flag to check if it is using stream from LOBStreamControl or from DVD.
+     * <code>true</code> means data is read from LOBStreamControl,
+     * <code>false</code> means data is read from the DVD.
+     */
     private boolean materialized;
     private InputStream stream;
+    /* Current position of this stream in number of bytes. */
     private long pos;
-    private EmbedBlob blob;
-    
+    private final EmbedBlob blob;
+
     /**
      * Constructs UpdateableBlobStream using the the InputStream receives as the
-     * parameter. The initial position is set to the pos.
+     * parameter. The initial position is set to the <code>0</code>.
      * @param blob EmbedBlob this stream is associated with.
      * @param is InputStream this class is going to use internally.
-     * @throws IOException
      */
     UpdateableBlobStream (EmbedBlob blob, InputStream is) {
-        stream = is;        
+        stream = is;
         this.pos = 0;
         this.blob = blob;
     }
-    
-    //Checks if this object is using materialized blob
-    //if not it checks if the blob was materialized since
-    //this stream was last access. If the blob was materialized 
-    //(due to one of the set methods) it gets the stream again and 
-    //sets the position to current read position
+
+    /**
+     * Checks if this object is using materialized blob
+     * if not it checks if the blob was materialized since
+     * this stream was last access. If the blob was materialized
+     * (due to one of the set methods) it gets the stream again and
+     * sets the position to current read position.
+     */
     private void updateIfRequired () throws IOException {
         if (materialized)
             return;
@@ -70,6 +77,7 @@
             } catch (SQLException ex) {
                 IOException ioe = new IOException (ex.getMessage());
                 ioe.initCause (ex);
+                throw ioe;
             }
             long leftToSkip = pos;
             while (leftToSkip > 0) {
@@ -86,11 +94,10 @@
                     }
                 }
                 leftToSkip -= skipped;
-                
             }
         }
     }
-    
+
     /**
      * Reads the next byte of data from the input stream. The value byte is
      * returned as an <code>int</code> in the range <code>0</code>
to
@@ -98,15 +105,19 @@
      * has been reached, the value <code>-1</code> is returned. This method
      * blocks until input data is available, the end of the stream is detected,
      * or an exception is thrown.
-     * 
-     * <p> A subclass must provide an implementation of this method.
-     * 
+     * <p>
+     * A subclass must provide an implementation of this method.
+     * <p>
+     * Note that this stream will reflect changes made to the underlying Blob at
+     * positions equal to or larger then the current position.
+     *
      * @return the next byte of data, or <code>-1</code> if the end of the
      *             stream is reached.
      * @exception IOException  if an I/O error occurs.
+     * @see InputStream#read
      */
     public int read() throws IOException {
-        updateIfRequired();        
+        updateIfRequired();
         int ret = stream.read();
         if (ret >= 0)
             pos++;
@@ -118,8 +129,10 @@
      * an array of bytes.  An attempt is made to read as many as
      * <code>len</code> bytes, but a smaller number may be read.
      * The number of bytes actually read is returned as an integer.
-     * 
-     * 
+     * <p>
+     * Note that this stream will reflect changes made to the underlying Blob at
+     * positions equal to or larger then the current position .
+     *
      * @param b     the buffer into which the data is read.
      * @param off   the start offset in array <code>b</code>
      *                   at which the data is written.
@@ -131,13 +144,13 @@
      * other than end of file, or if the input stream has been closed, or if
      * some other I/O error occurs.
      * @exception NullPointerException If <code>b</code> is <code>null</code>.
-     * @exception IndexOutOfBoundsException If <code>off</code> is negative,

-     * <code>len</code> is negative, or <code>len</code> is greater
than 
+     * @exception IndexOutOfBoundsException If <code>off</code> is negative,
+     * <code>len</code> is negative, or <code>len</code> is greater
than
      * <code>b.length - off</code>
-     * @see java.io.InputStream#read()
+     * @see java.io.InputStream#read(byte[],int,int)
      */
     public int read(byte[] b, int off, int len) throws IOException {
-        updateIfRequired();        
+        updateIfRequired();
         int retValue = super.read(b, off, len);
         if (retValue > 0)
             pos += retValue;
@@ -149,7 +162,10 @@
      * the buffer array <code>b</code>. The number of bytes actually read is
      * returned as an integer.  This method blocks until input data is
      * available, end of file is detected, or an exception is thrown.
-     * 
+     * <p>
+     * Note that this stream will reflect changes made to the underlying Blob at
+     * positions equal to or larger then the current position .
+     *
      * @param b   the buffer into which the data is read.
      * @return the total number of bytes read into the buffer, or
      *             <code>-1</code> is there is no more data because the end of
@@ -158,7 +174,7 @@
      * other than the end of the file, if the input stream has been closed, or
      * if some other I/O error occurs.
      * @exception NullPointerException  if <code>b</code> is <code>null</code>.
-     * @see java.io.InputStream#read(byte[], int, int)
+     * @see java.io.InputStream#read(byte[])
      */
     public int read(byte[] b) throws IOException {
         updateIfRequired();
@@ -176,7 +192,10 @@
      * before <code>n</code> bytes have been skipped is only one possibility.
      * The actual number of bytes skipped is returned.  If <code>n</code> is
      * negative, no bytes are skipped.
-     * 
+     * <p>
+     * Note that this stream will reflect changes made to the underlying Blob at
+     * positions equal to or larger then the current position .
+     *
      * @param n   the number of bytes to be skipped.
      * @return the actual number of bytes skipped.
      * @exception IOException  if the stream does not support seek,
@@ -189,5 +208,5 @@
         if (retValue > 0)
             pos += retValue;
         return retValue;
-    }        
+    }
 }



Mime
View raw message