Elffuss BraidHub

kikocis/java-driver public

Amend javadocs to reflect method signature changes
Changeset87381d2d6aaed3d1bc3f9994d4de82e6006ee7b5d6deebb0361ab3acfbc2af14
AuthorAlexandre Dutra <alexandre.dutra@datastax.com> · 2016-07-27 12:04 +02:00
Committerolim7t <omichallat+github@gmail.com> · 2016-07-27 10:50 -07:00
Parents6795b189968d

Browse the files at this changeset

2 files changed

modified driver-core/src/main/java/com/datastax/driver/core/querybuilder/Insert.java +24 −13
@@ -94,7 +94,7 @@
9494 * @param name the name of the column to insert/update.
9595 * @param value the value to insert/update for {@code name}.
9696 * @return this INSERT statement.
97- * @throws IllegalStateException if this method is called and the {@link #json(String)}
97+ * @throws IllegalStateException if this method is called and the {@link #json(Object)}
9898 * method has been called before, because it's not possible
9999 * to mix {@code INSERT JSON} syntax with regular {@code INSERT} syntax.
100100 */
@@ -118,7 +118,7 @@
118118 * in {@code names}.
119119 * @return this INSERT statement.
120120 * @throws IllegalArgumentException if {@code names.length != values.length}.
121- * @throws IllegalStateException if this method is called and the {@link #json(String)}
121+ * @throws IllegalStateException if this method is called and the {@link #json(Object)}
122122 * method has been called before, because it's not possible
123123 * to mix {@code INSERT JSON} syntax with regular {@code INSERT} syntax.
124124 */
@@ -135,7 +135,7 @@
135135 * in {@code names}.
136136 * @return this INSERT statement.
137137 * @throws IllegalArgumentException if {@code names.size() != values.size()}.
138- * @throws IllegalStateException if this method is called and the {@link #json(String)}
138+ * @throws IllegalStateException if this method is called and the {@link #json(Object)}
139139 * method has been called before, because it's not possible
140140 * to mix {@code INSERT JSON} syntax with regular {@code INSERT} syntax.
141141 */
@@ -156,20 +156,30 @@
156156 }
157157
158158 /**
159- * Inserts the provided JSON string, using the {@code INSERT INTO ... JSON} syntax introduced
159+ * Inserts the provided object, using the {@code INSERT INTO ... JSON} syntax introduced
160160 * in Cassandra 2.2.
161161 * <p/>
162- * With INSERT statements, the new {@code JSON} keyword can be used to enable inserting a
163- * JSON encoded map as a single row.
162+ * With INSERT statements, the new {@code JSON} keyword can be used to enable inserting a JSON
163+ * structure as a single row.
164164 * <p/>
165- * <strong>The provided JSON string will be appended to the query string as is.
166- * It should NOT be surrounded by single quotes.</strong>
165+ * The provided object can be of the following types:
166+ * <ol>
167+ * <li>A raw string. In this case, it will be appended to the query string as is.
168+ * <strong>It should NOT be surrounded by single quotes.</strong>
167169 * Its format should generally match that returned by a
168170 * {@code SELECT JSON} statement on the same table.
169- * <p/>
170- * Note that it is not possible to insert function calls nor bind markers in the JSON string.
171+ * Note that it is not possible to insert function calls nor bind markers in a JSON string.</li>
172+ * <li>A {@link QueryBuilder#bindMarker() bind marker}. In this case, the statement is meant to be prepared
173+ * and no JSON string will be appended to the query string, only a bind marker for the whole JSON parameter.</li>
174+ * <li>Any object that can be serialized to JSON. Such objects can be used provided that
175+ * a matching {@link com.datastax.driver.core.TypeCodec codec} is registered with the
176+ * {@link CodecRegistry} in use. This allows the usage of JSON libraries, such
177+ * as the <a href="https://jcp.org/en/jsr/detail?id=353">Java API for JSON processing</a>,
178+ * the popular <a href="http://wiki.fasterxml.com/JacksonHome">Jackson</a> library, or
179+ * Google's <a href="https://github.com/google/gson">Gson</a> library, for instance.</li>
180+ * </ol>
171181 * <h3>Case-sensitive column names</h3>
172- * Users are required to handle case-sensitive column names
182+ * When passing raw strings to this method, users are required to handle case-sensitive column names
173183 * by surrounding them with double quotes.
174184 * <p/>
175185 * For example, to insert into a table with two columns named “myKey” and “value”,
@@ -182,7 +192,8 @@
182192 * INSERT INTO mytable JSON '{"\"myKey\"": 0, "value": 0}';
183193 * </pre>
184194 * <h3>Escaping quotes in column values</h3>
185- * Double quotes should be escaped with a backslash, but single quotes should be escaped in
195+ * When passing raw strings to this method, double quotes should be escaped with a backslash,
196+ * but single quotes should be escaped in
186197 * the CQL manner, i.e. by another single quote. For example, the column value
187198 * {@code foo"'bar} should be inserted in the JSON string
188199 * as {@code "foo\"''bar"}.
@@ -191,7 +202,7 @@
191202 * Any columns which are omitted from the JSON string will be defaulted to a {@code NULL} value
192203 * (which will result in a tombstone being created).
193204 *
194- * @param json the JSON string, or a bind marker.
205+ * @param json the JSON string, or a bind marker, or a JSON object handled by a specific {@link com.datastax.driver.core.TypeCodec codec}.
195206 * @return this INSERT statement.
196207 * @throws IllegalStateException if this method is called and any of the {@code value} or {@code values}
197208 * methods have been called before, because it's not possible
modified driver-core/src/main/java/com/datastax/driver/core/querybuilder/QueryBuilder.java +24 −8
@@ -1057,23 +1057,39 @@
10571057 * Support for JSON functions has been added in Cassandra 2.2.
10581058 * The {@code fromJson()} function is similar to {@code INSERT JSON} statements,
10591059 * but applies to a single column value instead of the entire row, and
1060- * converts a JSON-encoded string into the normal Cassandra column value.
1060+ * converts a JSON object into the normal Cassandra column value.
10611061 * <p/>
10621062 * It may be used in {@code INSERT} and {@code UPDATE} statements,
10631063 * but NOT in the selection clause of a {@code SELECT} statement.
10641064 * <p/>
1065- * <strong>The provided JSON string will be appended to the query string as is.
1066- * It should NOT be surrounded by single quotes.</strong>
1065+ * The provided object can be of the following types:
1066+ * <ol>
1067+ * <li>A raw string. In this case, it will be appended to the query string as is.
1068+ * <strong>It should NOT be surrounded by single quotes.</strong>
1069+ * Its format should generally match that returned by a
1070+ * {@code SELECT JSON} statement on the same table.
1071+ * Note that it is not possible to insert function calls nor bind markers in a JSON string.</li>
1072+ * <li>A {@link QueryBuilder#bindMarker() bind marker}. In this case, the statement is meant to be prepared
1073+ * and no JSON string will be appended to the query string, only a bind marker for the whole JSON parameter.</li>
1074+ * <li>Any object that can be serialized to JSON. Such objects can be used provided that
1075+ * a matching {@link com.datastax.driver.core.TypeCodec codec} is registered with the
1076+ * {@link com.datastax.driver.core.CodecRegistry CodecRegistry} in use. This allows the usage of JSON libraries, such
1077+ * as the <a href="https://jcp.org/en/jsr/detail?id=353">Java API for JSON processing</a>,
1078+ * the popular <a href="http://wiki.fasterxml.com/JacksonHome">Jackson</a> library, or
1079+ * Google's <a href="https://github.com/google/gson">Gson</a> library, for instance.</li>
1080+ * </ol>
10671081 * <p/>
1068- * String values should be enclosed in double quotes.
1069- * Double quotes appearing inside strings should be escaped with a backslash,
1082+ * When passing raw strings to this method, the following rules apply:
1083+ * <ol>
1084+ * <li>String values should be enclosed in double quotes.</li>
1085+ * <li>Double quotes appearing inside strings should be escaped with a backslash,
10701086 * but single quotes should be escaped in
10711087 * the CQL manner, i.e. by another single quote. For example, the column value
10721088 * {@code foo"'bar} should be inserted in the JSON string
1073- * as {@code "foo\"''bar"}.
1074- * <p/>
1075- * Note that it is not possible to insert function calls nor bind markers in the JSON string.
1089+ * as {@code "foo\"''bar"}.</li>
1090+ * </ol>
10761091 *
1092+ * @param json the JSON string, or a bind marker, or a JSON object handled by a specific {@link com.datastax.driver.core.TypeCodec codec}.
10771093 * @return the function call.
10781094 * @see <a href="http://cassandra.apache.org/doc/cql3/CQL-2.2.html#json">JSON Support for CQL</a>
10791095 * @see <a href="http://www.datastax.com/dev/blog/whats-new-in-cassandra-2-2-json-support">JSON Support in Cassandra 2.2</a>