Mercurial > hg > monetdb-java
annotate src/main/java/org/monetdb/jdbc/MonetClob.java @ 451:3dfcd06fd8ba
Correcting typos in documentation text. Also improved the readability of the generated javadoc documents.
author | Martin van Dinther <martin.van.dinther@monetdbsolutions.com> |
---|---|
date | Thu, 04 Mar 2021 18:57:51 +0100 (2021-03-04) |
parents | bf9f6b6ecf40 |
children | 6aa38e8c0f2d |
rev | line source |
---|---|
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1 /* |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2 * This Source Code Form is subject to the terms of the Mozilla Public |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
5 * |
406
bf9f6b6ecf40
Update Copyright year.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
391
diff
changeset
|
6 * Copyright 1997 - July 2008 CWI, August 2008 - 2021 MonetDB B.V. |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
7 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
8 |
391
f523727db392
Moved Java classes from packages starting with nl.cwi.monetdb.* to package org.monetdb.*
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
350
diff
changeset
|
9 package org.monetdb.jdbc; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
10 |
69
e092fa8d9ab7
Expand import java.*.* statements
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
0
diff
changeset
|
11 import java.io.InputStream; |
e092fa8d9ab7
Expand import java.*.* statements
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
0
diff
changeset
|
12 import java.io.Reader; |
149
1e49fc74dba4
Implemented methods getCharacterStream() and getCharacterStream(long pos, long length) in class MonetClob.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
147
diff
changeset
|
13 import java.io.StringReader; |
69
e092fa8d9ab7
Expand import java.*.* statements
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
0
diff
changeset
|
14 import java.sql.Clob; |
e092fa8d9ab7
Expand import java.*.* statements
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
0
diff
changeset
|
15 import java.sql.SQLException; |
266
eefa7f625673
Resolve javadoc errors:
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
262
diff
changeset
|
16 import java.sql.SQLFeatureNotSupportedException; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
17 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
18 /** |
451
3dfcd06fd8ba
Correcting typos in documentation text. Also improved the readability of the generated javadoc documents.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
406
diff
changeset
|
19 *<pre> |
209
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
20 * The MonetClob class implements the {@link java.sql.Clob} interface. |
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
21 * |
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
22 * Because MonetDB/SQL currently has no support for streams, this class is a |
451
3dfcd06fd8ba
Correcting typos in documentation text. Also improved the readability of the generated javadoc documents.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
406
diff
changeset
|
23 * shallow wrapper of a {@link StringBuilder}. It is more or less supplied to |
3dfcd06fd8ba
Correcting typos in documentation text. Also improved the readability of the generated javadoc documents.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
406
diff
changeset
|
24 * enable an application that depends on it to run. It may be obvious |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
25 * that it is a real resource expensive workaround that contradicts the |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
26 * sole reason for a Clob: avoidance of huge resource consumption. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
27 * <b>Use of this class is highly discouraged.</b> |
451
3dfcd06fd8ba
Correcting typos in documentation text. Also improved the readability of the generated javadoc documents.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
406
diff
changeset
|
28 *</pre> |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
29 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
30 * @author Fabian Groffen |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
31 */ |
209
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
32 public final class MonetClob implements Clob { |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
33 private StringBuilder buf; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
34 |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
289
diff
changeset
|
35 protected MonetClob(final String in) { |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
36 buf = new StringBuilder(in); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
37 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
38 |
147
ad0fe5b04fd4
Improve MonetClob implementatin.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
39 /* internal utility method */ |
316
d479475888e3
Replace StringBuilder methods sb.delete(0, sb.length()) with faster sb.setLength(0).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
295
diff
changeset
|
40 private final void checkBufIsNotNull() throws SQLException { |
147
ad0fe5b04fd4
Improve MonetClob implementatin.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
41 if (buf == null) |
149
1e49fc74dba4
Implemented methods getCharacterStream() and getCharacterStream(long pos, long length) in class MonetClob.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
147
diff
changeset
|
42 throw new SQLException("This MonetClob has been freed", "M1M20"); |
147
ad0fe5b04fd4
Improve MonetClob implementatin.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
43 } |
ad0fe5b04fd4
Improve MonetClob implementatin.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
44 |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
45 //== begin interface Clob |
147
ad0fe5b04fd4
Improve MonetClob implementatin.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
46 |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
47 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
48 * This method frees the Clob object and releases the resources the |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
49 * resources that it holds. The object is invalid once the free |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
50 * method is called. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
51 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
52 * After free has been called, any attempt to invoke a method other |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
53 * than free will result in a SQLException being thrown. If free is |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
54 * called multiple times, the subsequent calls to free are treated |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
55 * as a no-op. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
56 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
57 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
58 public void free() { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
59 buf = null; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
60 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
61 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
62 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
63 * Retrieves the CLOB value designated by this Clob object as an |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
64 * ascii stream. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
65 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
66 * @return a java.io.InputStream object containing the CLOB data |
209
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
67 * @throws SQLException - if there is an error accessing the CLOB value |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
68 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
69 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
70 public InputStream getAsciiStream() throws SQLException { |
289
cce8a1803f68
Implemented method MonetClob.getAsciiStream()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
266
diff
changeset
|
71 checkBufIsNotNull(); |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
289
diff
changeset
|
72 return new java.io.ByteArrayInputStream(buf.toString().getBytes()); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
73 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
74 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
75 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
76 * Retrieves the CLOB value designated by this Clob object as a |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
77 * java.io.Reader object (or as a stream of characters). |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
78 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
79 * @return a java.io.Reader object containing the CLOB data |
209
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
80 * @throws SQLException - if there is an error accessing the CLOB value |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
81 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
82 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
83 public Reader getCharacterStream() throws SQLException { |
149
1e49fc74dba4
Implemented methods getCharacterStream() and getCharacterStream(long pos, long length) in class MonetClob.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
147
diff
changeset
|
84 checkBufIsNotNull(); |
1e49fc74dba4
Implemented methods getCharacterStream() and getCharacterStream(long pos, long length) in class MonetClob.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
147
diff
changeset
|
85 return new StringReader(buf.toString()); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
86 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
87 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
88 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
89 * Returns a Reader object that contains a partial Clob value, |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
90 * starting with the character specified by pos, which is length |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
91 * characters in length. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
92 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
93 * @param pos the offset to the first character of the partial value |
289
cce8a1803f68
Implemented method MonetClob.getAsciiStream()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
266
diff
changeset
|
94 * to be retrieved. The first character in the Clob is at position 1. |
cce8a1803f68
Implemented method MonetClob.getAsciiStream()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
266
diff
changeset
|
95 * @param length the length in characters of the partial value to be retrieved. |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
96 * @return Reader through which the partial Clob value can be read. |
209
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
97 * @throws SQLException - if pos is less than 1 |
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
98 * or if pos is greater than the number of characters in the Clob |
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
99 * or if pos + length is greater than the number of characters in the Clob |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
100 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
101 @Override |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
289
diff
changeset
|
102 public Reader getCharacterStream(final long pos, final long length) throws SQLException { |
316
d479475888e3
Replace StringBuilder methods sb.delete(0, sb.length()) with faster sb.setLength(0).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
295
diff
changeset
|
103 // as length will be casted to int, check it for too big value first |
289
cce8a1803f68
Implemented method MonetClob.getAsciiStream()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
266
diff
changeset
|
104 if (length < 0 || length > Integer.MAX_VALUE) { |
209
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
105 throw new SQLException("Invalid length value: " + length, "M1M05"); |
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
106 } |
316
d479475888e3
Replace StringBuilder methods sb.delete(0, sb.length()) with faster sb.setLength(0).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
295
diff
changeset
|
107 // buf and input argument pos will be checked in method getSubString(long, int) |
149
1e49fc74dba4
Implemented methods getCharacterStream() and getCharacterStream(long pos, long length) in class MonetClob.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
147
diff
changeset
|
108 return new StringReader(getSubString(pos, (int)length)); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
109 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
110 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
111 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
112 * Retrieves a copy of the specified substring in the CLOB value |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
289
diff
changeset
|
113 * designated by this Clob object. The substring begins at |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
114 * position pos and has up to length consecutive characters. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
115 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
116 * @param pos the first character of the substring to be |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
117 * extracted. The first character is at position 1. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
118 * @param length the number of consecutive characters to be copied |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
119 * @return a String that is the specified substring in the |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
120 * CLOB value designated by this Clob object |
209
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
121 * @throws SQLException - if pos is less than 1 |
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
122 * or if pos is greater than the number of characters in the Clob |
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
123 * or if pos + length is greater than the number of characters in the Clob |
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
124 * @throws SQLException - if there is an error accessing the CLOB value |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
125 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
126 @Override |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
289
diff
changeset
|
127 public String getSubString(final long pos, final int length) throws SQLException { |
147
ad0fe5b04fd4
Improve MonetClob implementatin.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
128 checkBufIsNotNull(); |
327
ca6a4b02d418
Add optimisation for MonetClob.getSubString(pos, length) in case the whole string is requested.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
316
diff
changeset
|
129 if (pos == 1L && length == buf.length()) { |
ca6a4b02d418
Add optimisation for MonetClob.getSubString(pos, length) in case the whole string is requested.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
316
diff
changeset
|
130 // the whole string is requested |
ca6a4b02d418
Add optimisation for MonetClob.getSubString(pos, length) in case the whole string is requested.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
316
diff
changeset
|
131 return buf.toString(); |
ca6a4b02d418
Add optimisation for MonetClob.getSubString(pos, length) in case the whole string is requested.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
316
diff
changeset
|
132 } |
209
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
133 if (pos < 1 || pos > buf.length()) { |
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
134 throw new SQLException("Invalid pos value: " + pos, "M1M05"); |
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
135 } |
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
136 if (length < 0 || pos -1 + length > buf.length()) { |
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
137 throw new SQLException("Invalid length value: " + length, "M1M05"); |
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
138 } |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
139 try { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
140 return buf.substring((int)(pos - 1), (int)(pos - 1 + length)); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
141 } catch (IndexOutOfBoundsException e) { |
209
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
142 throw new SQLException(e.getMessage(), "M1M05"); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
143 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
144 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
145 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
146 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
147 * Retrieves the number of characters in the CLOB value designated |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
148 * by this Clob object. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
149 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
150 * @return length of the CLOB in characters |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
151 * @throws SQLException if there is an error accessing the length |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
152 * of the CLOB value |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
153 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
154 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
155 public long length() throws SQLException { |
147
ad0fe5b04fd4
Improve MonetClob implementatin.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
156 checkBufIsNotNull(); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
157 return (long)buf.length(); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
158 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
159 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
160 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
161 * Retrieves the character position at which the specified Clob |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
289
diff
changeset
|
162 * object searchstr appears in this Clob object. The search |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
163 * begins at position start. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
164 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
165 * @param searchstr the Clob object for which to search |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
166 * @param start the position at which to begin searching; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
167 * the first position is 1 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
168 * @return the position at which the Clob object appears or |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
169 * -1 if it is not present; the first position is 1 |
209
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
170 * @throws SQLException - if there is an error accessing the CLOB value |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
171 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
172 @Override |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
289
diff
changeset
|
173 public long position(final Clob searchstr, final long start) throws SQLException { |
209
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
174 if (searchstr == null) { |
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
175 throw new SQLException("Missing searchstr object", "M1M05"); |
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
176 } |
316
d479475888e3
Replace StringBuilder methods sb.delete(0, sb.length()) with faster sb.setLength(0).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
295
diff
changeset
|
177 // buf and input argument start will be checked in method position(String, long) |
209
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
178 return position(searchstr.toString(), start); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
179 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
180 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
181 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
182 * Retrieves the character position at which the specified |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
183 * substring searchstr appears in the SQL CLOB value represented |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
289
diff
changeset
|
184 * by this Clob object. The search begins at position start. |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
185 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
186 * @param searchstr the substring for which to search |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
187 * @param start the position at which to begin searching; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
188 * the first position is 1 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
189 * @return the position at which the substring appears or |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
190 * -1 if it is not present; the first position is 1 |
209
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
191 * @throws SQLException - if there is an error accessing the CLOB value |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
192 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
193 @Override |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
289
diff
changeset
|
194 public long position(final String searchstr, final long start) throws SQLException { |
147
ad0fe5b04fd4
Improve MonetClob implementatin.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
195 checkBufIsNotNull(); |
209
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
196 if (searchstr == null) { |
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
197 throw new SQLException("Missing searchstr object", "M1M05"); |
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
198 } |
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
199 if (start < 1 || start > buf.length()) { |
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
200 throw new SQLException("Invalid start value: " + start, "M1M05"); |
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
201 } |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
202 return (long)(buf.indexOf(searchstr, (int)(start - 1))); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
203 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
204 |
209
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
205 /** |
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
206 * Retrieves a stream to be used to write Ascii characters to the CLOB value that this |
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
207 * Clob object represents, starting at position pos. Characters written to the stream |
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
208 * will overwrite the existing characters in the Clob object starting at the position pos. |
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
209 * If the end of the Clob value is reached while writing characters to the stream, |
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
210 * then the length of the Clob value will be increased to accomodate the extra characters. |
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
211 * |
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
212 * Note: If the value specified for pos is greater then the length+1 of the CLOB value |
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
213 * then the behavior is undefined. Some JDBC drivers may throw a SQLException while |
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
214 * other drivers may support this operation. |
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
215 * |
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
216 * @param pos - the position at which to start writing to this CLOB object; The first position is 1 |
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
217 * @return the stream to which ASCII encoded characters can be written |
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
218 * @throws SQLException - if there is an error accessing the CLOB value or if pos is less than 1 |
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
219 * @throws SQLFeatureNotSupportedException - if the JDBC driver does not support this method |
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
220 */ |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
221 @Override |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
289
diff
changeset
|
222 public java.io.OutputStream setAsciiStream(final long pos) throws SQLException { |
262
2d62ca1f758b
Moved utility method newSQLFeatureNotSupportedException(String name) from MonetPreparedStatement.java and MonetResultSet.java
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
261
diff
changeset
|
223 throw MonetWrapper.newSQLFeatureNotSupportedException("setAsciiStream"); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
224 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
225 |
209
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
226 /** |
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
227 * Retrieves a stream to be used to write a stream of Unicode characters to the CLOB value that |
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
228 * this Clob object represents, starting at position pos. Characters written to the stream |
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
229 * will overwrite the existing characters in the Clob object starting at the position pos. |
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
230 * If the end of the Clob value is reached while writing characters to the stream, |
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
231 * then the length of the Clob value will be increased to accomodate the extra characters. |
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
232 * |
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
233 * Note: If the value specified for pos is greater then the length+1 of the CLOB value |
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
234 * then the behavior is undefined. Some JDBC drivers may throw a SQLException while |
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
235 * other drivers may support this operation. |
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
236 * |
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
237 * @param pos - the position at which to start writing to this CLOB object; The first position is 1 |
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
238 * @return the stream to which Unicode encoded characters can be written |
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
239 * @throws SQLException - if there is an error accessing the CLOB value or if pos is less than 1 |
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
240 * @throws SQLFeatureNotSupportedException - if the JDBC driver does not support this method |
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
241 */ |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
242 @Override |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
289
diff
changeset
|
243 public java.io.Writer setCharacterStream(final long pos) throws SQLException { |
262
2d62ca1f758b
Moved utility method newSQLFeatureNotSupportedException(String name) from MonetPreparedStatement.java and MonetResultSet.java
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
261
diff
changeset
|
244 throw MonetWrapper.newSQLFeatureNotSupportedException("setCharacterStream"); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
245 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
246 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
247 /** |
209
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
248 * Writes the given Java String to the CLOB value that this Clob object designates at the position pos. |
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
249 * The string will overwrite the existing characters in the Clob object starting at the position pos. |
289
cce8a1803f68
Implemented method MonetClob.getAsciiStream()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
266
diff
changeset
|
250 * If the end of the Clob value is reached while writing the given string, |
cce8a1803f68
Implemented method MonetClob.getAsciiStream()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
266
diff
changeset
|
251 * then the length of the Clob value will be increased to accomodate the extra characters. |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
252 * |
289
cce8a1803f68
Implemented method MonetClob.getAsciiStream()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
266
diff
changeset
|
253 * @param pos the position at which to start writing to the CLOB value that this Clob object represents |
cce8a1803f68
Implemented method MonetClob.getAsciiStream()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
266
diff
changeset
|
254 * @param str the string to be written to the CLOB value that this Clob designates |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
255 * @return the number of characters written |
289
cce8a1803f68
Implemented method MonetClob.getAsciiStream()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
266
diff
changeset
|
256 * @throws SQLException if there is an error accessing the CLOB value or if pos is less than 1 |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
257 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
258 @Override |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
289
diff
changeset
|
259 public int setString(final long pos, final String str) throws SQLException { |
316
d479475888e3
Replace StringBuilder methods sb.delete(0, sb.length()) with faster sb.setLength(0).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
295
diff
changeset
|
260 // buf and input arguments will be checked in method setString(long, String, int, int) |
d479475888e3
Replace StringBuilder methods sb.delete(0, sb.length()) with faster sb.setLength(0).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
295
diff
changeset
|
261 final int len = (str != null) ? str.length() : 0; |
d479475888e3
Replace StringBuilder methods sb.delete(0, sb.length()) with faster sb.setLength(0).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
295
diff
changeset
|
262 return setString(pos, str, 0, len); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
263 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
264 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
265 /** |
209
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
266 * Writes len characters of str, starting at character offset, to the CLOB value that this Clob represents. |
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
267 * The string will overwrite the existing characters in the Clob object starting at the position pos. |
289
cce8a1803f68
Implemented method MonetClob.getAsciiStream()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
266
diff
changeset
|
268 * If the end of the Clob value is reached while writing the given string, |
cce8a1803f68
Implemented method MonetClob.getAsciiStream()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
266
diff
changeset
|
269 * then the length of the Clob value will be increased to accomodate the extra characters. |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
270 * |
289
cce8a1803f68
Implemented method MonetClob.getAsciiStream()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
266
diff
changeset
|
271 * @param pos the position at which to start writing to this CLOB object |
cce8a1803f68
Implemented method MonetClob.getAsciiStream()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
266
diff
changeset
|
272 * @param str the string to be written to the CLOB value that this Clob object represents |
cce8a1803f68
Implemented method MonetClob.getAsciiStream()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
266
diff
changeset
|
273 * @param offset the offset into str to start reading the characters to be written |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
274 * @param len the number of characters to be written |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
275 * @return the number of characters written |
289
cce8a1803f68
Implemented method MonetClob.getAsciiStream()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
266
diff
changeset
|
276 * @throws SQLException if there is an error accessing the CLOB value or if pos is less than 1 |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
277 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
278 @Override |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
289
diff
changeset
|
279 public int setString(final long pos, final String str, final int offset, final int len) |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
280 throws SQLException |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
281 { |
147
ad0fe5b04fd4
Improve MonetClob implementatin.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
282 checkBufIsNotNull(); |
209
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
283 if (str == null) { |
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
284 throw new SQLException("Missing str object", "M1M05"); |
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
285 } |
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
286 if (pos < 1 || pos > Integer.MAX_VALUE) { |
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
287 throw new SQLException("Invalid pos value: " + pos, "M1M05"); |
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
288 } |
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
289 if (offset < 0 || offset > str.length()) { |
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
290 throw new SQLException("Invalid offset value: " + offset, "M1M05"); |
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
291 } |
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
292 if (len < 1 || (offset + len) > str.length()) { |
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
293 throw new SQLException("Invalid len value: " + len, "M1M05"); |
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
294 } |
316
d479475888e3
Replace StringBuilder methods sb.delete(0, sb.length()) with faster sb.setLength(0).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
295
diff
changeset
|
295 if (((int) pos + len) > buf.capacity()) { |
d479475888e3
Replace StringBuilder methods sb.delete(0, sb.length()) with faster sb.setLength(0).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
295
diff
changeset
|
296 // enlarge the buffer before filling it |
d479475888e3
Replace StringBuilder methods sb.delete(0, sb.length()) with faster sb.setLength(0).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
295
diff
changeset
|
297 buf.ensureCapacity((int) pos + len); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
298 } |
316
d479475888e3
Replace StringBuilder methods sb.delete(0, sb.length()) with faster sb.setLength(0).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
295
diff
changeset
|
299 buf.replace((int) pos - 1, (int) pos + len, str.substring(offset, (offset + len))); |
209
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
300 return len; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
301 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
302 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
303 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
304 * Truncates the CLOB value that this Clob designates to |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
305 * have a length of len characters. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
306 * |
289
cce8a1803f68
Implemented method MonetClob.getAsciiStream()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
266
diff
changeset
|
307 * @param len the length, in bytes, to which the CLOB value should be truncated |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
308 * @throws SQLException if there is an error accessing the |
209
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
309 * CLOB value or if len is less than 0 |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
310 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
311 @Override |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
289
diff
changeset
|
312 public void truncate(final long len) throws SQLException { |
147
ad0fe5b04fd4
Improve MonetClob implementatin.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
313 checkBufIsNotNull(); |
209
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
314 if (len < 0 || len > buf.length()) { |
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
315 throw new SQLException("Invalid len value: " + len, "M1M05"); |
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
316 } |
316
d479475888e3
Replace StringBuilder methods sb.delete(0, sb.length()) with faster sb.setLength(0).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
295
diff
changeset
|
317 buf.setLength((int)len); |
d479475888e3
Replace StringBuilder methods sb.delete(0, sb.length()) with faster sb.setLength(0).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
295
diff
changeset
|
318 // reduce storage used for the character sequence. |
289
cce8a1803f68
Implemented method MonetClob.getAsciiStream()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
266
diff
changeset
|
319 buf.trimToSize(); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
320 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
321 |
209
94131372ad0b
Improved implementation of MonetClob and MonetBlob classes by adding checks on validity of input parameters of methods of those classes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
322 |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
323 /** |
289
cce8a1803f68
Implemented method MonetClob.getAsciiStream()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
266
diff
changeset
|
324 * Returns a String from this MonetClob buf. |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
325 * |
289
cce8a1803f68
Implemented method MonetClob.getAsciiStream()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
266
diff
changeset
|
326 * @return the String this MonetClob wraps or empty string when this MonetClob was freed. |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
327 */ |
316
d479475888e3
Replace StringBuilder methods sb.delete(0, sb.length()) with faster sb.setLength(0).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
295
diff
changeset
|
328 public String toString() { |
d479475888e3
Replace StringBuilder methods sb.delete(0, sb.length()) with faster sb.setLength(0).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
295
diff
changeset
|
329 if (buf == null) |
d479475888e3
Replace StringBuilder methods sb.delete(0, sb.length()) with faster sb.setLength(0).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
295
diff
changeset
|
330 return ""; |
d479475888e3
Replace StringBuilder methods sb.delete(0, sb.length()) with faster sb.setLength(0).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
295
diff
changeset
|
331 return buf.toString(); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
332 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
333 } |