db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From krist...@apache.org
Subject svn commit: r540083 - in /db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc: ClobStreamControl.java EmbedClob.java
Date Mon, 21 May 2007 09:28:44 GMT
Author: kristwaa
Date: Mon May 21 02:28:43 2007
New Revision: 540083

URL: http://svn.apache.org/viewvc?view=rev&rev=540083
Log:
DERBY-2646: Cleanup of Clob control/support structures. Removal of trailing space characters.
This patch *only* deletes spaces.
Patch file: derby-2646-01a_trailing_space.diff

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

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/ClobStreamControl.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/ClobStreamControl.java?view=diff&rev=540083&r1=540082&r2=540083
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/ClobStreamControl.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/ClobStreamControl.java Mon
May 21 02:28:43 2007
@@ -1,4 +1,4 @@
-/* 
+/*
 
    Derby - Class org.apache.derby.impl.jdbc.ClobStreamControl
 
@@ -35,7 +35,7 @@
 import org.apache.derby.iapi.util.ByteArray;
 
 final class ClobStreamControl extends LOBStreamControl {
-    
+
     private ConnectionChild conChild;
 
     /**
@@ -48,8 +48,8 @@
     ClobStreamControl (String dbName, ConnectionChild conChild) {
         super (dbName);
         this.conChild = conChild;
-    }        
-    
+    }
+
     /**
      * Finds the corresponding byte position for the given UTF-8 character
      * position, starting from the byte position <code>startPos</code>.
@@ -82,7 +82,7 @@
                     //no second and third byte present
                     throw new UTFDataFormatException();
                 }
-                streamLength += 2;                
+                streamLength += 2;
             }
             else if ((c & 0x70) == 0x60) // we know the top bit is set here
             {
@@ -98,11 +98,11 @@
                 throw new UTFDataFormatException();
             }
         }
-        
+
         in.close();
-        return streamLength;        
+        return streamLength;
     }
-    
+
     /**
      * Constructs and returns a <code>Writer</code> for the CLOB value.
      *
@@ -118,7 +118,7 @@
                                 "" + (pos + 1));
         return new ClobUtf8Writer (this, getStreamPosition (0, charPos));
     }
-    
+
     /**
      * Constructs and returns a <code>Reader</code>.
      * @param pos initial position of the returned <code>Reader</code> in
@@ -137,8 +137,8 @@
             leftToSkip -= isr.skip (leftToSkip);
         }
         return isr;
-    }    
-    
+    }
+
     /**
      * Returns a substring.
      * @param bIndex 
@@ -147,9 +147,9 @@
      * @throws IOException
      * @throws SQLException
      */
-    synchronized String getSubstring (long bIndex, long eIndex) 
+    synchronized String getSubstring (long bIndex, long eIndex)
                                             throws IOException, SQLException {
-        Reader r = getReader(bIndex);        
+        Reader r = getReader(bIndex);
         char [] buff = new char [(int) (eIndex - bIndex)];
         int length = 0;
         do {
@@ -160,7 +160,7 @@
         } while (length < eIndex - bIndex);
         return new String (buff, 0, length);
     }
-    
+
     /**
      * returns number of charecter in the clob.
      * @return char length
@@ -177,7 +177,7 @@
         }while (true);
         return length;
     }
-    
+
     /**
      * Returns the size of the Clob in bytes.
      * @return Number of bytes in the <code>CLOB</code> value.
@@ -186,7 +186,7 @@
     long getByteLength () throws IOException {
         return super.getLength();
     }
-    
+
     /**
      * inserts a string at a given postion.
      * @param str 
@@ -194,7 +194,7 @@
      * @return current byte postion
      * @throws IOException
      */
