Skip to content

Commit e2fc4e6

Browse files
committed
Renmae ExtendedType -> ExtensionType
1 parent 2ff4f59 commit e2fc4e6

23 files changed

+189
-197
lines changed

README.md

Lines changed: 2 additions & 1 deletion
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

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 renamed to msgpack-core/src/main/java/org/msgpack/core/ExtensionTypeHeader.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
import static org.msgpack.core.Preconditions.*;
44

55
/**
6-
* Header of the extended types
6+
* Header of the Extension types
77
*/
8-
public class ExtendedTypeHeader {
8+
public class ExtensionTypeHeader {
99
private final byte type;
1010
private final int length;
1111

12-
ExtendedTypeHeader(byte type, int length) {
12+
ExtensionTypeHeader(byte type, int length) {
1313
checkArgument(length >= 0, String.format("length must be >= 0: %,d", length));
1414
this.length = length;
1515
this.type = type;
@@ -30,16 +30,16 @@ public int hashCode() {
3030

3131
@Override
3232
public boolean equals(Object obj) {
33-
if(obj instanceof ExtendedTypeHeader) {
34-
ExtendedTypeHeader other = (ExtendedTypeHeader) obj;
33+
if(obj instanceof ExtensionTypeHeader) {
34+
ExtensionTypeHeader other = (ExtensionTypeHeader) obj;
3535
return this.type == other.type && this.length == other.length;
3636
}
3737
return false;
3838
}
3939

4040
@Override
4141
public String toString() {
42-
return String.format("ExtendedTypeHeader(type:%d, length:%,d)", type, length);
42+
return String.format("ExtensionTypeHeader(type:%d, length:%,d)", type, length);
4343
}
4444

4545
}

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ public enum MessageFormat {
2424
BIN8(ValueType.BINARY),
2525
BIN16(ValueType.BINARY),
2626
BIN32(ValueType.BINARY),
27-
EXT8(ValueType.EXTENDED),
28-
EXT16(ValueType.EXTENDED),
29-
EXT32(ValueType.EXTENDED),
27+
EXT8(ValueType.EXTENSION),
28+
EXT16(ValueType.EXTENSION),
29+
EXT32(ValueType.EXTENSION),
3030
FLOAT32(ValueType.FLOAT),
3131
FLOAT64(ValueType.FLOAT),
3232
UINT8(ValueType.INTEGER),
@@ -38,11 +38,11 @@ public enum MessageFormat {
3838
INT16(ValueType.INTEGER),
3939
INT32(ValueType.INTEGER),
4040
INT64(ValueType.INTEGER),
41-
FIXEXT1(ValueType.EXTENDED),
42-
FIXEXT2(ValueType.EXTENDED),
43-
FIXEXT4(ValueType.EXTENDED),
44-
FIXEXT8(ValueType.EXTENDED),
45-
FIXEXT16(ValueType.EXTENDED),
41+
FIXEXT1(ValueType.EXTENSION),
42+
FIXEXT2(ValueType.EXTENSION),
43+
FIXEXT4(ValueType.EXTENSION),
44+
FIXEXT8(ValueType.EXTENSION),
45+
FIXEXT16(ValueType.EXTENSION),
4646
STR8(ValueType.STRING),
4747
STR16(ValueType.STRING),
4848
STR32(ValueType.STRING),

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ public MessagePacker packString(String s) throws IOException {
379379
flush();
380380

381381
prepareBuffer();
382-
boolean isExtended = false;
382+
boolean isExtension = false;
383383
ByteBuffer encodeBuffer = buffer.toByteBuffer(position, buffer.size() - position);
384384
encoder.reset();
385385
while(in.hasRemaining()) {
@@ -400,7 +400,7 @@ public MessagePacker packString(String s) throws IOException {
400400
// Coy the current encodeBuffer contents to the new buffer
401401
newBuffer.put(encodeBuffer);
402402
encodeBuffer = newBuffer;
403-
isExtended = true;
403+
isExtension = true;
404404
encoder.reset();
405405
continue;
406406
}
@@ -434,7 +434,7 @@ public MessagePacker packString(String s) throws IOException {
434434
flush(); // We need to dump the data here to MessageBufferOutput so that we can switch back to the original buffer
435435

436436
// Reset to the original buffer (or encodeBuffer if new buffer is allocated)
437-
buffer = isExtended ? MessageBuffer.wrap(encodeBuffer) : tmpBuf;
437+
buffer = isExtension ? MessageBuffer.wrap(encodeBuffer) : tmpBuf;
438438
// No need exists to write payload since the encoded string (payload) is already written to the buffer
439439
position = strLen;
440440
return this;
@@ -477,7 +477,7 @@ public MessagePacker packValue(Value v) throws IOException {
477477
return this;
478478
}
479479

480-
public MessagePacker packExtendedTypeHeader(int extType, int payloadLen) throws IOException {
480+
public MessagePacker packExtensionTypeHeader(int extType, int payloadLen) throws IOException {
481481
if(payloadLen < (1 << 8)) {
482482
if(payloadLen > 0 && (payloadLen & (payloadLen - 1)) == 0) { // check whether dataLen == 2^x
483483
if(payloadLen == 1) {

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

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
import org.msgpack.value.Value;
3838
import org.msgpack.value.ImmutableValue;
3939
import org.msgpack.value.Variable;
40-
import org.msgpack.value.ValueType;
4140
import org.msgpack.value.ValueFactory;
4241

4342
import static org.msgpack.core.Preconditions.*;
@@ -580,9 +579,9 @@ public ImmutableValue unpackValue() throws IOException {
580579
}
581580
return ValueFactory.newMapValue(kvs);
582581
}
583-
case EXTENDED: {
584-
ExtendedTypeHeader extHeader = unpackExtendedTypeHeader();
585-
return ValueFactory.newExtendedValue(extHeader.getType(), readPayload(extHeader.getLength()));
582+
case EXTENSION: {
583+
ExtensionTypeHeader extHeader = unpackExtensionTypeHeader();
584+
return ValueFactory.newExtensionValue(extHeader.getType(), readPayload(extHeader.getLength()));
586585
}
587586
default:
588587
throw new MessageFormatException("Unknown value type");
@@ -648,9 +647,9 @@ public Variable unpackValue(Variable var) throws IOException {
648647
var.setMapValue(map);
649648
return var;
650649
}
651-
case EXTENDED: {
652-
ExtendedTypeHeader extHeader = unpackExtendedTypeHeader();
653-
var.setExtendedValue(extHeader.getType(), readPayload(extHeader.getLength()));
650+
case EXTENSION: {
651+
ExtensionTypeHeader extHeader = unpackExtensionTypeHeader();
652+
var.setExtensionValue(extHeader.getType(), readPayload(extHeader.getLength()));
654653
return var;
655654
}
656655
default:
@@ -1042,33 +1041,33 @@ public int unpackMapHeader() throws IOException {
10421041
throw unexpected("Map", b);
10431042
}
10441043

1045-
public ExtendedTypeHeader unpackExtendedTypeHeader() throws IOException {
1044+
public ExtensionTypeHeader unpackExtensionTypeHeader() throws IOException {
10461045
byte b = consume();
10471046
switch(b) {
10481047
case Code.FIXEXT1:
1049-
return new ExtendedTypeHeader(readByte(), 1);
1048+
return new ExtensionTypeHeader(readByte(), 1);
10501049
case Code.FIXEXT2:
1051-
return new ExtendedTypeHeader(readByte(), 2);
1050+
return new ExtensionTypeHeader(readByte(), 2);
10521051
case Code.FIXEXT4:
1053-
return new ExtendedTypeHeader(readByte(), 4);
1052+
return new ExtensionTypeHeader(readByte(), 4);
10541053
case Code.FIXEXT8:
1055-
return new ExtendedTypeHeader(readByte(), 8);
1054+
return new ExtensionTypeHeader(readByte(), 8);
10561055
case Code.FIXEXT16:
1057-
return new ExtendedTypeHeader(readByte(), 16);
1056+
return new ExtensionTypeHeader(readByte(), 16);
10581057
case Code.EXT8: {
10591058
int length = readNextLength8();
10601059
byte type = readByte();
1061-
return new ExtendedTypeHeader(type, length);
1060+
return new ExtensionTypeHeader(type, length);
10621061
}
10631062
case Code.EXT16: {
10641063
int length = readNextLength16();
10651064
byte type = readByte();
1066-
return new ExtendedTypeHeader(type, length);
1065+
return new ExtensionTypeHeader(type, length);
10671066
}
10681067
case Code.EXT32: {
10691068
int length = readNextLength32();
10701069
byte type = readByte();
1071-
return new ExtendedTypeHeader(type, length);
1070+
return new ExtensionTypeHeader(type, length);
10721071
}
10731072
}
10741073

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
package org.msgpack.core.example;
1717

1818
import org.msgpack.core.*;
19-
import org.msgpack.core.buffer.MessageBuffer;
2019
import org.msgpack.value.*;
2120

2221
import java.math.BigInteger;
@@ -126,7 +125,7 @@ public static void packer() throws IOException {
126125

127126
// Write ext type data: https://github.com/msgpack/msgpack/blob/master/spec.md#ext-format-family
128127
byte[] extData = "custom data type".getBytes(MessagePack.UTF8);
129-
packer.packExtendedTypeHeader(1, 10); // type number [0, 127], data byte length
128+
packer.packExtensionTypeHeader(1, 10); // type number [0, 127], data byte length
130129
packer.writePayload(extData);
131130

132131
// Succinct syntax for packing
@@ -217,8 +216,8 @@ else if (iv.isInLongRange()) {
217216
System.out.println("read array element: " + e);
218217
}
219218
break;
220-
case EXTENDED:
221-
ExtendedValue ev = v.asExtendedValue();
219+
case EXTENSION:
220+
ExtensionValue ev = v.asExtensionValue();
222221
byte extType = ev.getType();
223222
byte[] extValue = ev.getData();
224223
break;

msgpack-core/src/main/java/org/msgpack/value/ExtendedValue.java renamed to msgpack-core/src/main/java/org/msgpack/value/ExtensionValue.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,16 @@
1616
package org.msgpack.value;
1717

1818
/**
19-
* The interface {@code ExtendedValue} represents MessagePack's Extended type.
19+
* The interface {@code ExtensionValue} represents MessagePack's Extension type.
2020
*
21-
* MessagePack's Extended type can represent represents a tuple of type information and a byte array where type information is an integer whose meaning is defined by applications.
21+
* MessagePack's Extension type can represent represents a tuple of type information and a byte array where type information is an
22+
* integer whose meaning is defined by applications.
2223
*
2324
* As the type information, applications can use 0 to 127 as the application-specific types. -1 to -128 is reserved for MessagePack's future extension.
2425
*/
25-
public interface ExtendedValue extends Value {
26+
public interface ExtensionValue extends Value {
2627
@Override
27-
public ImmutableExtendedValue immutableValue();
28+
public ImmutableExtensionValue immutableValue();
2829

2930
public byte getType();
3031

msgpack-core/src/main/java/org/msgpack/value/ImmutableExtendedValue.java renamed to msgpack-core/src/main/java/org/msgpack/value/ImmutableExtensionValue.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@
1515
//
1616
package org.msgpack.value;
1717

18-
public interface ImmutableExtendedValue extends ExtendedValue, ImmutableValue {
18+
public interface ImmutableExtensionValue extends ExtensionValue, ImmutableValue {
1919
}

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

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package org.msgpack.value;
1717

1818
import org.msgpack.core.MessagePacker;
19+
import org.msgpack.core.MessageTypeCastException;
1920

2021
import java.io.IOException;
2122

@@ -119,12 +120,13 @@ public interface Value {
119120
public boolean isMapValue();
120121

121122
/**
122-
* Returns true if type of this an Extended.
123+
* Returns true if type of this an Extension.
123124
*
124-
* If this method returns true, {@code asExtendedValue} never throws exceptions.
125-
* Note that you can't use <code>instanceof</code> or cast <code>((ExtendedValue) thisValue)</code> to check type of a value because type of a mutable value is variable.
125+
* If this method returns true, {@code asExtensionValue} never throws exceptions.
126+
* Note that you can't use <code>instanceof</code> or cast <code>((ExtensionValue) thisValue)</code> to check type of a value because
127+
* type of a mutable value is variable.
126128
*/
127-
public boolean isExtendedValue();
129+
public boolean isExtensionValue();
128130

129131
/**
130132
* Returns the value as {@code NilValue}. Otherwise throws {@code MessageTypeCastException}.
@@ -227,14 +229,15 @@ public interface Value {
227229
public MapValue asMapValue();
228230

229231
/**
230-
* Returns the value as {@code ExtendedValue}. Otherwise throws {@code MessageTypeCastException}.
232+
* Returns the value as {@code ExtensionValue}. Otherwise throws {@code MessageTypeCastException}.
231233
*
232-
* Note that you can't use <code>instanceof</code> or cast <code>((ExtendedValue) thisValue)</code> to check type of a value because type of a mutable value is variable.
234+
* Note that you can't use <code>instanceof</code> or cast <code>((ExtensionValue) thisValue)</code> to check type of a value
235+
* because type of a mutable value is variable.
233236
*
234237
* @throws MessageTypeCastException
235-
* If type of this value is not Extended.
238+
* If type of this value is not an Extension.
236239
*/
237-
public ExtendedValue asExtendedValue();
240+
public ExtensionValue asExtensionValue();
238241

239242
/**
240243
* Serializes the value using the specified {@code MessagePacker}

0 commit comments

Comments
 (0)