2828
2929/**
3030 * This class has MessagePack prefix code definitions and packer/unpacker factory methods.
31- *
3231 */
3332public class MessagePack {
3433
@@ -49,15 +48,15 @@ public static class Config {
4948 private final int packerRawDataCopyingThreshold ;
5049
5150 public Config (
52- boolean readStringAsBinary ,
53- boolean readBinaryAsString ,
54- CodingErrorAction onMalFormedInput ,
55- CodingErrorAction onUnmappableCharacter ,
56- int maxUnpackStringSize ,
57- int stringEncoderBufferSize ,
58- int stringDecoderBufferSize ,
59- int packerBufferSize ,
60- int packerRawDataCopyingThreshold ) {
51+ boolean readStringAsBinary ,
52+ boolean readBinaryAsString ,
53+ CodingErrorAction onMalFormedInput ,
54+ CodingErrorAction onUnmappableCharacter ,
55+ int maxUnpackStringSize ,
56+ int stringEncoderBufferSize ,
57+ int stringDecoderBufferSize ,
58+ int packerBufferSize ,
59+ int packerRawDataCopyingThreshold ) {
6160
6261 checkArgument (packerBufferSize > 0 , "packer buffer size must be larger than 0: " + packerBufferSize );
6362 checkArgument (stringEncoderBufferSize > 0 , "string encoder buffer size must be larger than 0: " + stringEncoderBufferSize );
@@ -77,31 +76,49 @@ public Config(
7776 /**
7877 * allow unpackBinaryHeader to read str format family (default:true)
7978 */
80- public boolean isReadStringAsBinary () { return readStringAsBinary ; }
79+ public boolean isReadStringAsBinary () {
80+ return readStringAsBinary ;
81+ }
8182
8283 /**
8384 * allow unpackRawStringHeader and unpackString to read bin format family (default: true)
8485 */
85- public boolean isReadBinaryAsString () { return readBinaryAsString ; }
86+ public boolean isReadBinaryAsString () {
87+ return readBinaryAsString ;
88+ }
8689 /**
8790 * Action when encountered a malformed input
8891 */
89- public CodingErrorAction getActionOnMalFormedInput () { return onMalFormedInput ; }
92+ public CodingErrorAction getActionOnMalFormedInput () {
93+ return onMalFormedInput ;
94+ }
9095 /**
9196 * Action when an unmappable character is found
9297 */
93- public CodingErrorAction getActionOnUnmappableCharacter () { return onUnmappableCharacter ; }
98+ public CodingErrorAction getActionOnUnmappableCharacter () {
99+ return onUnmappableCharacter ;
100+ }
94101
95102 /**
96103 * unpackString size limit. (default: Integer.MAX_VALUE)
97104 */
98- public int getMaxUnpackStringSize () { return maxUnpackStringSize ; }
105+ public int getMaxUnpackStringSize () {
106+ return maxUnpackStringSize ;
107+ }
99108
100- public int getStringEncoderBufferSize () { return stringEncoderBufferSize ; }
101- public int getStringDecoderBufferSize () { return stringDecoderBufferSize ; }
109+ public int getStringEncoderBufferSize () {
110+ return stringEncoderBufferSize ;
111+ }
112+ public int getStringDecoderBufferSize () {
113+ return stringDecoderBufferSize ;
114+ }
102115
103- public int getPackerBufferSize () { return packerBufferSize ; }
104- public int getPackerRawDataCopyingThreshold () { return packerRawDataCopyingThreshold ; }
116+ public int getPackerBufferSize () {
117+ return packerBufferSize ;
118+ }
119+ public int getPackerRawDataCopyingThreshold () {
120+ return packerRawDataCopyingThreshold ;
121+ }
105122 }
106123
107124 /**
@@ -123,15 +140,15 @@ public static class ConfigBuilder {
123140
124141 public Config build () {
125142 return new Config (
126- readStringAsBinary ,
127- readBinaryAsString ,
128- onMalFormedInput ,
129- onUnmappableCharacter ,
130- maxUnpackStringSize ,
131- stringEncoderBufferSize ,
132- stringDecoderBufferSize ,
133- packerBufferSize ,
134- packerRawDataCopyingThreshold
143+ readStringAsBinary ,
144+ readBinaryAsString ,
145+ onMalFormedInput ,
146+ onUnmappableCharacter ,
147+ maxUnpackStringSize ,
148+ stringEncoderBufferSize ,
149+ stringDecoderBufferSize ,
150+ packerBufferSize ,
151+ packerRawDataCopyingThreshold
135152 );
136153 }
137154
@@ -151,7 +168,7 @@ public ConfigBuilder onUnmappableCharacter(CodingErrorAction action) {
151168 this .onUnmappableCharacter = action ;
152169 return this ;
153170 }
154- public ConfigBuilder maxUnpackStringSize (int size ){
171+ public ConfigBuilder maxUnpackStringSize (int size ) {
155172 this .maxUnpackStringSize = size ;
156173 return this ;
157174 }
@@ -174,7 +191,6 @@ public ConfigBuilder packerRawDataCopyingThreshold(int threshold) {
174191 }
175192
176193
177-
178194 /**
179195 * Default configuration, which is visible only from classes in the core package.
180196 */
@@ -278,6 +294,7 @@ public MessagePack(MessagePack.Config config) {
278294
279295 /**
280296 * Create a MessagePacker that outputs the packed data to the specified stream, using the default configuration
297+ *
281298 * @param out
282299 * @return
283300 */
@@ -287,6 +304,7 @@ public static MessagePacker newDefaultPacker(OutputStream out) {
287304
288305 /**
289306 * Create a MessagePacker that outputs the packed data to the specified channel, using the default configuration
307+ *
290308 * @param channel
291309 * @return
292310 */
@@ -296,6 +314,7 @@ public static MessagePacker newDefaultPacker(WritableByteChannel channel) {
296314
297315 /**
298316 * Create a MessageUnpacker that reads data from then given InputStream, using the default configuration
317+ *
299318 * @param in
300319 * @return
301320 */
@@ -305,6 +324,7 @@ public static MessageUnpacker newDefaultUnpacker(InputStream in) {
305324
306325 /**
307326 * Create a MessageUnpacker that reads data from the given channel, using the default configuration
327+ *
308328 * @param channel
309329 * @return
310330 */
@@ -314,6 +334,7 @@ public static MessageUnpacker newDefaultUnpacker(ReadableByteChannel channel) {
314334
315335 /**
316336 * Create a MessageUnpacker that reads data from the given byte array, using the default configuration
337+ *
317338 * @param arr
318339 * @return
319340 */
@@ -324,6 +345,7 @@ public static MessageUnpacker newDefaultUnpacker(byte[] arr) {
324345 /**
325346 * Create a MessageUnpacker that reads data form the given byte array [offset, .. offset+length), using the default
326347 * configuration.
348+ *
327349 * @param arr
328350 * @param offset
329351 * @param length
@@ -336,6 +358,7 @@ public static MessageUnpacker newDefaultUnpacker(byte[] arr, int offset, int len
336358
337359 /**
338360 * Create a MessagePacker that outputs the packed data to the specified stream
361+ *
339362 * @param out
340363 */
341364 public MessagePacker newPacker (OutputStream out ) {
@@ -344,6 +367,7 @@ public MessagePacker newPacker(OutputStream out) {
344367
345368 /**
346369 * Create a MessagePacker that outputs the packed data to the specified channel
370+ *
347371 * @param channel
348372 */
349373 public MessagePacker newPacker (WritableByteChannel channel ) {
@@ -362,6 +386,7 @@ public MessageUnpacker newUnpacker(InputStream in) {
362386
363387 /**
364388 * Create a MessageUnpacker that reads data from the given ReadableByteChannel.
389+ *
365390 * @param in
366391 */
367392 public MessageUnpacker newUnpacker (ReadableByteChannel in ) {
@@ -380,6 +405,7 @@ public MessageUnpacker newUnpacker(byte[] arr) {
380405
381406 /**
382407 * Create a MessageUnpacker that reads data from the given byte array [offset, offset+length)
408+ *
383409 * @param arr
384410 * @param offset
385411 * @param length
@@ -389,6 +415,4 @@ public MessageUnpacker newUnpacker(byte[] arr, int offset, int length) {
389415 }
390416
391417
392-
393-
394418}
0 commit comments