Modified: 
incubator/derby/code/trunk/java/client/org/apache/derby/client/am/Clob.java
URL: 
http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/client/org/apache/derby/client/am/Clob.java?rev=165585&r1=165584&r2=165585&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/client/org/apache/derby/client/am/Clob.java 
(original)
+++ incubator/derby/code/trunk/java/client/org/apache/derby/client/am/Clob.java 
Sun May  1 23:25:59 2005
@@ -20,357 +20,387 @@
 
 package org.apache.derby.client.am;
 
-public class Clob extends Lob implements java.sql.Clob
-{
-  //---------------------navigational 
members-----------------------------------
-
-  
//-----------------------------state------------------------------------------
-  protected String string_ = null;
-
-  // Only used for input purposes.  For output, each getXXXStream call
-  // must generate an independent stream.
-  protected java.io.InputStream asciiStream_ = null;
-  protected java.io.InputStream unicodeStream_ = null;
-  protected java.io.Reader characterStream_ = null;
-
-  // used for input
-  // Therefore, we always convert a String to UTF-8 before we flow it for input
-  protected byte[] utf8String_;
-
-  // the length of the clob returned by the LENGTH function.
-  protected long lengthInBytes_ = 0;
-
-  private PreparedStatement internalLengthStmt_ = null;
-
-  protected String encoding_ = "UNICODE";
-
-  
//---------------------constructors/finalizer---------------------------------
-  public Clob(Agent agent, String string)
-  {
-    this (agent);
-    string_ = string;
-    sqlLength_ = string_.length();
-    lengthObtained_ = true;
-    dataType_ |= STRING;
-  }
-
-  // CTOR for output, when a btc isn't available; the encoding is
-  public Clob (Agent agent,
-               byte[] unconvertedBytes,
-               String charsetName,
-               int dataOffset) throws SqlException
-  {
-    this (agent);
-    try {
-      // check for null encoding is needed because the net layer
-      // will no longer throw an exception if the server didn't specify
-      // a mixed or double byte ccsid (ccsid = 0).  this check for null in the
-      // cursor is only required for types which can have mixed or double
-      // byte ccsids.
-      if (charsetName == null) {
-        throw new SqlException (agent.logWriter_,
-          "Required character converter not available for data type.");
-      }
-
-      string_ = new  String(unconvertedBytes,
-                            dataOffset,
-                            unconvertedBytes.length - dataOffset,
-                            charsetName);
-      sqlLength_ = string_.length();
-      lengthObtained_ = true;
-      dataType_ |= STRING;
-    }
-    catch (java.io.UnsupportedEncodingException e) {
-      throw new SqlException (agent_.logWriter_, e.getMessage());
-    }
-  }
-
-  // CTOR for ascii/unicode stream input
-  //"US-ASCII", "UTF-8", or "UnicodeBigUnmarked"
-  public Clob (Agent agent,
-               java.io.InputStream inputStream,
-              String encoding,
-               int length) throws SqlException
-  {
-    this (agent);
-
-    sqlLength_ = length;
-    lengthObtained_ = true;
-
-    if (encoding.equals ("US-ASCII")) {
-      asciiStream_ = inputStream;
-      dataType_ |= ASCII_STREAM;
-    }
-    else if (encoding.equals ("UTF-8")){ // "UTF-8"
-      unicodeStream_ = inputStream;
-      dataType_ |= UNICODE_STREAM;
-    }
-    else if (encoding.equals ("UnicodeBigUnmarked")){ // "UnicodeBigUnmarked"
-      try {
-        characterStream_ =
-          new java.io.InputStreamReader(inputStream, "UnicodeBigUnmarked");
-      }
-      catch(java.io.UnsupportedEncodingException e) {
-        throw new SqlException (agent_.logWriter_, e.getMessage());
-      }
-      dataType_ |= CHARACTER_STREAM;
-      sqlLength_ = length / 2;
-    }
-  }
-
-  // CTOR for character stream input
-  // THE ENCODING IS ASSUMED TO BE "UTF-16BE"
-  public Clob(Agent agent, java.io.Reader reader, int length)
-  {
-    this (agent);
-    sqlLength_ = length;
-    lengthObtained_ = true;
-    characterStream_ = reader;
-    dataType_ |= CHARACTER_STREAM;
-  }
-
-  private Clob(Agent agent)
-  {
-    super (agent);
-  }
-
-  protected void finalize () throws java.lang.Throwable
-  {
-    super.finalize();
-    if (internalLengthStmt_ != null)
-      internalLengthStmt_.closeX();
-  }
-
-  // ---------------------------jdbc 
2------------------------------------------
-  // Create another method lengthX for internal calls
-  public long length() throws SqlException
-  {
-    synchronized (agent_.connection_) {
-      if (agent_.loggingEnabled())
-        agent_.logWriter_.traceEntry(this, "length");
-
-      if (lengthObtained_)
-        return sqlLength_;
-
-      lengthInBytes_ = super.sqlLength ();
-
-      if (agent_.loggingEnabled()) agent_.logWriter_.traceExit (this, 
"length", sqlLength_);
-      return sqlLength_;
-    }
-  }
-
-  public String getSubString (long pos, int length) throws SqlException
-  {
-    synchronized (agent_.connection_) {
-      String retVal = null;
-
-      if (agent_.loggingEnabled()) agent_.logWriter_.traceEntry (this, 
"getSubString", (int) pos, length);
-
-      // We can also do a check for pos > length()
-      // Defer it till FP7 so that proper testing can be performed on this
-      if ((pos <= 0) || (length < 0))
-        throw new SqlException(agent_.logWriter_, "Invalid position " + pos +" 
or length " + length);
-
-      retVal = getSubStringX (pos, length);
-
-      if (agent_.loggingEnabled()) agent_.logWriter_.traceExit (this, 
"getSubString", retVal);
-      return retVal;
-    }
-  }
-
-  private String getSubStringX (long pos, int length) throws SqlException
-  {
-    checkForClosedConnection ();
-    long actualLength = Math.min (this.length() - pos + 1, (long) length);
-    return string_.substring((int)pos - 1, (int)(pos - 1 + actualLength));
-  }
-
-  public java.io.Reader getCharacterStream () throws SqlException
-  {
-    synchronized (agent_.connection_) {
-      if (agent_.loggingEnabled()) agent_.logWriter_.traceEntry (this, 
"getCharacterStream");
-
-      java.io.Reader retVal = getCharacterStreamX();
-      if (agent_.loggingEnabled()) agent_.logWriter_.traceExit (this, 
"getCharacterStream", retVal);
-      return retVal;
-    }
-  }
-
-  private java.io.Reader getCharacterStreamX () throws SqlException
-  {
-    checkForClosedConnection ();
-
-    if (isCharacterStream ())  // this Lob is used for input
-      return characterStream_;
-
-    return new java.io.StringReader (string_);
-  }
-
-  public java.io.InputStream getAsciiStream () throws SqlException
-  {
-       synchronized (agent_.connection_) {
-        if (agent_.loggingEnabled()) agent_.logWriter_.traceEntry (this, 
"getAsciiStream");
-
-        java.io.InputStream retVal = getAsciiStreamX();
-        if (agent_.loggingEnabled()) agent_.logWriter_.traceExit (this, 
"getAsciiStream", retVal);
-        return retVal;
-       }
-  }
-
-  private java.io.InputStream getAsciiStreamX () throws SqlException
-  {
-    checkForClosedConnection ();
-
-    if (isAsciiStream ())  // this Lob is used for input
-      return asciiStream_;
-
-    return new AsciiStream (string_, new java.io.StringReader (string_));
-  }
-
-  public long position (String searchstr, long start) throws SqlException
-  {
-       synchronized (agent_.connection_) {
-        if (agent_.loggingEnabled())
-          agent_.logWriter_.traceEntry(this,
-                                       "position(String, long)",
-                                       searchstr,
-                                       start);
-        if (searchstr == null)
-          throw new SqlException(agent_.logWriter_, "Search string cannot be 
null.");
-
-        long pos = positionX (searchstr, start);
-        if (agent_.loggingEnabled())
-          agent_.logWriter_.traceExit(this, "position(String, long)", pos);
-        return pos;
-    }
-  }
-
-  private long positionX (String searchstr, long start) throws SqlException
-  {
-    checkForClosedConnection ();
-
-
-    if (start <= 0)
-          throw new SqlException (agent_.logWriter_, "Clob.position(): start 
must be >= 1.");
-
-    int index = string_.indexOf(searchstr, (int) start - 1);
-    if (index != -1)
-      index++; // api index starts at 1
-    return (long) index;
-  }
-
-  public long position (java.sql.Clob searchstr, long start) throws 
SqlException
-  {
-       synchronized (agent_.connection_) {
-        if (agent_.loggingEnabled())
-          agent_.logWriter_.traceEntry(this,
-                                       "position(Clob, long)",
-                                       searchstr,
-                                       start);
-        if (searchstr == null)
-          throw new SqlException(agent_.logWriter_, "Search string cannot be 
null.");
-        long pos = positionX (searchstr, start);
-        if (agent_.loggingEnabled())
-          agent_.logWriter_.traceExit(this, "position(Clob, long)", pos);
-        return pos;
-    }
-  }
-
-  private long positionX (java.sql.Clob searchstr, long start) throws 
SqlException
-  {
-    checkForClosedConnection ();
-
-    if (start <= 0)
-       throw new SqlException (agent_.logWriter_, "Clob.position(): start must 
be >= 1.");
-
-    // if the searchstr is longer than the source, no match
-    int index;
-    try {
-      if (searchstr.length() > length())
-        return -1;
-
-      index = string_.indexOf(searchstr.getSubString (1L, (int) 
searchstr.length()), (int) start -1);
-    } catch (java.sql.SQLException e) {
-          throw new SqlException (agent_.logWriter_, e.getMessage());
-    }
-    if (index != -1) index++; // api index starts at 1
-    return (long) index;
-  }
+public class Clob extends Lob implements java.sql.Clob {
+    //---------------------navigational 
members-----------------------------------
 
-    //---------------------------- jdbc 3.0 -----------------------------------
+    
//-----------------------------state------------------------------------------
+    protected String string_ = null;
+
+    // Only used for input purposes.  For output, each getXXXStream call
+    // must generate an independent stream.
+    protected java.io.InputStream asciiStream_ = null;
+    protected java.io.InputStream unicodeStream_ = null;
+    protected java.io.Reader characterStream_ = null;
+
+    // used for input
+    // Therefore, we always convert a String to UTF-8 before we flow it for 
input
+    protected byte[] utf8String_;
+
+    // the length of the clob returned by the LENGTH function.
+    protected long lengthInBytes_ = 0;
+
+    private PreparedStatement internalLengthStmt_ = null;
+
+    protected String encoding_ = "UNICODE";
+
+    
//---------------------constructors/finalizer---------------------------------
+    public Clob(Agent agent, String string) {
+        this(agent);
+        string_ = string;
+        sqlLength_ = string_.length();
+        lengthObtained_ = true;
+        dataType_ |= STRING;
+    }
+
+    // CTOR for output, when a btc isn't available; the encoding is
+    public Clob(Agent agent,
+                byte[] unconvertedBytes,
+                String charsetName,
+                int dataOffset) throws SqlException {
+        this(agent);
+        try {
+            // check for null encoding is needed because the net layer
+            // will no longer throw an exception if the server didn't specify
+            // a mixed or double byte ccsid (ccsid = 0).  this check for null 
in the
+            // cursor is only required for types which can have mixed or double
+            // byte ccsids.
+            if (charsetName == null) {
+                throw new SqlException(agent.logWriter_,
+                        "Required character converter not available for data 
type.");
+            }
+
+            string_ = new String(unconvertedBytes,
+                    dataOffset,
+                    unconvertedBytes.length - dataOffset,
+                    charsetName);
+            sqlLength_ = string_.length();
+            lengthObtained_ = true;
+            dataType_ |= STRING;
+        } catch (java.io.UnsupportedEncodingException e) {
+            throw new SqlException(agent_.logWriter_, e.getMessage());
+        }
+    }
+
+    // CTOR for ascii/unicode stream input
+    //"US-ASCII", "UTF-8", or "UnicodeBigUnmarked"
+    public Clob(Agent agent,
+                java.io.InputStream inputStream,
+                String encoding,
+                int length) throws SqlException {
+        this(agent);
+
+        sqlLength_ = length;
+        lengthObtained_ = true;
+
+        if (encoding.equals("US-ASCII")) {
+            asciiStream_ = inputStream;
+            dataType_ |= ASCII_STREAM;
+        } else if (encoding.equals("UTF-8")) { // "UTF-8"
+            unicodeStream_ = inputStream;
+            dataType_ |= UNICODE_STREAM;
+        } else if (encoding.equals("UnicodeBigUnmarked")) { // 
"UnicodeBigUnmarked"
+            try {
+                characterStream_ =
+                        new java.io.InputStreamReader(inputStream, 
"UnicodeBigUnmarked");
+            } catch (java.io.UnsupportedEncodingException e) {
+                throw new SqlException(agent_.logWriter_, e.getMessage());
+            }
+            dataType_ |= CHARACTER_STREAM;
+            sqlLength_ = length / 2;
+        }
+    }
+
+    // CTOR for character stream input
+    // THE ENCODING IS ASSUMED TO BE "UTF-16BE"
+    public Clob(Agent agent, java.io.Reader reader, int length) {
+        this(agent);
+        sqlLength_ = length;
+        lengthObtained_ = true;
+        characterStream_ = reader;
+        dataType_ |= CHARACTER_STREAM;
+    }
+
+    private Clob(Agent agent) {
+        super(agent);
+    }
+
+    protected void finalize() throws java.lang.Throwable {
+        super.finalize();
+        if (internalLengthStmt_ != null) {
+            internalLengthStmt_.closeX();
+        }
+    }
+
+    // ---------------------------jdbc 
2------------------------------------------
+    // Create another method lengthX for internal calls
+    public long length() throws SqlException {
+        synchronized (agent_.connection_) {
+            if (agent_.loggingEnabled()) {
+                agent_.logWriter_.traceEntry(this, "length");
+            }
+
+            if (lengthObtained_) {
+                return sqlLength_;
+            }
+
+            lengthInBytes_ = super.sqlLength();
+
+            if (agent_.loggingEnabled()) {
+                agent_.logWriter_.traceExit(this, "length", sqlLength_);
+            }
+            return sqlLength_;
+        }
+    }
 
-    public int setString (long pos, String str) throws SqlException
-    {
+    public String getSubString(long pos, int length) throws SqlException {
         synchronized (agent_.connection_) {
-          if (agent_.loggingEnabled()) agent_.logWriter_.traceEntry (this, 
"setString", (int) pos, str);
-          int length = setStringX (pos,str, 0,str.length());
-          if (agent_.loggingEnabled()) agent_.logWriter_.traceExit (this, 
"setString", length);
-          return length;
+            String retVal = null;
+
+            if (agent_.loggingEnabled()) {
+                agent_.logWriter_.traceEntry(this, "getSubString", (int) pos, 
length);
+            }
+
+            // We can also do a check for pos > length()
+            // Defer it till FP7 so that proper testing can be performed on 
this
+            if ((pos <= 0) || (length < 0)) {
+                throw new SqlException(agent_.logWriter_, "Invalid position " 
+ pos + " or length " + length);
+            }
+
+            retVal = getSubStringX(pos, length);
+
+            if (agent_.loggingEnabled()) {
+                agent_.logWriter_.traceExit(this, "getSubString", retVal);
+            }
+            return retVal;
         }
     }
 
-    public int setString (long pos, String str, int offset, int len) throws 
SqlException
-    {
+    private String getSubStringX(long pos, int length) throws SqlException {
+        checkForClosedConnection();
+        long actualLength = Math.min(this.length() - pos + 1, (long) length);
+        return string_.substring((int) pos - 1, (int) (pos - 1 + 
actualLength));
+    }
+
+    public java.io.Reader getCharacterStream() throws SqlException {
         synchronized (agent_.connection_) {
-          if (agent_.loggingEnabled()) agent_.logWriter_.traceEntry (this, 
"setString", (int) pos, str, offset, len);
-          int length = setStringX (pos, str, offset, len);
-          if (agent_.loggingEnabled()) agent_.logWriter_.traceExit (this, 
"setString", length);
-          return length;
+            if (agent_.loggingEnabled()) {
+                agent_.logWriter_.traceEntry(this, "getCharacterStream");
+            }
+
+            java.io.Reader retVal = getCharacterStreamX();
+            if (agent_.loggingEnabled()) {
+                agent_.logWriter_.traceExit(this, "getCharacterStream", 
retVal);
+            }
+            return retVal;
         }
     }
 
-    public int setStringX (long pos, String str, int offset, int len) throws 
SqlException
-    {
-      if ( (int) pos <= 0 || pos - 1 > sqlLength_)
-      throw new SqlException(agent_.logWriter_, "Invalid position " + pos
-                             + " , offset " + offset + " or length " + len);
-      if ( (offset < 0) || offset > str.length() || len < 0 )
-      throw new SqlException(agent_.logWriter_, "Invalid position " + pos
-                             + " , offset " + offset + " or length " + len);
-    if (len == 0)  return 0;
+    private java.io.Reader getCharacterStreamX() throws SqlException {
+        checkForClosedConnection();
+
+        if (isCharacterStream())  // this Lob is used for input
+        {
+            return characterStream_;
+        }
 
-      int length = 0;
-      length = Math.min((str.length()  - offset ),len);
-      String newString = string_.substring(0,(int)pos-1);
-      string_ = newString.concat(str.substring(offset,offset+length));
-      asciiStream_ = new java.io.StringBufferInputStream(string_);
-      unicodeStream_ = new java.io.StringBufferInputStream(string_);
-      characterStream_ = new java.io.StringReader(string_);
-      sqlLength_ = string_.length();
-      return length;
+        return new java.io.StringReader(string_);
     }
 
-    public java.io.OutputStream setAsciiStream (long pos) throws SqlException
-    {
+    public java.io.InputStream getAsciiStream() throws SqlException {
         synchronized (agent_.connection_) {
-            if (agent_.loggingEnabled()) agent_.logWriter_.traceEntry (this, 
"setAsciiStream", (int) pos);
-            ClobOutputStream outStream = new ClobOutputStream (this,pos);
+            if (agent_.loggingEnabled()) {
+                agent_.logWriter_.traceEntry(this, "getAsciiStream");
+            }
+
+            java.io.InputStream retVal = getAsciiStreamX();
+            if (agent_.loggingEnabled()) {
+                agent_.logWriter_.traceExit(this, "getAsciiStream", retVal);
+            }
+            return retVal;
+        }
+    }
 
-            if (agent_.loggingEnabled()) agent_.logWriter_.traceExit (this, 
"setAsciiStream", outStream);
-            return outStream;
+    private java.io.InputStream getAsciiStreamX() throws SqlException {
+        checkForClosedConnection();
+
+        if (isAsciiStream())  // this Lob is used for input
+        {
+            return asciiStream_;
+        }
+
+        return new AsciiStream(string_, new java.io.StringReader(string_));
+    }
+
+    public long position(String searchstr, long start) throws SqlException {
+        synchronized (agent_.connection_) {
+            if (agent_.loggingEnabled()) {
+                agent_.logWriter_.traceEntry(this,
+                        "position(String, long)",
+                        searchstr,
+                        start);
+            }
+            if (searchstr == null) {
+                throw new SqlException(agent_.logWriter_, "Search string 
cannot be null.");
+            }
+
+            long pos = positionX(searchstr, start);
+            if (agent_.loggingEnabled()) {
+                agent_.logWriter_.traceExit(this, "position(String, long)", 
pos);
+            }
+            return pos;
+        }
+    }
+
+    private long positionX(String searchstr, long start) throws SqlException {
+        checkForClosedConnection();
+
+
+        if (start <= 0) {
+            throw new SqlException(agent_.logWriter_, "Clob.position(): start 
must be >= 1.");
+        }
+
+        int index = string_.indexOf(searchstr, (int) start - 1);
+        if (index != -1) {
+            index++; // api index starts at 1
+        }
+        return (long) index;
+    }
+
+    public long position(java.sql.Clob searchstr, long start) throws 
SqlException {
+        synchronized (agent_.connection_) {
+            if (agent_.loggingEnabled()) {
+                agent_.logWriter_.traceEntry(this,
+                        "position(Clob, long)",
+                        searchstr,
+                        start);
+            }
+            if (searchstr == null) {
+                throw new SqlException(agent_.logWriter_, "Search string 
cannot be null.");
+            }
+            long pos = positionX(searchstr, start);
+            if (agent_.loggingEnabled()) {
+                agent_.logWriter_.traceExit(this, "position(Clob, long)", pos);
+            }
+            return pos;
+        }
+    }
+
+    private long positionX(java.sql.Clob searchstr, long start) throws 
SqlException {
+        checkForClosedConnection();
+
+        if (start <= 0) {
+            throw new SqlException(agent_.logWriter_, "Clob.position(): start 
must be >= 1.");
+        }
+
+        // if the searchstr is longer than the source, no match
+        int index;
+        try {
+            if (searchstr.length() > length()) {
+                return -1;
+            }
+
+            index = string_.indexOf(searchstr.getSubString(1L, (int) 
searchstr.length()), (int) start - 1);
+        } catch (java.sql.SQLException e) {
+            throw new SqlException(agent_.logWriter_, e.getMessage());
+        }
+        if (index != -1) {
+            index++; // api index starts at 1
+        }
+        return (long) index;
+    }
+
+    //---------------------------- jdbc 3.0 -----------------------------------
+
+    public int setString(long pos, String str) throws SqlException {
+        synchronized (agent_.connection_) {
+            if (agent_.loggingEnabled()) {
+                agent_.logWriter_.traceEntry(this, "setString", (int) pos, 
str);
+            }
+            int length = setStringX(pos, str, 0, str.length());
+            if (agent_.loggingEnabled()) {
+                agent_.logWriter_.traceExit(this, "setString", length);
+            }
+            return length;
         }
-      }
+    }
+
+    public int setString(long pos, String str, int offset, int len) throws 
SqlException {
+        synchronized (agent_.connection_) {
+            if (agent_.loggingEnabled()) {
+                agent_.logWriter_.traceEntry(this, "setString", (int) pos, 
str, offset, len);
+            }
+            int length = setStringX(pos, str, offset, len);
+            if (agent_.loggingEnabled()) {
+                agent_.logWriter_.traceExit(this, "setString", length);
+            }
+            return length;
+        }
+    }
+
+    public int setStringX(long pos, String str, int offset, int len) throws 
SqlException {
+        if ((int) pos <= 0 || pos - 1 > sqlLength_) {
+            throw new SqlException(agent_.logWriter_, "Invalid position " + pos
+                    + " , offset " + offset + " or length " + len);
+        }
+        if ((offset < 0) || offset > str.length() || len < 0) {
+            throw new SqlException(agent_.logWriter_, "Invalid position " + pos
+                    + " , offset " + offset + " or length " + len);
+        }
+        if (len == 0) {
+            return 0;
+        }
+
+        int length = 0;
+        length = Math.min((str.length() - offset), len);
+        String newString = string_.substring(0, (int) pos - 1);
+        string_ = newString.concat(str.substring(offset, offset + length));
+        asciiStream_ = new java.io.StringBufferInputStream(string_);
+        unicodeStream_ = new java.io.StringBufferInputStream(string_);
+        characterStream_ = new java.io.StringReader(string_);
+        sqlLength_ = string_.length();
+        return length;
+    }
 
-    public java.io.Writer setCharacterStream (long pos) throws SqlException
-    {
+    public java.io.OutputStream setAsciiStream(long pos) throws SqlException {
         synchronized (agent_.connection_) {
-            if (agent_.loggingEnabled()) agent_.logWriter_.traceEntry (this, 
"setCharacterStream", (int) pos);
-            ClobWriter writer = new  ClobWriter (this,pos);
+            if (agent_.loggingEnabled()) {
+                agent_.logWriter_.traceEntry(this, "setAsciiStream", (int) 
pos);
+            }
+            ClobOutputStream outStream = new ClobOutputStream(this, pos);
+
+            if (agent_.loggingEnabled()) {
+                agent_.logWriter_.traceExit(this, "setAsciiStream", outStream);
+            }
+            return outStream;
+        }
+    }
 
-            if (agent_.loggingEnabled()) agent_.logWriter_.traceExit (this, 
"setCharacterStream", writer);
+    public java.io.Writer setCharacterStream(long pos) throws SqlException {
+        synchronized (agent_.connection_) {
+            if (agent_.loggingEnabled()) {
+                agent_.logWriter_.traceEntry(this, "setCharacterStream", (int) 
pos);
+            }
+            ClobWriter writer = new ClobWriter(this, pos);
+
+            if (agent_.loggingEnabled()) {
+                agent_.logWriter_.traceExit(this, "setCharacterStream", 
writer);
+            }
             return writer;
         }
-      }
+    }
 
-    public void truncate (long len) throws SqlException
-    {
+    public void truncate(long len) throws SqlException {
         synchronized (agent_.connection_) {
-            if (agent_.loggingEnabled()) agent_.logWriter_.traceEntry (this, " 
truncate", (int) len);
-            if (len < 0 || len > this.length())
-        throw new SqlException(agent_.logWriter_, "Invalid length " + len);
-            if (len == this.length())
-              return;
-            String newstr = string_.substring(0,(int)len);
+            if (agent_.loggingEnabled()) {
+                agent_.logWriter_.traceEntry(this, " truncate", (int) len);
+            }
+            if (len < 0 || len > this.length()) {
+                throw new SqlException(agent_.logWriter_, "Invalid length " + 
len);
+            }
+            if (len == this.length()) {
+                return;
+            }
+            String newstr = string_.substring(0, (int) len);
             string_ = newstr;
             asciiStream_ = new java.io.StringBufferInputStream(string_);
             unicodeStream_ = new java.io.StringBufferInputStream(string_);
@@ -379,104 +409,93 @@
         }
     }
 
-  //----------------------------helper 
methods----------------------------------
+    //----------------------------helper 
methods----------------------------------
+
+    public boolean isString() {
+        return ((dataType_ & STRING) == STRING);
+    }
+
+    public boolean isAsciiStream() {
+        return ((dataType_ & ASCII_STREAM) == ASCII_STREAM);
+    }
+
+    public boolean isCharacterStream() {
+        return ((dataType_ & CHARACTER_STREAM) == CHARACTER_STREAM);
+    }
+
+    public boolean isUnicodeStream() {
+        return ((dataType_ & UNICODE_STREAM) == UNICODE_STREAM);
+    }
 
-  public boolean isString ()
-  {
-    return ((dataType_ & STRING) == STRING);
-  }
-
-  public boolean isAsciiStream ()
-  {
-    return ((dataType_ & ASCII_STREAM) == ASCII_STREAM);
-  }
-
-  public boolean isCharacterStream ()
-  {
-    return ((dataType_ & CHARACTER_STREAM) == CHARACTER_STREAM);
-  }
-
-  public boolean isUnicodeStream ()
-  {
-    return ((dataType_ & UNICODE_STREAM) == UNICODE_STREAM);
-  }
-
-  public java.io.InputStream getUnicodeStream ()
-  {
-    return unicodeStream_;
-  }
-
-  public String getString ()
-  {
-    return string_;
-  }
-
-  public byte[] getUtf8String ()
-  {
-    return utf8String_;
-  }
-
-  // Return the length of the equivalent UTF-8 string
-  // precondition: string_ is not null and dataType_ includes STRING
-  public int getUTF8Length () throws SqlException
-  {
-    if (utf8String_ != null) return utf8String_.length;
-
-    try {
-      utf8String_ = string_.getBytes("UTF-8");
-      return utf8String_.length;
-    }
-    catch (java.io.UnsupportedEncodingException e) {
-      throw new SqlException (agent_.logWriter_, e.getMessage());
-    }
-  }
-
-  // auxiliary method for position (Clob, long)
-  protected Clob createClobWrapper (java.sql.Clob clob) throws SqlException
-  {
-    long length;
-    java.io.Reader rdr;
-
-    try {
-      length = clob.length();
-    }
-    catch (java.sql.SQLException e) {
-      throw new SqlException (agent_.logWriter_, e.getMessage());
-    }
-
-    if (length > java.lang.Integer.MAX_VALUE)
-      throw new SqlException (agent_.logWriter_, "searchstr Clob object is too 
large");
-
-    try {
-      rdr = clob.getCharacterStream ();
-    }
-    catch (java.sql.SQLException e) {
-      throw new SqlException (agent_.logWriter_, e.getMessage());
-    }
-
-    return new Clob (this.agent_, rdr, (int)length);
-  }
-
-  public void convertFromAsciiToCharacterStream () throws SqlException
-  {
-    try {
-      characterStream_ =
-        new java.io.InputStreamReader(asciiStream_, "US-ASCII");
-      dataType_ = CHARACTER_STREAM;
-    }
-    catch (java.io.UnsupportedEncodingException e) {
-      throw new SqlException (agent_.logWriter_, e.getMessage());
-    }
-  }
-
-  // this method is primarily for mixed clob length calculations.
-  // it was introduced to prevent recursion in the actual char length 
calculation
-  public long getByteLength () throws SqlException
-  {
-    if (lengthObtained_ == true)
-      return lengthInBytes_;
-
-    length();
-    return lengthInBytes_;
-  }
+    public java.io.InputStream getUnicodeStream() {
+        return unicodeStream_;
+    }
+
+    public String getString() {
+        return string_;
+    }
+
+    public byte[] getUtf8String() {
+        return utf8String_;
+    }
+
+    // Return the length of the equivalent UTF-8 string
+    // precondition: string_ is not null and dataType_ includes STRING
+    public int getUTF8Length() throws SqlException {
+        if (utf8String_ != null) {
+            return utf8String_.length;
+        }
+
+        try {
+            utf8String_ = string_.getBytes("UTF-8");
+            return utf8String_.length;
+        } catch (java.io.UnsupportedEncodingException e) {
+            throw new SqlException(agent_.logWriter_, e.getMessage());
+        }
+    }
+
+    // auxiliary method for position (Clob, long)
+    protected Clob createClobWrapper(java.sql.Clob clob) throws SqlException {
+        long length;
+        java.io.Reader rdr;
+
+        try {
+            length = clob.length();
+        } catch (java.sql.SQLException e) {
+            throw new SqlException(agent_.logWriter_, e.getMessage());
+        }
+
+        if (length > java.lang.Integer.MAX_VALUE) {
+            throw new SqlException(agent_.logWriter_, "searchstr Clob object 
is too large");
+        }
+
+        try {
+            rdr = clob.getCharacterStream();
+        } catch (java.sql.SQLException e) {
+            throw new SqlException(agent_.logWriter_, e.getMessage());
+        }
+
+        return new Clob(this.agent_, rdr, (int) length);
+    }
+
+    public void convertFromAsciiToCharacterStream() throws SqlException {
+        try {
+            characterStream_ =
+                    new java.io.InputStreamReader(asciiStream_, "US-ASCII");
+            dataType_ = CHARACTER_STREAM;
+        } catch (java.io.UnsupportedEncodingException e) {
+            throw new SqlException(agent_.logWriter_, e.getMessage());
+        }
+    }
+
+    // this method is primarily for mixed clob length calculations.
+    // it was introduced to prevent recursion in the actual char length 
calculation
+    public long getByteLength() throws SqlException {
+        if (lengthObtained_ == true) {
+            return lengthInBytes_;
+        }
+
+        length();
+        return lengthInBytes_;
+    }
 }

Modified: 
incubator/derby/code/trunk/java/client/org/apache/derby/client/am/ClobOutputStream.java
URL: 
http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/client/org/apache/derby/client/am/ClobOutputStream.java?rev=165585&r1=165584&r2=165585&view=diff
==============================================================================
--- 
incubator/derby/code/trunk/java/client/org/apache/derby/client/am/ClobOutputStream.java
 (original)
+++ 
incubator/derby/code/trunk/java/client/org/apache/derby/client/am/ClobOutputStream.java
 Sun May  1 23:25:59 2005
@@ -21,52 +21,47 @@
 package org.apache.derby.client.am;
 
 
-public class ClobOutputStream extends java.io.OutputStream
-{
-  private Clob clob_;
-  private long offset_;
+public class ClobOutputStream extends java.io.OutputStream {
+    private Clob clob_;
+    private long offset_;
 
-  public ClobOutputStream (Clob clob, long offset) throws SqlException
-  {
-    clob_ = clob;
-    offset_ = offset;
-    if (offset_ > clob_.sqlLength_)
-      throw new IndexOutOfBoundsException();
-  }
+    public ClobOutputStream(Clob clob, long offset) throws SqlException {
+        clob_ = clob;
+        offset_ = offset;
+        if (offset_ > clob_.sqlLength_) {
+            throw new IndexOutOfBoundsException();
+        }
+    }
 
-  public void write (int b) throws java.io.IOException
-  {
-    clob_.string_ = clob_.string_.substring(0, (int)offset_ - 1);
-    clob_.string_ = clob_.string_.concat("" + b + "");
-    clob_.asciiStream_ = new java.io.StringBufferInputStream(clob_.string_);
-    clob_.unicodeStream_ = new java.io.StringBufferInputStream(clob_.string_);
-    clob_. characterStream_ = new java.io.StringReader(clob_.string_);
-    clob_.sqlLength_ = clob_.string_.length();
-  }
+    public void write(int b) throws java.io.IOException {
+        clob_.string_ = clob_.string_.substring(0, (int) offset_ - 1);
+        clob_.string_ = clob_.string_.concat("" + b + "");
+        clob_.asciiStream_ = new 
java.io.StringBufferInputStream(clob_.string_);
+        clob_.unicodeStream_ = new 
java.io.StringBufferInputStream(clob_.string_);
+        clob_.characterStream_ = new java.io.StringReader(clob_.string_);
+        clob_.sqlLength_ = clob_.string_.length();
+    }
 
 
-  public void write (byte b[], int off, int len) throws java.io.IOException
-  {
-    if (b == null) {
-        throw new NullPointerException();
-    }
-    else if ((off < 0) || (off > b.length) || (len < 0) ||
-               ((off + len) > b.length) || ((off + len) < 0)) {
-        throw new IndexOutOfBoundsException();
-    }
-    else if (len == 0) {
-        return;
-    }
+    public void write(byte b[], int off, int len) throws java.io.IOException {
+        if (b == null) {
+            throw new NullPointerException();
+        } else if ((off < 0) || (off > b.length) || (len < 0) ||
+                ((off + len) > b.length) || ((off + len) < 0)) {
+            throw new IndexOutOfBoundsException();
+        } else if (len == 0) {
+            return;
+        }
 
-    byte[] newByte = new byte[len];
-    System.arraycopy(b,off,newByte,0,len);
-    String str = new String (newByte);
-    clob_.string_ = clob_.string_.substring(0, (int)offset_ - 1);
-    clob_.string_ = clob_.string_.concat(str);
-    clob_.asciiStream_ = new java.io.StringBufferInputStream(clob_.string_);
-    clob_.unicodeStream_ = new java.io.StringBufferInputStream(clob_.string_);
-    clob_. characterStream_ = new java.io.StringReader(clob_.string_);
-    clob_.sqlLength_ = clob_.string_.length();
-  }
+        byte[] newByte = new byte[len];
+        System.arraycopy(b, off, newByte, 0, len);
+        String str = new String(newByte);
+        clob_.string_ = clob_.string_.substring(0, (int) offset_ - 1);
+        clob_.string_ = clob_.string_.concat(str);
+        clob_.asciiStream_ = new 
java.io.StringBufferInputStream(clob_.string_);
+        clob_.unicodeStream_ = new 
java.io.StringBufferInputStream(clob_.string_);
+        clob_.characterStream_ = new java.io.StringReader(clob_.string_);
+        clob_.sqlLength_ = clob_.string_.length();
+    }
 }
 

Modified: 
incubator/derby/code/trunk/java/client/org/apache/derby/client/am/ClobWriter.java
URL: 
http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/client/org/apache/derby/client/am/ClobWriter.java?rev=165585&r1=165584&r2=165585&view=diff
==============================================================================
--- 
incubator/derby/code/trunk/java/client/org/apache/derby/client/am/ClobWriter.java
 (original)
+++ 
incubator/derby/code/trunk/java/client/org/apache/derby/client/am/ClobWriter.java
 Sun May  1 23:25:59 2005
@@ -21,81 +21,78 @@
 package org.apache.derby.client.am;
 
 
-public class ClobWriter extends java.io.Writer
-{
-  private Clob clob_;
-  private long offset_;
-
-  public ClobWriter()
-  {}
-
-  public ClobWriter(Clob clob, long offset) throws SqlException
-  {
-    clob_ = clob;
-    offset_ = offset;
-
-    if (offset_ - 1 > clob_.sqlLength_)
-      throw new SqlException( clob_.agent_.logWriter_, "Invalid position: " + 
offset);
-  }
-
-  public void write (int c)
-  {
-    StringBuffer sb = new 
StringBuffer(clob_.string_.substring(0,(int)offset_-1));
-    sb.append(c);
-    clob_.string_ = sb.toString();
-    clob_.asciiStream_ = new java.io.StringBufferInputStream(clob_.string_);
-    clob_.unicodeStream_ = new java.io.StringBufferInputStream(clob_.string_);
-    clob_. characterStream_ = new java.io.StringReader(clob_.string_);
-    clob_.sqlLength_ = clob_.string_.length();
-    offset_ = clob_.sqlLength_ + 1;
-  }
-
-  public void write(char cbuf[], int off, int len)
-  {
-    if ((off < 0) || (off > cbuf.length) || (len < 0) ||
-        ((off + len) > cbuf.length) || ((off + len) < 0)) {
-        throw new IndexOutOfBoundsException();
-    }
-    else if (len == 0) {
-        return;
-    }
-    StringBuffer sb = new 
StringBuffer(clob_.string_.substring(0,(int)offset_-1));
-    sb.append(cbuf,off,len);
-    clob_.string_ = sb.toString();
-    clob_.asciiStream_ = new java.io.StringBufferInputStream(clob_.string_);
-    clob_.unicodeStream_ = new java.io.StringBufferInputStream(clob_.string_);
-    clob_. characterStream_ = new java.io.StringReader(clob_.string_);
-    clob_.sqlLength_ = clob_.string_.length();
-    offset_ = clob_.sqlLength_ + 1;
-  }
-
-
-  public void write (String str)
-  {
-    StringBuffer sb = new 
StringBuffer(clob_.string_.substring(0,(int)offset_-1));
-    sb.append(str);
-    clob_.string_ = sb.toString();
-    clob_.asciiStream_ = new java.io.StringBufferInputStream(clob_.string_);
-    clob_.unicodeStream_ = new java.io.StringBufferInputStream(clob_.string_);
-    clob_. characterStream_ = new java.io.StringReader(clob_.string_);
-    clob_.sqlLength_ = clob_.string_.length();
-    offset_ = clob_.sqlLength_ + 1;
-  }
-
-
-  public void write(String str, int off, int len)
-  {
-    StringBuffer sb = new 
StringBuffer(clob_.string_.substring(0,(int)offset_-1));
-    sb.append(str.substring(off, off + len));
-    clob_.string_ = sb.toString();
-    clob_.asciiStream_ = new java.io.StringBufferInputStream(clob_.string_);
-    clob_.unicodeStream_ = new java.io.StringBufferInputStream(clob_.string_);
-    clob_. characterStream_ = new java.io.StringReader(clob_.string_);
-    clob_.sqlLength_ = clob_.string_.length();
-    offset_ = clob_.sqlLength_ + 1;
-  }
+public class ClobWriter extends java.io.Writer {
+    private Clob clob_;
+    private long offset_;
 
-  public void flush() {}
-  public void close() throws java.io.IOException {}
+    public ClobWriter() {
+    }
+
+    public ClobWriter(Clob clob, long offset) throws SqlException {
+        clob_ = clob;
+        offset_ = offset;
+
+        if (offset_ - 1 > clob_.sqlLength_) {
+            throw new SqlException(clob_.agent_.logWriter_, "Invalid position: 
" + offset);
+        }
+    }
+
+    public void write(int c) {
+        StringBuffer sb = new StringBuffer(clob_.string_.substring(0, (int) 
offset_ - 1));
+        sb.append(c);
+        clob_.string_ = sb.toString();
+        clob_.asciiStream_ = new 
java.io.StringBufferInputStream(clob_.string_);
+        clob_.unicodeStream_ = new 
java.io.StringBufferInputStream(clob_.string_);
+        clob_.characterStream_ = new java.io.StringReader(clob_.string_);
+        clob_.sqlLength_ = clob_.string_.length();
+        offset_ = clob_.sqlLength_ + 1;
+    }
+
+    public void write(char cbuf[], int off, int len) {
+        if ((off < 0) || (off > cbuf.length) || (len < 0) ||
+                ((off + len) > cbuf.length) || ((off + len) < 0)) {
+            throw new IndexOutOfBoundsException();
+        } else if (len == 0) {
+            return;
+        }
+        StringBuffer sb = new StringBuffer(clob_.string_.substring(0, (int) 
offset_ - 1));
+        sb.append(cbuf, off, len);
+        clob_.string_ = sb.toString();
+        clob_.asciiStream_ = new 
java.io.StringBufferInputStream(clob_.string_);
+        clob_.unicodeStream_ = new 
java.io.StringBufferInputStream(clob_.string_);
+        clob_.characterStream_ = new java.io.StringReader(clob_.string_);
+        clob_.sqlLength_ = clob_.string_.length();
+        offset_ = clob_.sqlLength_ + 1;
+    }
+
+
+    public void write(String str) {
+        StringBuffer sb = new StringBuffer(clob_.string_.substring(0, (int) 
offset_ - 1));
+        sb.append(str);
+        clob_.string_ = sb.toString();
+        clob_.asciiStream_ = new 
java.io.StringBufferInputStream(clob_.string_);
+        clob_.unicodeStream_ = new 
java.io.StringBufferInputStream(clob_.string_);
+        clob_.characterStream_ = new java.io.StringReader(clob_.string_);
+        clob_.sqlLength_ = clob_.string_.length();
+        offset_ = clob_.sqlLength_ + 1;
+    }
+
+
+    public void write(String str, int off, int len) {
+        StringBuffer sb = new StringBuffer(clob_.string_.substring(0, (int) 
offset_ - 1));
+        sb.append(str.substring(off, off + len));
+        clob_.string_ = sb.toString();
+        clob_.asciiStream_ = new 
java.io.StringBufferInputStream(clob_.string_);
+        clob_.unicodeStream_ = new 
java.io.StringBufferInputStream(clob_.string_);
+        clob_.characterStream_ = new java.io.StringReader(clob_.string_);
+        clob_.sqlLength_ = clob_.string_.length();
+        offset_ = clob_.sqlLength_ + 1;
+    }
+
+    public void flush() {
+    }
+
+    public void close() throws java.io.IOException {
+    }
 }
 


Reply via email to