Skip to content

Commit 70c5abe

Browse files
committed
updated document in MessagePack.java
1 parent 42bcb20 commit 70c5abe

File tree

1 file changed

+33
-19
lines changed

1 file changed

+33
-19
lines changed

src/main/java/org/msgpack/MessagePack.java

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@
4545
*
4646
* <p>
4747
* 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.
5050
* </p>
5151
*
5252
* <p>
@@ -60,7 +60,7 @@
6060
* <h3>How to Install</h3>
6161
*
6262
* <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
6464
* href="http://msgpack.org/maven2/">http://msgpack.org/maven2/</a>
6565
* </p>
6666
*
@@ -155,11 +155,11 @@
155155
* <p>
156156
* If you want to serialize multiple objects sequentially, MessagePack
157157
* 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
159159
* {@link MessagePack#write(Object)} and {@link #read(byte[])} method
160160
* invocations create {@link org.msgpack.packer.Packer} and
161161
* {@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
163163
* {@link #createPacker(OutputStream)} and {@link #createUnpacker(byte[])}.
164164
* </p>
165165
*
@@ -177,14 +177,19 @@
177177
* src3.version = 1.0;
178178
*
179179
* MessagePack msgpack = new MessagePack();
180-
* // serialize src data to byte array
180+
* //
181+
* // serialize
182+
* //
181183
* ByteArrayOutputStream out = new ByteArrayOutputStream();
182184
* Packer packer = msgpack.createPacker(out);
183185
* packer.write(src1);
184186
* packer.write(src2);
185187
* packer.write(src3);
186188
* byte[] bytes = out.toByteArray();
187-
* // deserialize byte array to MyMessage object
189+
*
190+
* //
191+
* // deserialize
192+
* //
188193
* ByteArrayInputStream in = new ByteArrayInputStream(bytes);
189194
* Unpacker unpacker = msgpack.createUnpacker(in);
190195
* MyMessage dst1 = unpacker.read(bytes, MyMessage.class);
@@ -214,7 +219,6 @@
214219
* //
215220
* // serialization
216221
* //
217-
*
218222
* ByteArrayOutputStream out = new ByteArrayOutputStream();
219223
* Packer packer = msgpack.createPacker(out);
220224
*
@@ -242,7 +246,6 @@
242246
* //
243247
* // deserialization
244248
* //
245-
*
246249
* byte[] bytes = out.toByteArray();
247250
* ByteArrayInputStream in = new ByteArrayInputStream(bytes);
248251
* Unpacker unpacker = msgpack.createUnpacker(in);
@@ -297,12 +300,23 @@
297300
* </h3>
298301
*
299302
* <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.
306320
* </p>
307321
*
308322
* <pre>
@@ -372,10 +386,10 @@
372386
* <p>
373387
* For example, if <code>MyMessage2</code> class is included in external
374388
* 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.
379393
* </p>
380394
*
381395
* <h3>Optional Fields</h3>

0 commit comments

Comments
 (0)