Skip to content

Commit 356eb36

Browse files
committed
Converter and Unconverter throw IOException
1 parent a7aa362 commit 356eb36

File tree

8 files changed

+92
-316
lines changed

8 files changed

+92
-316
lines changed

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public byte[] write(Object v) throws IOException {
9191
return pk.toByteArray();
9292
}
9393

94-
public <T> byte[] write(T v, Template<T> tmpl) throws IOException { // TODO IOException
94+
public <T> byte[] write(T v, Template<T> tmpl) throws IOException {
9595
BufferPacker pk = createBufferPacker();
9696
tmpl.write(pk, v);
9797
return pk.toByteArray();
@@ -112,49 +112,49 @@ public <T> void write(OutputStream out, T v, Template<T> tmpl) throws IOExceptio
112112
tmpl.write(pk, v);
113113
}
114114

115-
public byte[] write(Value v) throws IOException { // TODO IOException
115+
public byte[] write(Value v) throws IOException {
116116
// FIXME ValueTemplate should do this
117117
BufferPacker pk = createBufferPacker();
118118
pk.write(v);
119119
return pk.toByteArray();
120120
}
121121

122-
public Value read(byte[] b) throws IOException { // TODO IOException
122+
public Value read(byte[] b) throws IOException {
123123
return read(b, 0, b.length);
124124
}
125125

126-
public Value read(byte[] b, int off, int len) throws IOException { // TODO IOException
126+
public Value read(byte[] b, int off, int len) throws IOException {
127127
return createBufferUnpacker(b, off, len).readValue();
128128
}
129129

130-
public Value read(ByteBuffer buf) throws IOException { // TODO IOException
130+
public Value read(ByteBuffer buf) throws IOException {
131131
return createBufferUnpacker(buf).readValue();
132132
}
133133

134134
public Value read(InputStream in) throws IOException {
135135
return createUnpacker(in).readValue();
136136
}
137137

138-
public <T> T read(byte[] b, T v) throws IOException { // TODO IOException
138+
public <T> T read(byte[] b, T v) throws IOException {
139139
// TODO
140140
Template tmpl = registry.lookup(v.getClass());
141141
BufferUnpacker u = createBufferUnpacker(b);
142142
return (T) tmpl.read(u, v);
143143
}
144144

145-
public <T> T read(byte[] b, Class<T> c) throws IOException { // TODO IOException
145+
public <T> T read(byte[] b, Class<T> c) throws IOException {
146146
Template<T> tmpl = registry.lookup(c);
147147
BufferUnpacker u = createBufferUnpacker(b);
148148
return tmpl.read(u, null);
149149
}
150150

151-
public <T> T read(ByteBuffer b, T v) throws IOException { // TODO IOException
151+
public <T> T read(ByteBuffer b, T v) throws IOException {
152152
Template<T> tmpl = registry.lookup(v.getClass());
153153
BufferUnpacker u = createBufferUnpacker(b);
154154
return tmpl.read(u, v);
155155
}
156156

157-
public <T> T read(ByteBuffer b, Class<T> c) { // TODO IOException
157+
public <T> T read(ByteBuffer b, Class<T> c) {
158158
Template<T> tmpl = registry.lookup(c);
159159
BufferUnpacker u = createBufferUnpacker(b);
160160
return null;
@@ -170,7 +170,7 @@ public <T> T read(InputStream in, Class<T> c) throws IOException {
170170
return tmpl.read(createUnpacker(in), null);
171171
}
172172

173-
public <T> T convert(Value v, T to) throws IOException { // TODO IOException
173+
public <T> T convert(Value v, T to) throws IOException {
174174
Template<T> tmpl = registry.lookup(to.getClass());
175175
return tmpl.read(new Converter(this, v), to);
176176
}

src/main/java/org/msgpack/packer/Unconverter.java

Lines changed: 18 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
//
1818
package org.msgpack.packer;
1919

20+
import java.io.IOException;
2021
import java.math.BigInteger;
2122
import java.nio.ByteBuffer;
2223

@@ -51,72 +52,67 @@ public void resetResult() {
5152
}
5253

5354
@Override
54-
public void writeNil() {
55+
public void writeNil() throws IOException {
5556
put(ValueFactory.nilValue());
5657
}
5758

5859
@Override
59-
public void writeBoolean(boolean v) {
60+
public void writeBoolean(boolean v) throws IOException {
6061
put(ValueFactory.booleanValue(v));
6162
}
6263

6364
@Override
64-
public void writeByte(byte v) {
65+
public void writeByte(byte v) throws IOException {
6566
put(ValueFactory.integerValue(v));
6667
}
6768

6869
@Override
69-
public void writeShort(short v) {
70+
public void writeShort(short v) throws IOException {
7071
put(ValueFactory.integerValue(v));
7172
}
7273

7374
@Override
74-
public void writeInt(int v) {
75+
public void writeInt(int v) throws IOException {
7576
put(ValueFactory.integerValue(v));
7677
}
7778

7879
@Override
79-
public void writeBigInteger(BigInteger v) {
80+
public void writeBigInteger(BigInteger v) throws IOException {
8081
put(ValueFactory.integerValue(v));
8182
}
8283

8384
@Override
84-
public void writeLong(long v) {
85+
public void writeLong(long v) throws IOException {
8586
put(ValueFactory.integerValue(v));
8687
}
8788

8889
@Override
89-
public void writeFloat(float v) {
90+
public void writeFloat(float v) throws IOException {
9091
put(ValueFactory.floatValue(v));
9192
}
9293

9394
@Override
94-
public void writeDouble(double v) {
95+
public void writeDouble(double v) throws IOException {
9596
put(ValueFactory.floatValue(v));
9697
}
9798

9899
@Override
99-
public void writeByteArray(byte[] b) {
100-
writeByteArray(b, 0, b.length);
101-
}
102-
103-
@Override
104-
public void writeByteArray(byte[] b, int off, int len) {
100+
public void writeByteArray(byte[] b, int off, int len) throws IOException {
105101
put(ValueFactory.rawValue(b, off, len));
106102
}
107103

108104
@Override
109-
public void writeByteBuffer(ByteBuffer bb) {
105+
public void writeByteBuffer(ByteBuffer bb) throws IOException {
110106
put(ValueFactory.rawValue(bb));
111107
}
112108

113109
@Override
114-
public void writeString(String s) {
110+
public void writeString(String s) throws IOException {
115111
put(ValueFactory.rawValue(s));
116112
}
117113

118114
@Override
119-
public void writeArrayBegin(int size) {
115+
public void writeArrayBegin(int size) throws IOException {
120116
if(size == 0) {
121117
Value[] array = new Value[size];
122118
putContainer(ValueFactory.arrayValue());
@@ -131,12 +127,7 @@ public void writeArrayBegin(int size) {
131127
}
132128

133129
@Override
134-
public void writeArrayEnd() {
135-
writeArrayEnd(true);
136-
}
137-
138-
@Override
139-
public void writeArrayEnd(boolean check) {
130+
public void writeArrayEnd(boolean check) throws IOException {
140131
if(!stack.topIsArray()) {
141132
throw new MessageTypeException("writeArrayEnd() is called but writeArrayBegin() is not called");
142133
}
@@ -157,7 +148,7 @@ public void writeArrayEnd(boolean check) {
157148
}
158149

159150
@Override
160-
public void writeMapBegin(int size) {
151+
public void writeMapBegin(int size) throws IOException {
161152
stack.checkCount();
162153
if(size == 0) {
163154
putContainer(ValueFactory.mapValue());
@@ -172,12 +163,7 @@ public void writeMapBegin(int size) {
172163
}
173164

174165
@Override
175-
public void writeMapEnd() {
176-
writeMapEnd(true);
177-
}
178-
179-
@Override
180-
public void writeMapEnd(boolean check) {
166+
public void writeMapEnd(boolean check) throws IOException {
181167
if(!stack.topIsMap()) {
182168
throw new MessageTypeException("writeMapEnd() is called but writeMapBegin() is not called");
183169
}
@@ -198,7 +184,7 @@ public void writeMapEnd(boolean check) {
198184
}
199185

200186
@Override
201-
public Packer write(Value v) {
187+
public Packer write(Value v) throws IOException {
202188
put(v);
203189
return this;
204190
}
@@ -224,9 +210,5 @@ private void putContainer(Value v) {
224210
stack.reduceCount();
225211
}
226212
}
227-
228-
@Override
229-
public void close() {
230-
}
231213
}
232214

src/main/java/org/msgpack/unpacker/AbstractIndirectUnpacker.java

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

0 commit comments

Comments
 (0)