kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | ef959426af64fa6a568ffbe9df9aa816688c7a9a554bd0d3055b2fc43b3fef98 |
|---|---|
| Author | Alexandre Dutra <alexandre.dutra@datastax.com> · 2015-11-18 13:38 +01:00 |
| Committer | Alexandre Dutra <alexandre.dutra@datastax.com> · 2015-11-18 16:24 +01:00 |
| Parents | 60d95e2391dc |
19 files changed
modified driver-extras/src/main/java/com/datastax/driver/extras/codecs/MappingCodec.java +3 −3
| @@ -24,19 +24,19 @@ | ||
| 24 | 24 | import com.datastax.driver.core.exceptions.InvalidTypeException; |
| 25 | 25 | |
| 26 | 26 | /** |
| 27 | - * An abstract TypeCodec that maps a Java Pojo to another Java object | |
| 27 | + * An abstract {@link TypeCodec} that maps a Java Pojo to another Java object | |
| 28 | 28 | * that can in turn be serialized into a CQL type. |
| 29 | 29 | * This can serve as a base for libraries dealing with Pojo mappings. |
| 30 | 30 | * <p> |
| 31 | 31 | * This codec can be seen as a convenience base class for libraries |
| 32 | 32 | * dealing with Pojo-to-Pojo mappings, but it comes |
| 33 | 33 | * with a performance penalty: each Java object is serialized |
| 34 | - * in two steps: first to an intermediary object, and then to a ByteBuffer, | |
| 34 | + * in two steps: first to an intermediate object, and then to a {@link ByteBuffer}, | |
| 35 | 35 | * which means that each serialization actually incurs in two potentially |
| 36 | 36 | * expensive operations being carried. |
| 37 | 37 | * <p> |
| 38 | 38 | * If such operations are really expensive, and your mapping library is capable |
| 39 | - * of serializing objects directly to ByteBuffers, | |
| 39 | + * of serializing objects directly to {@link ByteBuffer}s, | |
| 40 | 40 | * consider writing your own codec instead of using this one. |
| 41 | 41 | * |
| 42 | 42 | * @param <O> The "outer" (user-facing) Java type |
modified driver-extras/src/main/java/com/datastax/driver/extras/codecs/ParsingCodec.java +3 −3
| @@ -24,18 +24,18 @@ | ||
| 24 | 24 | import com.datastax.driver.core.exceptions.InvalidTypeException; |
| 25 | 25 | |
| 26 | 26 | /** |
| 27 | - * An abstract TypeCodec that stores JAVA objects as serialized strings. | |
| 27 | + * An abstract {@link TypeCodec} that stores JAVA objects as serialized strings. | |
| 28 | 28 | * This can serve as a base for codecs dealing with XML or JSON formats. |
| 29 | 29 | * <p> |
| 30 | 30 | * This codec can be seen as a convenience base class to help |
| 31 | 31 | * implementing Java-to-XML or Java-to-JSON mappings, but it comes |
| 32 | 32 | * with a performance penalty: each Java object is serialized |
| 33 | - * in two steps: first to a String, and then to a ByteBuffer, | |
| 33 | + * in two steps: first to a String, and then to a {@link ByteBuffer}, | |
| 34 | 34 | * which means that each serialization actually incurs in two potentially |
| 35 | 35 | * expensive operations being carried. |
| 36 | 36 | * <p> |
| 37 | 37 | * If you are using an XML or JSON library that supports writing Java objects |
| 38 | - * directly to ByteBuffers, consider writing your own codec instead of | |
| 38 | + * directly to {@link ByteBuffer}s, consider writing your own codec instead of | |
| 39 | 39 | * using this one. |
| 40 | 40 | * |
| 41 | 41 | * @param <T> The Java type this codec serializes from and deserializes to. |
modified driver-extras/src/main/java/com/datastax/driver/extras/codecs/arrays/package-info.java +0 −35
| @@ -18,40 +18,5 @@ | ||
| 18 | 18 | * This package contains a collection of convenience |
| 19 | 19 | * {@link com.datastax.driver.core.TypeCodec TypeCodec} instances useful for |
| 20 | 20 | * serializing between CQL lists and Java arrays. |
| 21 | - * <p> | |
| 22 | - * The codecs in this package provide the following mappings: | |
| 23 | - * | |
| 24 | - * <table summary="Supported Mappings"> | |
| 25 | - * <tr> | |
| 26 | - * <th>Codec</th> | |
| 27 | - * <th>CQL type</th> | |
| 28 | - * <th>Java type</th> | |
| 29 | - * </tr> | |
| 30 | - * <tr> | |
| 31 | - * <td>{@link com.datastax.driver.extras.codecs.arrays.ObjectArrayCodec}</td> | |
| 32 | - * <td>{@code list<?>}</td> | |
| 33 | - * <td>{@code T[]}</td> | |
| 34 | - * </tr> | |
| 35 | - * <tr> | |
| 36 | - * <td>{@link com.datastax.driver.extras.codecs.arrays.IntArrayCodec}</td> | |
| 37 | - * <td>{@code list<int>}</td> | |
| 38 | - * <td>{@code int[]}</td> | |
| 39 | - * </tr> | |
| 40 | - * <tr> | |
| 41 | - * <td>{@link com.datastax.driver.extras.codecs.arrays.LongArrayCodec}</td> | |
| 42 | - * <td>{@code list<long>}</td> | |
| 43 | - * <td>{@code long[]}</td> | |
| 44 | - * </tr> | |
| 45 | - * <tr> | |
| 46 | - * <td>{@link com.datastax.driver.extras.codecs.arrays.FloatArrayCodec}</td> | |
| 47 | - * <td>{@code list<float>}</td> | |
| 48 | - * <td>{@code float[]}</td> | |
| 49 | - * </tr> | |
| 50 | - * <tr> | |
| 51 | - * <td>{@link com.datastax.driver.extras.codecs.arrays.DoubleArrayCodec}</td> | |
| 52 | - * <td>{@code list<double>}</td> | |
| 53 | - * <td>{@code double[]}</td> | |
| 54 | - * </tr> | |
| 55 | - * </table> | |
| 56 | 21 | */ |
| 57 | 22 | package com.datastax.driver.extras.codecs.arrays; |
modified driver-extras/src/main/java/com/datastax/driver/extras/codecs/date/package-info.java +1 −21
| @@ -16,27 +16,7 @@ | ||
| 16 | 16 | |
| 17 | 17 | /** |
| 18 | 18 | * This package contains a collection of convenience |
| 19 | - * {@link com.datastax.driver.core.TypeCodec} instances useful for | |
| 19 | + * {@link com.datastax.driver.core.TypeCodec TypeCodec} instances useful for | |
| 20 | 20 | * serializing between CQL temporal types and Java primitive types. |
| 21 | - * <p> | |
| 22 | - * The codecs in this class provide the following mappings: | |
| 23 | - * | |
| 24 | - * <table summary="Supported Mappings"> | |
| 25 | - * <tr> | |
| 26 | - * <th>Codec</th> | |
| 27 | - * <th>CQL type</th> | |
| 28 | - * <th>Java type</th> | |
| 29 | - * </tr> | |
| 30 | - * <tr> | |
| 31 | - * <td>{@link com.datastax.driver.extras.codecs.date.SimpleTimestampCodec}</td> | |
| 32 | - * <td>{@link com.datastax.driver.core.DataType#timestamp() timestamp}</td> | |
| 33 | - * <td>{@code long} (representing milliseconds since the Epoch)</td> | |
| 34 | - * </tr> | |
| 35 | - * <tr> | |
| 36 | - * <td>{@link com.datastax.driver.extras.codecs.date.SimpleDateCodec}</td> | |
| 37 | - * <td>{@link com.datastax.driver.core.DataType#date() date}</td> | |
| 38 | - * <td>{@code int} (representing days since the Epoch)</td> | |
| 39 | - * </tr> | |
| 40 | - * </table> | |
| 41 | 21 | */ |
| 42 | 22 | package com.datastax.driver.extras.codecs.date; |
modified driver-extras/src/main/java/com/datastax/driver/extras/codecs/guava/package-info.java +0 −3
| @@ -18,8 +18,5 @@ | ||
| 18 | 18 | * This package contains a collection of convenience |
| 19 | 19 | * {@link com.datastax.driver.core.TypeCodec TypeCodec} instances useful for |
| 20 | 20 | * serializing between CQL types and Guava-specific Java types. |
| 21 | - * | |
| 22 | - * Currently only {@link com.datastax.driver.extras.codecs.guava.OptionalCodec OptionalCodec} | |
| 23 | - * is provided. | |
| 24 | 21 | */ |
| 25 | 22 | package com.datastax.driver.extras.codecs.guava; |
modified driver-extras/src/main/java/com/datastax/driver/extras/codecs/jdk8/InstantCodec.java +4 −3
| @@ -42,8 +42,8 @@ | ||
| 42 | 42 | |
| 43 | 43 | /** |
| 44 | 44 | * <p> |
| 45 | - * {@link TypeCodec} that maps {@link Instant} <-> {@link Date} | |
| 46 | - * allowing the setting and retrieval of <code>timestamp</code> | |
| 45 | + * {@link TypeCodec} that maps {@link Instant} to CQL {@code timestamp} | |
| 46 | + * allowing the setting and retrieval of {@code timestamp} | |
| 47 | 47 | * columns as {@link Instant} instances. |
| 48 | 48 | * </p> |
| 49 | 49 | * |
| @@ -53,7 +53,8 @@ | ||
| 53 | 53 | * </p> |
| 54 | 54 | * |
| 55 | 55 | * @see ZonedDateTimeCodec |
| 56 | - * @see "https://cassandra.apache.org/doc/cql3/CQL-2.2.html#usingtimestamps" | |
| 56 | + * @see <a href="https://cassandra.apache.org/doc/cql3/CQL-2.2.html#usingtimestamps">Working with timestamps</a> | |
| 57 | + * section of CQL specification. | |
| 57 | 58 | */ |
| 58 | 59 | public class InstantCodec extends TypeCodec<Instant> { |
| 59 | 60 |
modified driver-extras/src/main/java/com/datastax/driver/extras/codecs/jdk8/LocalDateCodec.java +1 −1
| @@ -35,7 +35,7 @@ | ||
| 35 | 35 | |
| 36 | 36 | /** |
| 37 | 37 | * {@link TypeCodec} that maps |
| 38 | - * {@link java.time.LocalDate} to CQL <code>date</code> columns. | |
| 38 | + * {@link java.time.LocalDate} to CQL {@code date}. | |
| 39 | 39 | */ |
| 40 | 40 | public class LocalDateCodec extends TypeCodec<LocalDate> { |
| 41 | 41 |
modified driver-extras/src/main/java/com/datastax/driver/extras/codecs/jdk8/LocalTimeCodec.java +1 −3
| @@ -28,9 +28,7 @@ | ||
| 28 | 28 | import static com.datastax.driver.core.ParseUtils.quote; |
| 29 | 29 | |
| 30 | 30 | /** |
| 31 | - * {@link TypeCodec} that maps {@link LocalTime} <-> CQL time (long representing nanoseconds since midnight) | |
| 32 | - * allowing the setting and retrieval of <code>time</code> columns as {@link LocalTime} | |
| 33 | - * instances. | |
| 31 | + * {@link TypeCodec} that maps {@link LocalTime} to CQL {@code time} (long representing nanoseconds since midnight). | |
| 34 | 32 | */ |
| 35 | 33 | public class LocalTimeCodec extends TypeCodec<LocalTime> { |
| 36 | 34 |
modified driver-extras/src/main/java/com/datastax/driver/extras/codecs/jdk8/ZonedDateTimeCodec.java +4 −1
| @@ -41,7 +41,7 @@ | ||
| 41 | 41 | /** |
| 42 | 42 | * <p> |
| 43 | 43 | * {@link TypeCodec} that maps |
| 44 | - * {@link ZonedDateTime} <-> <code>tuple<timestamp,varchar></code> | |
| 44 | + * {@link ZonedDateTime} to CQL {@code tuple<timestamp,varchar>}, | |
| 45 | 45 | * providing a pattern for maintaining timezone information in |
| 46 | 46 | * Cassandra. |
| 47 | 47 | * |
| @@ -53,6 +53,9 @@ | ||
| 53 | 53 | * persisted in the <code>varchar</code> field such that when the |
| 54 | 54 | * value is deserialized the timezone is |
| 55 | 55 | * preserved. |
| 56 | + * | |
| 57 | + * @see <a href="https://cassandra.apache.org/doc/cql3/CQL-2.2.html#usingtimestamps">Working with timestamps</a> | |
| 58 | + * section of CQL specification. | |
| 56 | 59 | */ |
| 57 | 60 | public class ZonedDateTimeCodec extends TypeCodec.AbstractTupleCodec<ZonedDateTime> { |
| 58 | 61 |
modified driver-extras/src/main/java/com/datastax/driver/extras/codecs/jdk8/package-info.java +6 −38
| @@ -17,45 +17,13 @@ | ||
| 17 | 17 | /** |
| 18 | 18 | * This package contains a collection of convenience |
| 19 | 19 | * {@link com.datastax.driver.core.TypeCodec TypeCodec} instances useful for |
| 20 | - * serializing between CQL types and JDK 8 types, such as the ones from the | |
| 21 | - * {@code java.time} API and {@link java.util.Optional}. | |
| 22 | - * <p> | |
| 23 | - * The codecs in this class provide the following mappings: | |
| 20 | + * serializing between CQL types and Java 8 types, such as the ones from the | |
| 21 | + * {@link java.time} API and {@link java.util.Optional}. | |
| 24 | 22 | * |
| 25 | - * <table summary="Supported Mappings"> | |
| 26 | - * <tr> | |
| 27 | - * <th>Codec</th> | |
| 28 | - * <th>CQL type</th> | |
| 29 | - * <th>JDK 8 type</th> | |
| 30 | - * </tr> | |
| 31 | - * <tr> | |
| 32 | - * <td>{@link com.datastax.driver.extras.codecs.jdk8.OptionalCodec}</td> | |
| 33 | - * <td>Any</td> | |
| 34 | - * <td>{@link java.util.Optional Optional}</td> | |
| 35 | - * </tr> | |
| 36 | - * <tr> | |
| 37 | - * <td>{@link com.datastax.driver.extras.codecs.jdk8.LocalTimeCodec}</td> | |
| 38 | - * <td>{@link com.datastax.driver.core.DataType#time() time}</td> | |
| 39 | - * <td>{@link java.time.LocalTime LocalTime}</td> | |
| 40 | - * </tr> | |
| 41 | - * <tr> | |
| 42 | - * <td>{@link com.datastax.driver.extras.codecs.jdk8.LocalDateCodec}</td> | |
| 43 | - * <td>{@link com.datastax.driver.core.DataType#date() date}</td> | |
| 44 | - * <td>{@link java.time.LocalDate LocalDate}</td> | |
| 45 | - * </tr> | |
| 46 | - * <tr> | |
| 47 | - * <td>{@link com.datastax.driver.extras.codecs.jdk8.InstantCodec}</td> | |
| 48 | - * <td>{@link com.datastax.driver.core.DataType#timestamp() timestamp}</td> | |
| 49 | - * <td>{@link java.time.Instant Instant}</td> | |
| 50 | - * </tr> | |
| 51 | - * <tr> | |
| 52 | - * <td>{@link com.datastax.driver.extras.codecs.jdk8.ZonedDateTimeCodec}</td> | |
| 53 | - * <td>{@link com.datastax.driver.core.TupleType tuple} of | |
| 54 | - * ({@link com.datastax.driver.core.DataType#timestamp() timestamp}, | |
| 55 | - * {@link com.datastax.driver.core.DataType#varchar() varchar})</td> | |
| 56 | - * <td>{@link java.time.ZonedDateTime ZonedDateTime}</td> | |
| 57 | - * </tr> | |
| 58 | - * </table> | |
| 23 | + * <p> | |
| 24 | + * Note that, while the driver remains globally compatible with older JDKs, | |
| 25 | + * classes in this package require the presence of a Java 8 or higher | |
| 26 | + * at runtime. | |
| 59 | 27 | * |
| 60 | 28 | */ |
| 61 | 29 | package com.datastax.driver.extras.codecs.jdk8; |
modified driver-extras/src/main/java/com/datastax/driver/extras/codecs/joda/DateTimeCodec.java +4 −1
| @@ -37,7 +37,7 @@ | ||
| 37 | 37 | /** |
| 38 | 38 | * <p> |
| 39 | 39 | * {@link TypeCodec} that maps |
| 40 | - * {@link DateTime} <-> <code>tuple<timestamp,varchar></code> | |
| 40 | + * {@link DateTime} to CQL {@code tuple<timestamp,varchar>}, | |
| 41 | 41 | * providing a pattern for maintaining timezone information in |
| 42 | 42 | * Cassandra. |
| 43 | 43 | * |
| @@ -49,6 +49,9 @@ | ||
| 49 | 49 | * persisted in the <code>varchar</code> field such that when the |
| 50 | 50 | * value is deserialized the timezone is |
| 51 | 51 | * preserved. |
| 52 | + * | |
| 53 | + * @see <a href="https://cassandra.apache.org/doc/cql3/CQL-2.2.html#usingtimestamps">Working with timestamps</a> | |
| 54 | + * section of CQL specification. | |
| 52 | 55 | */ |
| 53 | 56 | public class DateTimeCodec extends TypeCodec.AbstractTupleCodec<DateTime> { |
| 54 | 57 |
modified driver-extras/src/main/java/com/datastax/driver/extras/codecs/joda/InstantCodec.java +3 −2
| @@ -36,10 +36,11 @@ | ||
| 36 | 36 | import static com.datastax.driver.core.ParseUtils.unquote; |
| 37 | 37 | |
| 38 | 38 | /** |
| 39 | - * {@link TypeCodec} that maps {@link Instant} to CQL <code>timestamp</code>. | |
| 39 | + * {@link TypeCodec} that maps {@link Instant} to CQL {@code timestamp}. | |
| 40 | 40 | * |
| 41 | 41 | * @see DateTimeCodec |
| 42 | - * @see "https://cassandra.apache.org/doc/cql3/CQL-2.2.html#usingtimestamps" | |
| 42 | + * @see <a href="https://cassandra.apache.org/doc/cql3/CQL-2.2.html#usingtimestamps">Working with timestamps</a> | |
| 43 | + * section of CQL specification. | |
| 43 | 44 | */ |
| 44 | 45 | public class InstantCodec extends TypeCodec<Instant> { |
| 45 | 46 |
modified driver-extras/src/main/java/com/datastax/driver/extras/codecs/joda/LocalDateCodec.java +1 −1
| @@ -39,7 +39,7 @@ | ||
| 39 | 39 | |
| 40 | 40 | /** |
| 41 | 41 | * {@link TypeCodec} that maps |
| 42 | - * {@link org.joda.time.LocalDate} to CQL <code>date</code> columns. | |
| 42 | + * {@link org.joda.time.LocalDate} to CQL {@code date}. | |
| 43 | 43 | */ |
| 44 | 44 | public class LocalDateCodec extends TypeCodec<LocalDate> { |
| 45 | 45 |
modified driver-extras/src/main/java/com/datastax/driver/extras/codecs/joda/LocalTimeCodec.java +2 −4
| @@ -33,12 +33,10 @@ | ||
| 33 | 33 | import static com.datastax.driver.core.ParseUtils.quote; |
| 34 | 34 | |
| 35 | 35 | /** |
| 36 | - * {@link TypeCodec} that maps {@link LocalTime} <-> CQL time (long representing nanoseconds since midnight) | |
| 37 | - * allowing the setting and retrieval of <code>time</code> columns as {@link LocalTime} | |
| 38 | - * instances. | |
| 36 | + * {@link TypeCodec} that maps {@link LocalTime} to CQL {@code time} (long representing nanoseconds since midnight). | |
| 39 | 37 | * |
| 40 | 38 | * <p> |
| 41 | - * IMPORTANT: {@link LocalTime} as millisecond precision; nanoseconds below one millisecond will be lost | |
| 39 | + * IMPORTANT: {@link LocalTime} has millisecond precision; nanoseconds below one millisecond will be lost | |
| 42 | 40 | * during deserialization. |
| 43 | 41 | */ |
| 44 | 42 | public class LocalTimeCodec extends TypeCodec<LocalTime> { |
modified driver-extras/src/main/java/com/datastax/driver/extras/codecs/joda/package-info.java +14 −32
| @@ -16,39 +16,21 @@ | ||
| 16 | 16 | |
| 17 | 17 | /** |
| 18 | 18 | * This package contains a collection of convenience |
| 19 | - * {@link com.datastax.driver.core.TypeCodec} instances useful for | |
| 20 | - * serializing between CQL types and Joda Time types like {@link org.joda.time.DateTime}. | |
| 19 | + * {@link com.datastax.driver.core.TypeCodec TypeCodec} instances useful for | |
| 20 | + * serializing between CQL types and Joda Time types such as {@link org.joda.time.DateTime}. | |
| 21 | + * | |
| 21 | 22 | * <p> |
| 22 | - * The codecs in this class provide the following mappings: | |
| 23 | + * Note that classes in this package require the presence of | |
| 24 | + * <a href="http://www.joda.org/joda-time/">Joda Time library</a> at runtime. | |
| 25 | + * If you use Maven, this can be done by declaring the following dependency in your project: | |
| 26 | + * | |
| 27 | + * <pre>{@code | |
| 28 | + * <dependency> | |
| 29 | + * <groupId>joda-time</groupId> | |
| 30 | + * <artifactId>joda-time</artifactId> | |
| 31 | + * <version>2.9.1</version> | |
| 32 | + * </dependency> | |
| 33 | + * }</pre> | |
| 23 | 34 | * |
| 24 | - * <table summary="Supported Mappings"> | |
| 25 | - * <tr> | |
| 26 | - * <th>Codec</th> | |
| 27 | - * <th>CQL type</th> | |
| 28 | - * <th>Joda Time</th> | |
| 29 | - * </tr> | |
| 30 | - * <tr> | |
| 31 | - * <td>{@link com.datastax.driver.extras.codecs.joda.LocalTimeCodec}</td> | |
| 32 | - * <td>{@link com.datastax.driver.core.DataType#time() time}</td> | |
| 33 | - * <td>{@link org.joda.time.LocalTime LocalTime}</td> | |
| 34 | - * </tr> | |
| 35 | - * <tr> | |
| 36 | - * <td>{@link com.datastax.driver.extras.codecs.joda.LocalDateCodec}</td> | |
| 37 | - * <td>{@link com.datastax.driver.core.DataType#date() date}</td> | |
| 38 | - * <td>{@link org.joda.time.LocalDate LocalDate}</td> | |
| 39 | - * </tr> | |
| 40 | - * <tr> | |
| 41 | - * <td>{@link com.datastax.driver.extras.codecs.joda.InstantCodec}</td> | |
| 42 | - * <td>{@link com.datastax.driver.core.DataType#timestamp() timestamp}</td> | |
| 43 | - * <td>{@link org.joda.time.Instant Instant}</td> | |
| 44 | - * </tr> | |
| 45 | - * <tr> | |
| 46 | - * <td>{@link com.datastax.driver.extras.codecs.joda.DateTimeCodec}</td> | |
| 47 | - * <td>{@link com.datastax.driver.core.TupleType tuple} of | |
| 48 | - * ({@link com.datastax.driver.core.DataType#timestamp() timestamp}, | |
| 49 | - * {@link com.datastax.driver.core.DataType#varchar() varchar})</td> | |
| 50 | - * <td>{@link org.joda.time.DateTime DateTime}</td> | |
| 51 | - * </tr> | |
| 52 | - * </table> | |
| 53 | 35 | */ |
| 54 | 36 | package com.datastax.driver.extras.codecs.joda; |
modified driver-extras/src/main/java/com/datastax/driver/extras/codecs/json/JacksonJsonCodec.java +15 −1
| @@ -33,10 +33,24 @@ | ||
| 33 | 33 | /** |
| 34 | 34 | * A JSON codec that uses the <a href="http://wiki.fasterxml.com/JacksonHome">Jackson</a> |
| 35 | 35 | * library to perform serialization and deserialization of JSON objects. |
| 36 | + * | |
| 36 | 37 | * <p> |
| 37 | - * Note that this codec maps a single object to a single JSON structure at a time; | |
| 38 | + * This codec maps a single Java object to a single JSON structure at a time; | |
| 38 | 39 | * mapping of arrays or collections to root-level JSON arrays is not supported, |
| 39 | 40 | * but such a codec can be easily crafted after this one. |
| 41 | + * | |
| 42 | + * <p> | |
| 43 | + * Note that this codec requires the presence of Jackson library at runtime. | |
| 44 | + * If you use Maven, this can be done by declaring the following dependency in your project: | |
| 45 | + * | |
| 46 | + * <pre>{@code | |
| 47 | + * <dependency> | |
| 48 | + * <groupId>com.fasterxml.jackson.core</groupId> | |
| 49 | + * <artifactId>jackson-databind</artifactId> | |
| 50 | + * <version>2.6.3</version> | |
| 51 | + * </dependency> | |
| 52 | + * }</pre> | |
| 53 | + * | |
| 40 | 54 | */ |
| 41 | 55 | public class JacksonJsonCodec<T> extends TypeCodec<T> { |
| 42 | 56 |
modified driver-extras/src/main/java/com/datastax/driver/extras/codecs/json/Jsr353JsonCodec.java +23 −3
| @@ -36,7 +36,7 @@ | ||
| 36 | 36 | * More specifically, this codec maps an arbitrary {@link JsonStructure} to |
| 37 | 37 | * a CQL {@code varchar} column. |
| 38 | 38 | * <p> |
| 39 | - * Note that this codec handles the Java type {@link JsonStructure}. | |
| 39 | + * This codec handles the Java type {@link JsonStructure}. | |
| 40 | 40 | * It is therefore required that values are set and retrieved using that exact Java type; |
| 41 | 41 | * users should manually downcast to either {@link JsonObject} or {@link JsonArray}, |
| 42 | 42 | * as in the example below: |
| @@ -45,12 +45,12 @@ | ||
| 45 | 45 | * // setting values |
| 46 | 46 | * JsonObject myObject = ... |
| 47 | 47 | * PreparedStatement ps = ... |
| 48 | - * // set values using JsonStructure | |
| 48 | + * // set values using JsonStructure as target Java type | |
| 49 | 49 | * BoundStatement bs = ps.bind().set(1, myObject, JsonStructure.class); |
| 50 | 50 | * |
| 51 | 51 | * // retrieving values |
| 52 | 52 | * Row row = session.execute(bs).one(); |
| 53 | - * // use JsonStructure to retrieve values | |
| 53 | + * // use JsonStructure as target Java type to retrieve values | |
| 54 | 54 | * JsonStructure json = row.get(0, JsonStructure.class); |
| 55 | 55 | * if (json instanceof JsonObject) { |
| 56 | 56 | * myObject = (JsonObject) json; |
| @@ -58,6 +58,26 @@ | ||
| 58 | 58 | * } |
| 59 | 59 | * }</pre> |
| 60 | 60 | * |
| 61 | + * <p> | |
| 62 | + * Note that at runtime, this codec requires the presence of both JSR-353 API | |
| 63 | + * and a JSR-353-compatible runtime library, such as | |
| 64 | + * <a href="https://jsonp.java.net/download.html">JSR-353's reference implementation</a>. | |
| 65 | + * If you use Maven, this can be done by declaring the following dependencies in your project: | |
| 66 | + * | |
| 67 | + * <pre>{@code | |
| 68 | + * <dependency> | |
| 69 | + * <groupId>javax.json</groupId> | |
| 70 | + * <artifactId>javax.json-api</artifactId> | |
| 71 | + * <version>1.0</version> | |
| 72 | + * </dependency> | |
| 73 | + * | |
| 74 | + * <dependency> | |
| 75 | + * <groupId>org.glassfish</groupId> | |
| 76 | + * <artifactId>javax.json</artifactId> | |
| 77 | + * <version>1.0.4</version> | |
| 78 | + * </dependency> | |
| 79 | + * }</pre> | |
| 80 | + * | |
| 61 | 81 | */ |
| 62 | 82 | public class Jsr353JsonCodec extends TypeCodec<JsonStructure> { |
| 63 | 83 |
modified driver-extras/src/main/java/com/datastax/driver/extras/codecs/json/package-info.java +0 −24
| @@ -18,29 +18,5 @@ | ||
| 18 | 18 | * This package contains a collection of convenience |
| 19 | 19 | * {@link com.datastax.driver.core.TypeCodec} instances useful for |
| 20 | 20 | * serializing JSON structures. |
| 21 | - * <p> | |
| 22 | - * The codecs in this class provide support for the following mappings | |
| 23 | - * and frameworks: | |
| 24 | - * | |
| 25 | - * <table summary="Supported Mappings"> | |
| 26 | - * <tr> | |
| 27 | - * <th>Codec</th> | |
| 28 | - * <th>CQL type</th> | |
| 29 | - * <th>Java type</th> | |
| 30 | - * <th>JSON Framework</th> | |
| 31 | - * </tr> | |
| 32 | - * <tr> | |
| 33 | - * <td>{@link com.datastax.driver.extras.codecs.json.JacksonJsonCodec}</td> | |
| 34 | - * <td>{@link com.datastax.driver.core.DataType#varchar() varchar}</td> | |
| 35 | - * <td>Any</td> | |
| 36 | - * <td><a href="http://wiki.fasterxml.com/JacksonHome">Jackson</a></td> | |
| 37 | - * </tr> | |
| 38 | - * <tr> | |
| 39 | - * <td>{@link com.datastax.driver.extras.codecs.json.Jsr353JsonCodec}</td> | |
| 40 | - * <td>{@link com.datastax.driver.core.DataType#varchar() varchar}</td> | |
| 41 | - * <td>{@link javax.json.JsonStructure JsonStructure}</td> | |
| 42 | - * <td><a href="https://jcp.org/en/jsr/detail?id=353">Java API for JSON processing</a> (JSR 353)</td> | |
| 43 | - * </tr> | |
| 44 | - * </table> | |
| 45 | 21 | */ |
| 46 | 22 | package com.datastax.driver.extras.codecs.json; |
added driver-extras/src/main/java/com/datastax/driver/extras/codecs/package-info.java +55 −0
| @@ -0,0 +1,55 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (C) 2012-2015 DataStax Inc. | |
| 3 | + * | |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | |
| 5 | + * you may not use this file except in compliance with the License. | |
| 6 | + * You may obtain a copy of the License at | |
| 7 | + * | |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
| 9 | + * | |
| 10 | + * Unless required by applicable law or agreed to in writing, software | |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, | |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 13 | + * See the License for the specific language governing permissions and | |
| 14 | + * limitations under the License. | |
| 15 | + */ | |
| 16 | + | |
| 17 | +/** | |
| 18 | + * This package and its subpackages contain several convenience {@link com.datastax.driver.core.TypeCodec TypeCodec}s. | |
| 19 | + * | |
| 20 | + * <table summary="Supported Mappings"> | |
| 21 | + * <tr> | |
| 22 | + * <th>Package</th> | |
| 23 | + * <th>Description</th> | |
| 24 | + * </tr> | |
| 25 | + * <tr> | |
| 26 | + * <td>{@link com.datastax.driver.extras.codecs.arrays}</td> | |
| 27 | + * <td>codecs mapping CQL lists to Java arrays.</td> | |
| 28 | + * </tr> | |
| 29 | + * <tr> | |
| 30 | + * <td>{@link com.datastax.driver.extras.codecs.date}</td> | |
| 31 | + * <td>codecs mapping CQL temporal types to Java primitive types.</td> | |
| 32 | + * </tr> | |
| 33 | + * <tr> | |
| 34 | + * <td>{@link com.datastax.driver.extras.codecs.enums}</td> | |
| 35 | + * <td>codecs mapping CQL types to Java enums.</td> | |
| 36 | + * </tr> | |
| 37 | + * <tr> | |
| 38 | + * <td>{@link com.datastax.driver.extras.codecs.guava}</td> | |
| 39 | + * <td>codecs mapping CQL types to Guava-specific Java types.</td> | |
| 40 | + * </tr> | |
| 41 | + * <tr> | |
| 42 | + * <td>{@link com.datastax.driver.extras.codecs.jdk8}</td> | |
| 43 | + * <td>codecs mapping CQL types to Java 8 types, including {@code java.time} API and {@code java.util.Optional}.</td> | |
| 44 | + * </tr> | |
| 45 | + * <tr> | |
| 46 | + * <td>{@link com.datastax.driver.extras.codecs.joda}</td> | |
| 47 | + * <td>codecs mapping CQL types to Joda Time types.</td> | |
| 48 | + * </tr> | |
| 49 | + * <tr> | |
| 50 | + * <td>{@link com.datastax.driver.extras.codecs.json}</td> | |
| 51 | + * <td>codecs mapping CQL varchars to JSON structures.</td> | |
| 52 | + * </tr> | |
| 53 | + * </table> | |
| 54 | + */ | |
| 55 | +package com.datastax.driver.extras.codecs; |