JDBCClobClient.java (hsqldb-2.7.0) | : | JDBCClobClient.java (hsqldb-2.7.1) | ||
---|---|---|---|---|
skipping to change at line 54 | skipping to change at line 54 | |||
import org.hsqldb.error.ErrorCode; | import org.hsqldb.error.ErrorCode; | |||
import org.hsqldb.types.ClobDataID; | import org.hsqldb.types.ClobDataID; | |||
import org.hsqldb.types.ClobInputStream; | import org.hsqldb.types.ClobInputStream; | |||
/** | /** | |||
* A wrapper for HSQLDB ClobData objects. | * A wrapper for HSQLDB ClobData objects. | |||
* | * | |||
* Instances of this class are returned by calls to ResultSet methods. | * Instances of this class are returned by calls to ResultSet methods. | |||
* | * | |||
* @author Fred Toussi (fredt@users dot sourceforge.net) | * @author Fred Toussi (fredt@users dot sourceforge.net) | |||
* @version 2.7.0 | * @version 2.7.1 | |||
* @since HSQLDB 1.9.0 | * @since HSQLDB 1.9.0 | |||
*/ | */ | |||
public class JDBCClobClient implements Clob { | public class JDBCClobClient implements Clob { | |||
/** | /** | |||
* Retrieves the <code>CLOB</code> value designated by this | * Retrieves the <code>CLOB</code> value designated by this | |||
* <code>Clob</code> object as an ascii stream. | * <code>Clob</code> object as an ascii stream. | |||
* | * | |||
* The ascii stream consists of the low ordre bytes of UTF-16 characters | * The ascii stream consists of the low ordre bytes of UTF-16 characters | |||
* in the clob. The question mark character is returnd for UTF-16 characters | * in the clob. The question mark character is returnd for UTF-16 characters | |||
skipping to change at line 88 | skipping to change at line 88 | |||
private Reader reader = clob.getCharacterStream(session); | private Reader reader = clob.getCharacterStream(session); | |||
public int read() throws IOException { | public int read() throws IOException { | |||
int c = reader.read(); | int c = reader.read(); | |||
if (c < 0) { | if (c < 0) { | |||
return -1; | return -1; | |||
} | } | |||
return c < 256 ? c & 0xff | if (c >= 256) { | |||
: '?'; | if (Character.isHighSurrogate((char) c)) { | |||
reader.read(); | ||||
} | ||||
c = '?'; | ||||
} | ||||
return c; | ||||
} | } | |||
public int read(byte[] b, int off, int len) throws IOException { | public int read(byte[] b, int off, int len) throws IOException { | |||
if (b == null) { | if (b == null) { | |||
throw new NullPointerException(); | throw new NullPointerException(); | |||
} | } | |||
if (off < 0 || len < 0 || len > b.length - off) { | if (off < 0 || len < 0 || len > b.length - off) { | |||
throw new IndexOutOfBoundsException(); | throw new IndexOutOfBoundsException(); | |||
skipping to change at line 115 | skipping to change at line 122 | |||
int bytesRead = 0; | int bytesRead = 0; | |||
for (int i = 0; i < len; i++) { | for (int i = 0; i < len; i++) { | |||
int c = reader.read(); | int c = reader.read(); | |||
if (c < 0) { | if (c < 0) { | |||
break; | break; | |||
} | } | |||
if (c >= 256) { | ||||
if (Character.isHighSurrogate((char) c)) { | ||||
reader.read(); | ||||
} | ||||
c = '?'; | ||||
} | ||||
b[off + i] = (byte) c; | b[off + i] = (byte) c; | |||
bytesRead++; | bytesRead++; | |||
} | } | |||
return bytesRead; | return bytesRead == 0 ? -1 : bytesRead; | |||
} | } | |||
public void close() throws IOException { | public void close() throws IOException { | |||
try { | try { | |||
reader.close(); | reader.close(); | |||
} catch (Exception ex) {} | } catch (Exception ex) {} | |||
} | } | |||
}; | }; | |||
} | } | |||
End of changes. 4 change blocks. | ||||
4 lines changed or deleted | 19 lines changed or added |