-    synchronized long insertString (String str, long pos) 
+    synchronized long insertString (String str, long pos)
                                             throws IOException, SQLException {
         int len = str.length();
         if (pos == super.getLength()) {
@@ -207,7 +207,7 @@
         replaceBytes (getByteFromString (str), pos, endPos);
         return str.length();
     }
-    
+
     /**
      * Converts a string into utf8 byte array.
      * @param str 
@@ -236,5 +236,5 @@
         byte [] buff = new byte [len];
         System.arraycopy (buffer, 0, buff, 0, len);
         return buff;
-    } 
+    }
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedClob.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedClob.java?view=diff&rev=540083&r1=540082&r2=540083
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedClob.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedClob.java Mon May 21 02:28:43
2007
@@ -75,7 +75,7 @@
     private boolean         materialized;
     private InputStream     myStream;
     private ClobStreamControl control;
-    
+
     //This boolean variable indicates whether the Clob object has
     //been invalidated by calling free() on it
     private boolean isValid = true;
@@ -83,15 +83,15 @@
     /**
      * This constructor is used to create a empty Clob object. It is used by the
      * Connection interface method createClob().
-     * 
-     * @param clobString A String object containing the data to be stores in the 
+     *
+     * @param clobString A String object containing the data to be stores in the
      *        Clob.
      *
      * @param con The Connection object associated with this EmbedClob object.
      * @throws SQLException
      *
      */
-    
+
     EmbedClob(String clobString,EmbedConnection con) throws SQLException {
         super(con);
         materialized = true;
@@ -99,12 +99,12 @@
         try {
             control.insertString (clobString, 0);
         }
-       
+
         catch (IOException e) {
             throw Util.setStreamFailure (e);
         }
     }
-    
+
     /**
      * This constructor should only be called by {@link EmbedResultSet#getClob}.
      *
@@ -238,7 +238,7 @@
    * <code>pos</code> and has up to <code>length</code> consecutive
    * characters. The starting position must be between 1 and the length
    * of the CLOB plus 1. This allows for zero-length CLOB values, from
-   * which only zero-length substrings can be returned. 
+   * which only zero-length substrings can be returned.
    * If a larger length is requested than there are characters available,
    * characters from the start position to the end of the CLOB are returned.
    * @param pos the first character of the substring to be extracted.
@@ -257,7 +257,7 @@
         //call checkValidity to exit by throwing a SQLException if
         //the Clob object has been freed by calling free() on it
         checkValidity();
-        
+
         if (pos < 1)
             throw Util.generateCsSQLException(
                 SQLState.BLOB_BAD_POSITION, new Long(pos));
@@ -347,7 +347,7 @@
                             if (materialized) {
                                 return control.getReader (0);
                             }
-                            
+
                             return getCharacterStreamAtPos(1, synchronization);
 			}
 			catch (Throwable t)
@@ -382,24 +382,24 @@
     throws IOException, StandardException {
         UTF8Reader clobReader = null;
         if (materialized)
-            clobReader = new UTF8Reader (control.getInputStream (0), 0, 
-                                            control.getByteLength(), 
+            clobReader = new UTF8Reader (control.getInputStream (0), 0,
+                                            control.getByteLength(),
                                     this, control);
         else {
             ((Resetable)myStream).resetStream();
             clobReader = new UTF8Reader(myStream, 0, this, synchronization);
         }
-        
+
         // skip to the correct position (pos is one based)
         long remainToSkip = position - 1;
         while (remainToSkip > 0) {
             long skipBy = clobReader.skip(remainToSkip);
             if (skipBy == -1)
                 return null;
-            
+
             remainToSkip -= skipBy;
         }
-        
+
         return clobReader;
     }
 
@@ -425,12 +425,12 @@
    * </ul>
    * <p>
    * The position where the stream has a char equal to the first char of
-   * <code>searchStr</code> will be remembered and used as the starting 
+   * <code>searchStr</code> will be remembered and used as the starting
    * position for the next search-iteration if the current match fails.
    * If a non-matching char is found, start a fresh search from the position
    * remembered. If there is no such position, next search will start at the
    * current position <code>+1</code>.
-   * 
+   *
    * @param searchStr the substring for which to search
    * @param start the position at which to begin searching; the first position
    *    is <code>1</code>
@@ -446,7 +446,7 @@
         //call checkValidity to exit by throwing a SQLException if
         //the Clob object has been freed by calling free() on it
         checkValidity();
-        
+
         boolean pushStack = false;
         try
         {
@@ -476,23 +476,23 @@
                     if (readCount == -1)
                         return -1;
                     if (readCount == 0)
-                        continue;            
-                    for (int clobOffset = 0; 
+                        continue;
+                    for (int clobOffset = 0;
                                 clobOffset < readCount; clobOffset++) {
-                        if (tmpClob [clobOffset] 
+                        if (tmpClob [clobOffset]
                                         == searchStr.charAt (matchCount)) {
-                            //find the new starting position in 
+                            //find the new starting position in
                             // case this match is unsuccessful
-                            if (matchCount != 0 && newStart == -1 
-                                    && tmpClob [clobOffset] 
+                            if (matchCount != 0 && newStart == -1
+                                    && tmpClob [clobOffset]
                                     == searchStr.charAt (0)) {
                                 newStart = pos + clobOffset + 1;
                             }
                             matchCount ++;
                             if (matchCount == searchStr.length()) {
-                                //return after converting the position 
+                                //return after converting the position
                                 //to 1 based index
-                                return pos + clobOffset 
+                                return pos + clobOffset
                                         - searchStr.length() + 1 + 1;
                             }
                         }
@@ -503,19 +503,19 @@
                                         //compensate for increment in the "for"
                                         clobOffset--;
                                     }
-                                    matchCount = 0;                                    
+                                    matchCount = 0;
                                     continue;
                                 }
                                 matchCount = 0;
                                 if (newStart < pos) {
                                     pos = newStart;
                                     reader.close();
-                                    reader = getCharacterStreamAtPos 
+                                    reader = getCharacterStreamAtPos
                                                 (newStart + 1, this);
                                     newStart = -1;
                                     reset = true;
                                     break;
-                                }                        
+                                }
                                 clobOffset = (int) (newStart - pos) - 1;
                                 newStart = -1;
                                 continue;
@@ -562,7 +562,7 @@
         //call checkValidity to exit by throwing a SQLException if
         //the Clob object has been freed by calling free() on it
         checkValidity();
-        
+
         boolean pushStack = false;
         try
         {
@@ -684,7 +684,7 @@
     *
     * @param pos - the position at which to start writing to the CLOB value that
     * this Clob object represents
-    * @return the number of characters written 
+    * @return the number of characters written
     * @exception SQLException Feature not implemented for now.
 	*/
 	public int setString(long pos, String str) throws SQLException {
@@ -700,7 +700,7 @@
     * @param pos - the position at which to start writing to this Clob object
     * @param str - the string to be written to the CLOB value that this Clob designates
     * @param offset - the offset into str to start reading the characters to be written
-    * @param len - the number of characters to be written 
+    * @param len - the number of characters to be written
     * @return the number of characters written
     * @exception SQLException Feature not implemented for now.
 	*/
@@ -729,7 +729,7 @@
     * value that this Clob object represents, starting at position pos.
     *
     * @param pos - the position at which to start writing to this Clob object
-    * @return the stream to which ASCII encoded characters can be written 
+    * @return the stream to which ASCII encoded characters can be written
     * @exception SQLException Feature not implemented for now.
 	*/
     public java.io.OutputStream setAsciiStream(long pos) throws SQLException {
@@ -747,7 +747,7 @@
     * CLOB value that this Clob object represents, starting at position pos.
     *
     * @param pos - the position at which to start writing to this Clob object
-    * @return the stream to which Unicode encoded characters can be written 
+    * @return the stream to which Unicode encoded characters can be written
     * @exception SQLException Feature not implemented for now.
 	*/
     public java.io.Writer setCharacterStream(long pos) throws SQLException {
@@ -794,18 +794,18 @@
         throws SQLException {
         //calling free() on a already freed object is treated as a no-op
         if (!isValid) return;
-        
+
         //now that free has been called the Clob object is no longer
         //valid
         isValid = false;
-        
+
         if (!materialized) {
             ((Resetable)myStream).closeStream();
         }
         else {
             try {
                 control.free();
-            }    
+            }
             catch (IOException e) {
                 throw Util.setStreamFailure(e);
             }
@@ -832,9 +832,9 @@
         }
 		return org.apache.derby.impl.jdbc.EmbedResultSet.noStateChangeException(t);
 	}
-        
+
         /*
-         * Checks is isValid is true. If it is not true throws 
+         * Checks is isValid is true. If it is not true throws
          * a SQLException stating that a method has been called on
          * an invalid LOB object
          *



Mime
View raw message