Skip to content

Commit b5b3c8e

Browse files
committed
Formatting
1 parent 7dd20d7 commit b5b3c8e

File tree

7 files changed

+67
-42
lines changed

7 files changed

+67
-42
lines changed

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

Lines changed: 56 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828

2929
/**
3030
* This class has MessagePack prefix code definitions and packer/unpacker factory methods.
31-
*
3231
*/
3332
public 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
}

msgpack-core/src/main/java/org/msgpack/core/MessageUnpacker.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -979,6 +979,7 @@ public String unpackString() throws IOException {
979979
boolean endOfInput = (cursor + readLen) >= strLen;
980980
CoderResult cr = decoder.decode(bb, decodeBuffer, endOfInput);
981981

982+
// FIXME
982983
if(endOfInput && cr.isUnderflow())
983984
cr = decoder.flush(decodeBuffer);
984985

msgpack-core/src/main/java/org/msgpack/core/buffer/MessageBuffer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ else if(bb.hasArray()) {
261261

262262

263263
/**
264-
* Create a MessageBuffer instance from an java heap array
264+
* Create a MessageBuffer instance from a java heap array
265265
* @param arr
266266
*/
267267
MessageBuffer(byte[] arr) {

msgpack-core/src/main/java/org/msgpack/core/example/MessagePackExample.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public static void basicUsage() throws IOException {
4949
.packArrayHeader(2)
5050
.packString("xxx-xxxx")
5151
.packString("yyy-yyyy");
52-
packer.close();
52+
packer.close(); // 1, "leo", ["xxx-xxxx", "yyy-yyyy"]
5353

5454
// Deserialize with MessageUnpacker
5555
MessageUnpacker unpacker = MessagePack.newDefaultUnpacker(out.toByteArray());

msgpack-core/src/main/java/org/msgpack/value/ValueFactory.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@
2828
* Factory for creting Value instances
2929
*/
3030
public class ValueFactory {
31-
public static NilValue nilValue() {
31+
public static ImmutableNilValue nilValue() {
3232
return NilValueImpl.getInstance();
3333
}
3434

35-
public static BooleanValue newBoolean(boolean v) {
35+
public static ImmutableBooleanValue newBoolean(boolean v) {
3636
return v ? BooleanValueImpl.TRUE : BooleanValueImpl.FALSE;
3737
}
3838

@@ -96,7 +96,7 @@ public static ArrayValue newArrayFrom(List<? extends Value> list) {
9696
if (list.isEmpty()) {
9797
return ArrayValueImpl.empty();
9898
}
99-
Value[] array = list.toArray(new Value[list.size()]);
99+
ImmutableValue[] array = list.toArray(new ImmutableValue[list.size()]);
100100
return new ArrayValueImpl(array);
101101
}
102102

msgpack-core/src/main/java/org/msgpack/value/impl/BooleanValueImpl.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
*/
1111
public class BooleanValueImpl extends AbstractValue implements ImmutableBooleanValue {
1212

13-
public static BooleanValue TRUE = new BooleanValueImpl(true);
14-
public static BooleanValue FALSE = new BooleanValueImpl(false);
13+
public static ImmutableBooleanValue TRUE = new BooleanValueImpl(true);
14+
public static ImmutableBooleanValue FALSE = new BooleanValueImpl(false);
1515

1616
private final boolean value;
1717

@@ -58,7 +58,7 @@ public void accept(ValueVisitor visitor) {
5858
}
5959

6060
@Override
61-
public BooleanValue toImmutable() {
61+
public ImmutableBooleanValue toImmutable() {
6262
return this;
6363
}
6464

msgpack-core/src/main/java/org/msgpack/value/impl/NilValueImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
*/
1111
public class NilValueImpl extends AbstractValue implements ImmutableNilValue {
1212

13-
private static NilValue instance = new NilValueImpl();
13+
private static ImmutableNilValue instance = new NilValueImpl();
1414

15-
public static NilValue getInstance() {
15+
public static ImmutableNilValue getInstance() {
1616
return instance;
1717
}
1818

0 commit comments

Comments
 (0)