cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Vadim Gritsenko <va...@reverycodes.com>
Subject Re: svn commit: r464376 - in /cocoon/branches/BRANCH_2_1_X: src/blocks/databases/java/org/apache/cocoon/transformation/SQLTransformer.java status.xml
Date Mon, 16 Oct 2006 12:55:41 GMT
antonio@apache.org wrote:
> @@ -1533,14 +1659,21 @@
>              if (object instanceof Clob && this.clobEncoding != null) {
>                  Clob clob = (Clob) object;
>                  StringBuffer buffer = new StringBuffer();
> -                InputStream is = clob.getAsciiStream();
>                  try {
> -                    byte[] bytes = new byte[BUFFER_SIZE];
> -                    int n;
> -                    while ((n = is.read(bytes)) > -1) {
> -                        buffer.append(new String(bytes, 0, n, this.clobEncoding));
> -                    }
> -                } catch (IOException e) {
> +                   int blocksize = BUFFER_SIZE;
> +                   long length = clob.length();
> +                   long nMax = length / blocksize;
> +                   for (int n = 0; n < nMax; n++) {
> +                       String sText = clob.getSubString(n*blocksize+1, blocksize);
> +                       buffer.append( sText);
> +                   }
> +                   //Read the last block
> +                   int lastblocksize = (int)length%blocksize;
> +                   if (lastblocksize > 0) {
> +                       String sText = clob.getSubString(nMax*blocksize+1, lastblocksize);
> +                       buffer.append( sText);
> +                   }
> +                } catch (Exception e) {
>                      throw new SQLException("Error reading stream from CLOB");
>                  }
>                  return buffer.toString();

Antonio,

Please revert. This code was specifically present for the purpose of backward 
compatibility, as it is stated in the comment. Correctly functioning new code is 
in the very next if() statement, implemented via getCharacterStream.

Vadim

Mime
View raw message