Elffuss BraidHub

kikocis/java-driver public

Clean up CodecRegistry javadoc.

Automatic formatting had added extra line breaks.
Changesetc559bbce6d4f454854ebf15eb5ac497fc1e7d91b286dc2cf58d1ba48a7f6e58c
Authorolim7t <omichallat+github@gmail.com> · 2015-12-18 16:17 +01:00
Committerolim7t <omichallat+github@gmail.com> · 2015-12-18 16:17 +01:00
Parents929f9e585424

Browse the files at this changeset

1 file changed

modified driver-core/src/main/java/com/datastax/driver/core/CodecRegistry.java +25 −36
@@ -41,16 +41,14 @@
4141 * it will lookup in the registry for a suitable codec. The registry is initialized with default codecs that handle
4242 * basic conversions (e.g. CQL {@code text} to {@code java.lang.String}), and users can add their own. Complex
4343 * codecs can also be generated on-the-fly from simpler ones (more details below).
44- * <p/>
45- * <h3>Creating a registry</h3>
46- * <p/>
47- * <p/>
44+ * <h3>
45+ * Creating a registry
46+ * </h3>
4847 * By default, the driver uses {@link CodecRegistry#DEFAULT_INSTANCE}, a shareable, JVM-wide instance initialized with
4948 * built-in codecs for all the base CQL types.
5049 * The only reason to create your own instances is if you have multiple {@code Cluster} objects that use different
5150 * sets of codecs. In that case, use {@link com.datastax.driver.core.Cluster.Builder#withCodecRegistry(CodecRegistry)}
5251 * to associate the registry with the cluster:
53- * <p/>
5452 * <pre>
5553 * {@code
5654 * CodecRegistry myCodecRegistry = new CodecRegistry();
@@ -58,29 +56,25 @@
5856 * Cluster cluster = Cluster.builder().withCodecRegistry(myCodecRegistry).build();
5957 *
6058 * // To retrieve the registry later:
61- * CodecRegistry registry = cluster.getConfiguration().getCodecRegistry();
62- * }</pre>
63- *
59+ * CodecRegistry registry = cluster.getConfiguration().getCodecRegistry();}
60+ * </pre>
6461 * {@code CodecRegistry} instances are thread-safe.
65- *
66- *
62+ * <p/>
6763 * It is possible to turn on log messages by setting the {@code com.datastax.driver.core.CodecRegistry} logger
6864 * level to {@code TRACE}. Beware that the registry can be very verbose at this log level.
69- *
70- * <h3>Registering and using custom codecs</h3>
71- *
65+ * <h3>
66+ * Registering and using custom codecs
67+ * </h3>
7268 * To create a custom codec, write a class that extends {@link TypeCodec}, create an instance, and pass it to one of
7369 * the {@link #register(TypeCodec) register} methods; for example, one could create a codec that maps CQL
7470 * timestamps to JDK8's {@code java.time.LocalDate}:
75- *
7671 * <pre>
7772 * {@code
7873 * class LocalDateCodec extends TypeCodec<java.time.LocalDate> {
7974 * ...
8075 * }
81- * myCodecRegistry.register(new LocalDateCodec());
82- * }</pre>
83- *
76+ * myCodecRegistry.register(new LocalDateCodec());}
77+ * </pre>
8478 * The conversion will be available to:
8579 * <ul>
8680 * <li>all driver types that implement {@link GettableByIndexData}, {@link GettableByNameData},
@@ -89,21 +83,20 @@
8983 * <li>{@link SimpleStatement(String, Object...) simple statements};</li>
9084 * <li>statements created with the {@link com.datastax.driver.core.querybuilder.QueryBuilder Query builder}.</li>
9185 * </ul>
92- *
86+ * <p/>
9387 * Example:
94- * <pre>{@code
88+ * <pre>
89+ * {@code
9590 * Row row = session.executeQuery("select date from some_table where pk = 1").one();
96- * java.time.LocalDate date = row.get(0, java.time.LocalDate.class); // uses LocalDateCodec registered above
97- * }</pre>
98- *
91+ * java.time.LocalDate date = row.get(0, java.time.LocalDate.class); // uses LocalDateCodec registered above}
92+ * </pre>
9993 * You can also bypass the codec registry by passing a standalone codec instance to methods such as
10094 * {@link GettableByIndexData#get(int, TypeCodec)}.
101- *
102- * <h3>Codec generation</h3>
103- *
95+ * <h3>
96+ * Codec generation
97+ * </h3>
10498 * When a {@code CodecRegistry} cannot find a suitable codec among existing ones, it will attempt to create it on-the-fly.
10599 * It can manage:
106- *
107100 * <ul>
108101 * <li>collections (lists, sets and maps) of known types. For example,
109102 * if you registered a codec for JDK8's {@code java.time.LocalDate} like in the example above, you get
@@ -116,12 +109,11 @@
116109 * <li>{@link TupleType tuple types}, mapped to {@link TupleValue} (with the same rules for nested fields);</li>
117110 * <li>{@link com.datastax.driver.core.DataType.CustomType custom types}, mapped to {@code ByteBuffer}.</li>
118111 * </ul>
119- *
120112 * If the codec registry encounters a mapping that it can't handle automatically, a {@link CodecNotFoundException} is thrown;
121113 * you'll need to register a custom codec for it.
122- *
123- * <h3>Performance and caching</h3>
124- *
114+ * <h3>
115+ * Performance and caching
116+ * </h3>
125117 * Whenever possible, the registry will cache the result of a codec lookup for a specific type mapping, including any generated
126118 * codec. For example, if you registered {@code LocalDateCodec} and ask the registry for a codec to convert a CQL
127119 * {@code list<timestamp>} to a Java {@code List<LocalDate>}:
@@ -130,13 +122,11 @@
130122 * the cache;</li>
131123 * <li>the second lookup will hit the cache directly, and reuse the previously generated instance.</li>
132124 * </ol>
133- *
134125 * The javadoc for each {@link #codecFor(DataType) codecFor} variant specifies whether the result can be cached or not.
135- *
136- * <h3>Codec order</h3>
137- *
126+ * <h3>
127+ * Codec order
128+ * </h3>
138129 * When the registry looks up a codec, the rules of precedence are:
139- *
140130 * <ul>
141131 * <li>if a result was previously cached for that mapping, it is returned;</li>
142132 * <li>otherwise, the registry checks the list of "basic" codecs: the default ones, and the ones that were explicitly
@@ -144,7 +134,6 @@
144134 * it can handle the mapping, and if so returns it;</li>
145135 * <li>otherwise, the registry tries to generate a codec, according to the rules outlined above.</li>
146136 * </ul>
147- *
148137 * It is currently impossible to override an existing codec. If you try to do so, {@link #register(TypeCodec)} will log a
149138 * warning and ignore it.
150139 */