Mercurial > hg > monetdb-java
annotate src/main/java/org/monetdb/jdbc/MonetClob.java @ 391:f523727db392
Moved Java classes from packages starting with nl.cwi.monetdb.* to package org.monetdb.*
This naming complies to the Java Package Naming convention as MonetDB's main website is www.monetdb.org.
author | Martin van Dinther <martin.van.dinther@monetdbsolutions.com> |
---|---|
date | Thu, 12 Nov 2020 22:02:01 +0100 (2020-11-12) |
parents | src/main/java/nl/cwi/monetdb/jdbc/MonetClob.java@54137aeb1f92 |
children | bf9f6b6ecf40 |
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 * |
350
54137aeb1f92
Update Copyright year.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
327
diff
changeset
|
6 * Copyright 1997 - July 2008 CWI, August 2008 - 2020 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 /** |
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
|
19 * 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
|
20 * |
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 * Because MonetDB/SQL currently has no support for streams, this class is a |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
22 * shallow wrapper of a {@link StringBuilder}. It is more or less supplied to |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
23 * enable an application that depends on it to run. It may be obvious |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
24 * 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
|
25 * 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
|
26 * <b>Use of this class is highly discouraged.</b> |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
27 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
28 * @author Fabian Groffen |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
29 */ |
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
|
30 public final class MonetClob implements Clob { |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
31 private StringBuilder buf; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
32 |
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
|
33 protected MonetClob(final String in) { |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
34 buf = new StringBuilder(in); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
35 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
36 |
147
ad0fe5b04fd4
Improve MonetClob implementatin.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
37 /* 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
|
38 private final void checkBufIsNotNull() throws SQLException { |
147
ad0fe5b04fd4
Improve MonetClob implementatin.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
39 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
|
40 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
|
41 } |
ad0fe5b04fd4
Improve MonetClob implementatin.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
42 |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
43 //== begin interface Clob |
147
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 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
46 * 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
|
47 * 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
|
48 * method is called. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
49 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
50 * 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
|
51 * 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
|
52 * 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
|
53 * as a no-op. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
54 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
55 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
56 public void free() { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
57 buf = null; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
58 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
59 |
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 * 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
|
62 * ascii stream. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
63 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
64 * @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
|
65 * @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
|
66 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
67 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
68 public InputStream getAsciiStream() throws SQLException { |
289
cce8a1803f68
Implemented method MonetClob.getAsciiStream()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
266
diff
changeset
|
69 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
|
70 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
|
71 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
72 |
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 * 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
|
75 * 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
|
76 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
77 * @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
|
78 * @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
|
79 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
80 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
81 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
|
82 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
|
83 return new StringReader(buf.toString()); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
84 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
85 |
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 * 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
|
88 * 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
|
89 * characters in length. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
90 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
91 * @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
|
92 * 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
|
93 * @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
|
94 * @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
|
95 * @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
|
96 * 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
|
97 * 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
|
98 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
99 @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
|
100 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
|
101 // 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
|
102 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
|
103 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
|
104 } |
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
|
105 // 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
|
106 return new StringReader(getSubString(pos, (int)length)); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
107 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
108 |
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 * 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
|
111 * 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
|
112 * 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
|
113 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
114 * @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
|
115 * extracted. The first character is at position 1. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
116 * @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
|
117 * @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
|
118 * 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
|
119 * @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
|
120 * 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
|
121 * 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
|
122 * @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
|
123 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
124 @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
|
125 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
|
126 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
|
127 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
|
128 // 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
|
129 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
|
130 } |
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
|
131 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
|
132 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
|
133 } |
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 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
|
135 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
|
136 } |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
137 try { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
138 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
|
139 } 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
|
140 throw new SQLException(e.getMessage(), "M1M05"); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
141 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
142 } |
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 * 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
|
146 * by this Clob object. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
147 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
148 * @return length of the CLOB in characters |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
149 * @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
|
150 * of the CLOB value |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
151 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
152 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
153 public long length() throws SQLException { |
147
ad0fe5b04fd4
Improve MonetClob implementatin.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
154 checkBufIsNotNull(); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
155 return (long)buf.length(); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
156 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
157 |
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 * 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
|
160 * 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
|
161 * begins at position start. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
162 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
163 * @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
|
164 * @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
|
165 * the first position is 1 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
166 * @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
|
167 * -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
|
168 * @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
|
169 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
170 @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
|
171 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
|
172 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
|
173 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
|
174 } |
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
|
175 // 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
|
176 return position(searchstr.toString(), start); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
177 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
178 |
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 * Retrieves the character position at which the specified |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
181 * 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
|
182 * 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
|
183 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
184 * @param searchstr the substring for which to search |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
185 * @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
|
186 * the first position is 1 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
187 * @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
|
188 * -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
|
189 * @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
|
190 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
191 @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
|
192 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
|
193 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
|
194 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
|
195 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
|
196 } |
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 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
|
198 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
|
199 } |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
200 return (long)(buf.indexOf(searchstr, (int)(start - 1))); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
201 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
202 |
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
|
203 /** |
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
|
204 * 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
|
205 * 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
|
206 * 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
|
207 * 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
|
208 * 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
|
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
|
210 * 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
|
211 * 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
|
212 * 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
|
213 * |
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 * @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
|
215 * @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
|
216 * @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
|
217 * @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
|
218 */ |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
219 @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
|
220 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
|
221 throw MonetWrapper.newSQLFeatureNotSupportedException("setAsciiStream"); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
222 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
223 |
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
|
224 /** |
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
|
225 * 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
|
226 * 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
|
227 * 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
|
228 * 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
|
229 * 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
|
230 * |
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 * 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
|
232 * 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
|
233 * 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
|
234 * |
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 * @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
|
236 * @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
|
237 * @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
|
238 * @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
|
239 */ |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
240 @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
|
241 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
|
242 throw MonetWrapper.newSQLFeatureNotSupportedException("setCharacterStream"); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
243 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
244 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
245 /** |
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
|
246 * 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
|
247 * 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
|
248 * 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
|
249 * 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
|
250 * |
289
cce8a1803f68
Implemented method MonetClob.getAsciiStream()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
266
diff
changeset
|
251 * @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
|
252 * @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
|
253 * @return the number of characters written |
289
cce8a1803f68
Implemented method MonetClob.getAsciiStream()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
266
diff
changeset
|
254 * @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
|
255 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
256 @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
|
257 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
|
258 // 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
|
259 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
|
260 return setString(pos, str, 0, len); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
261 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
262 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
263 /** |
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
|
264 * 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
|
265 * 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
|
266 * 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
|
267 * 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
|
268 * |
289
cce8a1803f68
Implemented method MonetClob.getAsciiStream()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
266
diff
changeset
|
269 * @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
|
270 * @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
|
271 * @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
|
272 * @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
|
273 * @return the number of characters written |
289
cce8a1803f68
Implemented method MonetClob.getAsciiStream()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
266
diff
changeset
|
274 * @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
|
275 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
276 @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
|
277 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
|
278 throws SQLException |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
279 { |
147
ad0fe5b04fd4
Improve MonetClob implementatin.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
280 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
|
281 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
|
282 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
|
283 } |
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 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
|
285 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
|
286 } |
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 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
|
288 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
|
289 } |
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 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
|
291 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
|
292 } |
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
|
293 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
|
294 // 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
|
295 buf.ensureCapacity((int) pos + len); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
296 } |
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
|
297 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
|
298 return len; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
299 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
300 |
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 * 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
|
303 * have a length of len characters. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
304 * |
289
cce8a1803f68
Implemented method MonetClob.getAsciiStream()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
266
diff
changeset
|
305 * @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
|
306 * @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
|
307 * 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
|
308 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
309 @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
|
310 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
|
311 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
|
312 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
|
313 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
|
314 } |
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
|
315 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
|
316 // 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
|
317 buf.trimToSize(); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
318 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
319 |
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
|
320 |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
321 /** |
289
cce8a1803f68
Implemented method MonetClob.getAsciiStream()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
266
diff
changeset
|
322 * Returns a String from this MonetClob buf. |
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 * @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
|
325 */ |
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
|
326 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
|
327 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
|
328 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
|
329 return buf.toString(); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
330 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
331 } |