Skip to content

Commit 305ecb2

Browse files
committed
MessagePack.pack/unpack -> write/read
1 parent 9a807a4 commit 305ecb2

3 files changed

Lines changed: 27 additions & 27 deletions

File tree

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

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -45,81 +45,81 @@ public MessagePack(MessagePack parent) {
4545
registry = new TemplateRegistry(parent.registry);
4646
}
4747

48-
public byte[] pack(Object v) throws IOException {
49-
return pack(v, getTemplate(v.getClass()));
48+
public byte[] write(Object v) throws IOException {
49+
return write(v, getTemplate(v.getClass()));
5050
}
5151

52-
public byte[] pack(Object v, Template tmpl) throws IOException { // TODO IOException
53-
BufferPacker pk = new BufferPacker();
54-
tmpl.write(pk, v);
55-
return pk.toByteArray();
52+
public byte[] write(Object v, Template tmpl) throws IOException { // TODO IOException
53+
BufferPacker pk = new BufferPacker();
54+
tmpl.write(pk, v);
55+
return pk.toByteArray();
5656
}
5757

58-
public void pack(OutputStream out, Object v) throws IOException {
59-
pack(out, v, getTemplate(v.getClass()));
58+
public void write(OutputStream out, Object v) throws IOException {
59+
write(out, v, getTemplate(v.getClass()));
6060
}
6161

62-
public void pack(OutputStream out, Object v, Template tmpl) throws IOException {
62+
public void write(OutputStream out, Object v, Template tmpl) throws IOException {
6363
StreamPacker pk = new StreamPacker(out);
6464
tmpl.write(pk, v);
6565
}
6666

67-
public byte[] pack(Value v) throws IOException { // TODO IOException
67+
public byte[] write(Value v) throws IOException { // TODO IOException
6868
// FIXME ValueTemplate should do this
6969
BufferPacker pk = new BufferPacker();
7070
pk.write(v);
7171
return pk.toByteArray();
7272
}
7373

74-
public <T> T unpack(InputStream in, T v) throws IOException {
74+
public <T> T read(InputStream in, T v) throws IOException {
7575
// TODO
7676
Template tmpl = getTemplate(v.getClass());
7777
return (T)tmpl.read(new StreamUnpacker(in), v);
7878
}
7979

80-
public <T> T unpack(InputStream in, Class<T> c) throws IOException {
80+
public <T> T read(InputStream in, Class<T> c) throws IOException {
8181
// TODO
8282
Template tmpl = getTemplate(c);
8383
return (T)tmpl.read(new StreamUnpacker(in), null);
8484
}
8585

86-
public Value unpack(byte[] b) throws IOException { // TODO IOException
87-
return unpack(b, 0, b.length);
86+
public Value read(byte[] b) throws IOException { // TODO IOException
87+
return read(b, 0, b.length);
8888
}
8989

90-
public Value unpack(byte[] b, int off, int len) throws IOException { // TODO IOException
90+
public Value read(byte[] b, int off, int len) throws IOException { // TODO IOException
9191
return new BufferUnpacker().wrap(b, off, len).readValue();
9292
}
9393

94-
public Value unpack(ByteBuffer buf) throws IOException { // TODO IOException
94+
public Value read(ByteBuffer buf) throws IOException { // TODO IOException
9595
return new BufferUnpacker().wrap(buf).readValue();
9696
}
9797

98-
public <T> T unpack(byte[] b, T v) throws IOException { // TODO IOException
98+
public <T> T read(byte[] b, T v) throws IOException { // TODO IOException
9999
// TODO
100100
Template tmpl = getTemplate(v.getClass());
101101
BufferUnpacker u = new BufferUnpacker();
102102
u.wrap(b);
103103
return (T)tmpl.read(u, v);
104104
}
105105

106-
public <T> T unpack(byte[] b, Class<T> c) throws IOException { // TODO IOException
106+
public <T> T read(byte[] b, Class<T> c) throws IOException { // TODO IOException
107107
// TODO
108108
Template tmpl = getTemplate(c);
109109
BufferUnpacker u = new BufferUnpacker();
110110
u.wrap(b);
111111
return (T)tmpl.read(u, null);
112112
}
113113

114-
public <T> T unpack(ByteBuffer b, T v) throws IOException { // TODO IOException
114+
public <T> T read(ByteBuffer b, T v) throws IOException { // TODO IOException
115115
// TODO
116116
Template tmpl = getTemplate(v.getClass());
117117
BufferUnpacker u = new BufferUnpacker();
118118
u.wrap(b);
119119
return (T)tmpl.read(u, v);
120120
}
121121

122-
public <T> T unpack(ByteBuffer b, Class<T> c) { // TODO IOException
122+
public <T> T read(ByteBuffer b, Class<T> c) { // TODO IOException
123123
// TODO
124124
Template tmpl = getTemplate(c);
125125
BufferUnpacker u = new BufferUnpacker();

src/test/java/org/msgpack/TestSimpleConvertUnconvert.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ public class TestSimpleConvertUnconvert {
2424
@Test
2525
public void testSimpleConvert() throws IOException {
2626
MessagePack msgpack = new MessagePack();
27-
byte[] raw = msgpack.pack(new int[] {1,2,3});
27+
byte[] raw = msgpack.write(new int[] {1,2,3});
2828

29-
Value v = msgpack.unpack(raw);
29+
Value v = msgpack.read(raw);
3030

3131
int[] array = msgpack.convert(v, new int[3]);
3232
assertArrayEquals(new int[] {1,2,3}, array);

src/test/java/org/msgpack/TestSimplePackUnpack.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ public class TestSimplePackUnpack {
2222
@Test
2323
public void testSimplePackUnpack() throws IOException {
2424
MessagePack msgpack = new MessagePack();
25-
byte[] raw = msgpack.pack(new int[] {1,2,3});
25+
byte[] raw = msgpack.write(new int[] {1,2,3});
2626

27-
Value v = msgpack.unpack(raw);
28-
int[] a = msgpack.unpack(raw, new int[3]);
27+
Value v = msgpack.read(raw);
28+
int[] a = msgpack.read(raw, new int[3]);
2929

30-
Value vb = msgpack.unpack(ByteBuffer.wrap(raw));
31-
int[] ab = msgpack.unpack(ByteBuffer.wrap(raw), new int[3]);
30+
Value vb = msgpack.read(ByteBuffer.wrap(raw));
31+
int[] ab = msgpack.read(ByteBuffer.wrap(raw), new int[3]);
3232
}
3333
}
3434

0 commit comments

Comments
 (0)