|
45 | 45 | * |
46 | 46 | * <p> |
47 | 47 | * MessagePack is a binary-based efficient object serialization library for |
48 | | - * cross languages. It enables to exchange structured objects between many |
49 | | - * languages like JSON. But unlike JSON, it is very fast and small. |
| 48 | + * cross languages. It enables exchanging structured objects between many |
| 49 | + * languages like JSON, but it is very fast and small compared to JSON. |
50 | 50 | * </p> |
51 | 51 | * |
52 | 52 | * <p> |
|
60 | 60 | * <h3>How to Install</h3> |
61 | 61 | * |
62 | 62 | * <p> |
63 | | - * The official Maven2 repository for MessagePack for Java is located here. <a |
| 63 | + * The official Maven2 repository of MessagePack for Java is located here. <a |
64 | 64 | * href="http://msgpack.org/maven2/">http://msgpack.org/maven2/</a> |
65 | 65 | * </p> |
66 | 66 | * |
|
155 | 155 | * <p> |
156 | 156 | * If you want to serialize multiple objects sequentially, MessagePack |
157 | 157 | * recommends use of {@link org.msgpack.packer.Packer} and |
158 | | - * {@link org.msgpack.unpacker.Unpacker} objects. Because |
| 158 | + * {@link org.msgpack.unpacker.Unpacker} objects. This is because |
159 | 159 | * {@link MessagePack#write(Object)} and {@link #read(byte[])} method |
160 | 160 | * invocations create {@link org.msgpack.packer.Packer} and |
161 | 161 | * {@link org.msgpack.unpacker.Unpacker} objects every times. To use |
162 | | - * <code>Packer</code> and <code>Unpacker</code> objects, you call |
| 162 | + * <code>Packer</code> and <code>Unpacker</code> objects, call |
163 | 163 | * {@link #createPacker(OutputStream)} and {@link #createUnpacker(byte[])}. |
164 | 164 | * </p> |
165 | 165 | * |
|
177 | 177 | * src3.version = 1.0; |
178 | 178 | * |
179 | 179 | * MessagePack msgpack = new MessagePack(); |
180 | | - * // serialize src data to byte array |
| 180 | + * // |
| 181 | + * // serialize |
| 182 | + * // |
181 | 183 | * ByteArrayOutputStream out = new ByteArrayOutputStream(); |
182 | 184 | * Packer packer = msgpack.createPacker(out); |
183 | 185 | * packer.write(src1); |
184 | 186 | * packer.write(src2); |
185 | 187 | * packer.write(src3); |
186 | 188 | * byte[] bytes = out.toByteArray(); |
187 | | - * // deserialize byte array to MyMessage object |
| 189 | + * |
| 190 | + * // |
| 191 | + * // deserialize |
| 192 | + * // |
188 | 193 | * ByteArrayInputStream in = new ByteArrayInputStream(bytes); |
189 | 194 | * Unpacker unpacker = msgpack.createUnpacker(in); |
190 | 195 | * MyMessage dst1 = unpacker.read(bytes, MyMessage.class); |
|
214 | 219 | * // |
215 | 220 | * // serialization |
216 | 221 | * // |
217 | | - * |
218 | 222 | * ByteArrayOutputStream out = new ByteArrayOutputStream(); |
219 | 223 | * Packer packer = msgpack.createPacker(out); |
220 | 224 | * |
|
242 | 246 | * // |
243 | 247 | * // deserialization |
244 | 248 | * // |
245 | | - * |
246 | 249 | * byte[] bytes = out.toByteArray(); |
247 | 250 | * ByteArrayInputStream in = new ByteArrayInputStream(bytes); |
248 | 251 | * Unpacker unpacker = msgpack.createUnpacker(in); |
|
297 | 300 | * </h3> |
298 | 301 | * |
299 | 302 | * <p> |
300 | | - * You can serialize <code>List</code> and <code>Map</code> objects with |
301 | | - * {@link org.msgpack.template.Template} objects, which are pairs of |
302 | | - * serializer/deserializer. The type of elements in <code>List</code> object |
303 | | - * needs to be specified to <code>Template</code> object for effective |
304 | | - * serialization/deserialization. Types of keys and values in <code>Map</code> |
305 | | - * object also need to be specified to <code>Template</code> object. |
| 303 | + * To serialize generic container objects like <code>List</code> and |
| 304 | + * <code>Map</code> objects, you can use {@link org.msgpack.template.Template}. |
| 305 | + * <code>Template</code> objects are pairs of serializer and deserializer. For |
| 306 | + * example, to serialize a <code>List</code> object that has |
| 307 | + * <code>Integer</code> objects as elements, you create the |
| 308 | + * <code>Template</code> object by the following way. |
| 309 | + * </p> |
| 310 | + * |
| 311 | + * <pre> |
| 312 | + * Template listTmpl = Templates.tList(Templates.TInteger); |
| 313 | + * </pre> |
| 314 | + * |
| 315 | + * <p> |
| 316 | + * <code>tList</code>, <code>TInteger</code> are <code>static method</code> and |
| 317 | + * <code>field</code> in {@link org.msgpack.template.Templates}. A simple |
| 318 | + * example of <code>List</code> and <code>Map</code> objects is shown in the |
| 319 | + * following. |
306 | 320 | * </p> |
307 | 321 | * |
308 | 322 | * <pre> |
|
372 | 386 | * <p> |
373 | 387 | * For example, if <code>MyMessage2</code> class is included in external |
374 | 388 | * library, you cannot easily modify the class declaration and append |
375 | | - * <code>@Message</code> to it. {@link #register} method allows to generate |
376 | | - * serializer/deserializer of <code>MyMessage2</code> class automatically. You |
377 | | - * can serialize objects of <code>MyMessage2</code> class after executing the |
378 | | - * method. |
| 389 | + * <code>@Message</code> to it. {@link #register} method allows to generate a |
| 390 | + * pair of serializer and deserializer for <code>MyMessage2</code> class |
| 391 | + * automatically. You can serialize objects of <code>MyMessage2</code> class |
| 392 | + * after executing the method. |
379 | 393 | * </p> |
380 | 394 | * |
381 | 395 | * <h3>Optional Fields</h3> |
|
0 commit comments