Skip to content

Commit ddc7e6f

Browse files
committed
Merge branch 'v07-develop' into issue_238
Conflicts: msgpack-jackson/src/main/java/org/msgpack/jackson/dataformat/MessagePackExtendedType.java msgpack-jackson/src/test/java/org/msgpack/jackson/dataformat/MessagePackGeneratorTest.java
2 parents 9cf12b0 + ef2a934 commit ddc7e6f

File tree

139 files changed

+7362
-5645
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

139 files changed

+7362
-5645
lines changed

.idea/copyright/msgpack.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/copyright/profiles_settings.xml

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.travis.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
language: scala
2-
scala:
3-
- 2.11.1
42

53
jdk:
6-
- openjdk6
74
- openjdk7
85
- oraclejdk7
96
- oraclejdk8
@@ -12,4 +9,6 @@ branches:
129
only:
1310
- /^v07.*$/
1411

15-
script: sbt ++$TRAVIS_SCALA_VERSION test
12+
script:
13+
- sbt test
14+
- sbt test -J-Dmsgpack.universal-buffer=true

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ MessagePack for Java
55

66
* Message Pack specification: <https://github.com/msgpack/msgpack/blob/master/spec.md>
77

8-
MessagePack v7 (0.7.x) is a faster implementation of the previous version [v06](https://github.com/msgpack/msgpack-java/tree/v06), and supports all of the message pack types, including [extended format](https://github.com/msgpack/msgpack/blob/master/spec.md#formats-ext).
8+
MessagePack v7 (0.7.x) is a faster implementation of the previous version [v06](https://github.com/msgpack/msgpack-java/tree/v06), and
9+
supports all of the message pack types, including [extension format](https://github.com/msgpack/msgpack/blob/master/spec.md#formats-ext).
910

1011
## Limitation
1112
- Value API is in a designing phase: https://github.com/msgpack/msgpack-java/pull/109
@@ -26,7 +27,7 @@ For sbt users:
2627
libraryDependencies += "org.msgpack" % "msgpack-core" % "0.7.0-p9"
2728
```
2829

29-
- [Usage examples](msgpack-core/src/main/java/org/msgpack/core/example/MessagePackExample.java)
30+
- [Usage examples](msgpack-core/src/test/java/org/msgpack/core/example/MessagePackExample.java)
3031

3132
msgpack-java supports serialization and deserialization of Java objects through [jackson-databind](https://github.com/FasterXML/jackson-databind).
3233
For details, see [msgpack-jackson/README.md](msgpack-jackson/README.md). The template-based serialization mechanism used in v06 is deprecated.
@@ -38,6 +39,10 @@ For details, see [msgpack-jackson/README.md](msgpack-jackson/README.md). The tem
3839
msgpack-java uses [sbt](http://www.scala-sbt.org/) for building the projects. For the basic usage of sbt, see:
3940
* [Building Java projects with sbt](http://xerial.org/blog/2014/03/24/sbt/)
4041

42+
Coding style
43+
* msgpack-java uses [the same coding style](https://github.com/airlift/codestyle) with Facebook Presto
44+
* [IntelliJ setting file](https://raw.githubusercontent.com/airlift/codestyle/master/IntelliJIdea13/Airlift.xml)
45+
4146
### Basic sbt commands
4247
Enter the sbt console:
4348
```
@@ -55,6 +60,7 @@ Here is a list of sbt commands for daily development:
5560
> package # Create a jar file in the target folder of each project
5661
> findbugs # Produce findbugs report in target/findbugs
5762
> jacoco:cover # Report the code coverage of tests to target/jacoco folder
63+
> jcheckStyle # Run check style
5864
```
5965

6066
### Publishing

RELEASE_NOTES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Fix [#217] when reading from SockectInputStream
55

66
* 2015-04-09 0.7.0-p8
7-
* Support Extended type (defined in MessagePack) in msgpack-jackson
7+
* Support Extension type (defined in MessagePack) in msgpack-jackson
88
* Support BigDecimal type (defined in Jackson) in msgpack-jackson
99
* Fix MessageUnpacker#unpackString [#215](https://github.com/msgpack/msgpack-java/pull/215), [#216](https://github.com/msgpack/msgpack-java/pull/216)
1010

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

Lines changed: 0 additions & 45 deletions
This file was deleted.
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
//
2+
// MessagePack for Java
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
//
16+
package org.msgpack.core;
17+
18+
import static org.msgpack.core.Preconditions.checkArgument;
19+
20+
/**
21+
* Header of the Extension types
22+
*/
23+
public class ExtensionTypeHeader
24+
{
25+
private final byte type;
26+
private final int length;
27+
28+
/**
29+
* Create an extension type header
30+
* Example:
31+
* <pre>
32+
* {@code
33+
* import org.msgpack.core.ExtensionTypeHeader;
34+
* import static org.msgpack.core.ExtensionTypeHeader.checkedCastToByte;
35+
* ...
36+
* ExtensionTypeHeader header = new ExtensionTypeHeader(checkedCastToByte(0x01), 32);
37+
* ...
38+
* }
39+
* </pre>
40+
*
41+
* @param type extension type (byte). You can check the valid byte range with {@link #checkedCastToByte(int)} method.
42+
* @param length extension type data length
43+
*/
44+
public ExtensionTypeHeader(byte type, int length)
45+
{
46+
checkArgument(length >= 0, "length must be >= 0");
47+
this.type = type;
48+
this.length = length;
49+
}
50+
51+
public static byte checkedCastToByte(int code)
52+
{
53+
checkArgument(Byte.MIN_VALUE <= code && code <= Byte.MAX_VALUE, "Extension type code must be within the range of byte");
54+
return (byte) code;
55+
}
56+
57+
public byte getType()
58+
{
59+
return type;
60+
}
61+
62+
public int getLength()
63+
{
64+
return length;
65+
}
66+
67+
@Override
68+
public int hashCode()
69+
{
70+
return (type + 31) * 31 + length;
71+
}
72+
73+
@Override
74+
public boolean equals(Object obj)
75+
{
76+
if (obj instanceof ExtensionTypeHeader) {
77+
ExtensionTypeHeader other = (ExtensionTypeHeader) obj;
78+
return this.type == other.type && this.length == other.length;
79+
}
80+
return false;
81+
}
82+
83+
@Override
84+
public String toString()
85+
{
86+
return String.format("ExtensionTypeHeader(type:%d, length:%,d)", type, length);
87+
}
88+
}

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

Lines changed: 0 additions & 20 deletions
This file was deleted.

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

Lines changed: 42 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,29 @@
1+
//
2+
// MessagePack for Java
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
//
116
package org.msgpack.core;
217

318
import org.msgpack.core.MessagePack.Code;
419
import org.msgpack.core.annotations.VisibleForTesting;
520
import org.msgpack.value.ValueType;
621

7-
822
/**
923
* Describes the list of the message format types defined in the MessagePack specification.
1024
*/
11-
public enum MessageFormat {
12-
25+
public enum MessageFormat
26+
{
1327
// INT7
1428
POSFIXINT(ValueType.INTEGER),
1529
// MAP4
@@ -24,9 +38,9 @@ public enum MessageFormat {
2438
BIN8(ValueType.BINARY),
2539
BIN16(ValueType.BINARY),
2640
BIN32(ValueType.BINARY),
27-
EXT8(ValueType.EXTENDED),
28-
EXT16(ValueType.EXTENDED),
29-
EXT32(ValueType.EXTENDED),
41+
EXT8(ValueType.EXTENSION),
42+
EXT16(ValueType.EXTENSION),
43+
EXT32(ValueType.EXTENSION),
3044
FLOAT32(ValueType.FLOAT),
3145
FLOAT64(ValueType.FLOAT),
3246
UINT8(ValueType.INTEGER),
@@ -38,64 +52,71 @@ public enum MessageFormat {
3852
INT16(ValueType.INTEGER),
3953
INT32(ValueType.INTEGER),
4054
INT64(ValueType.INTEGER),
41-
FIXEXT1(ValueType.EXTENDED),
42-
FIXEXT2(ValueType.EXTENDED),
43-
FIXEXT4(ValueType.EXTENDED),
44-
FIXEXT8(ValueType.EXTENDED),
45-
FIXEXT16(ValueType.EXTENDED),
55+
FIXEXT1(ValueType.EXTENSION),
56+
FIXEXT2(ValueType.EXTENSION),
57+
FIXEXT4(ValueType.EXTENSION),
58+
FIXEXT8(ValueType.EXTENSION),
59+
FIXEXT16(ValueType.EXTENSION),
4660
STR8(ValueType.STRING),
4761
STR16(ValueType.STRING),
4862
STR32(ValueType.STRING),
4963
ARRAY16(ValueType.ARRAY),
5064
ARRAY32(ValueType.ARRAY),
5165
MAP16(ValueType.MAP),
5266
MAP32(ValueType.MAP),
53-
NEGFIXINT(ValueType.INTEGER)
54-
;
67+
NEGFIXINT(ValueType.INTEGER);
5568

69+
private static final MessageFormat[] formatTable = new MessageFormat[256];
5670
private final ValueType valueType;
5771

58-
private MessageFormat(ValueType valueType) {
72+
private MessageFormat(ValueType valueType)
73+
{
5974
this.valueType = valueType;
6075
}
6176

6277
/**
6378
* Retruns the ValueType corresponding to this MessageFormat
79+
*
6480
* @return value type
6581
* @throws MessageFormatException if this == NEVER_USED type
6682
*/
67-
public ValueType getValueType() throws MessageFormatException {
68-
if(this == NEVER_USED)
83+
public ValueType getValueType()
84+
throws MessageFormatException
85+
{
86+
if (this == NEVER_USED) {
6987
throw new MessageFormatException("Cannot convert NEVER_USED to ValueType");
88+
}
7089
return valueType;
7190
}
7291

73-
private final static MessageFormat[] formatTable = new MessageFormat[256];
74-
7592
static {
7693
// Preparing a look up table for converting byte values into MessageFormat types
77-
for(int b = 0; b <= 0xFF; ++b) {
94+
for (int b = 0; b <= 0xFF; ++b) {
7895
MessageFormat mf = toMessageFormat((byte) b);
7996
formatTable[b] = mf;
8097
}
8198
}
8299

83100
/**
84101
* Returns a MessageFormat type of the specified byte value
102+
*
85103
* @param b MessageFormat of the given byte
86104
* @return
87105
*/
88-
public static MessageFormat valueOf(final byte b) {
106+
public static MessageFormat valueOf(final byte b)
107+
{
89108
return formatTable[b & 0xFF];
90109
}
91110

92111
/**
93112
* Converting a byte value into MessageFormat. For faster performance, use {@link #valueOf}
113+
*
94114
* @param b MessageFormat of the given byte
95115
* @return
96116
*/
97117
@VisibleForTesting
98-
public static MessageFormat toMessageFormat(final byte b) {
118+
static MessageFormat toMessageFormat(final byte b)
119+
{
99120
if (Code.isPosFixInt(b)) {
100121
return POSFIXINT;
101122
}
@@ -177,5 +198,4 @@ public static MessageFormat toMessageFormat(final byte b) {
177198
return NEVER_USED;
178199
}
179200
}
180-
181201
}

0 commit comments

Comments
 (0)