Skip to content

Commit 02bd129

Browse files
committed
Add read(byte[] bytes, int off, int len, Class<T> c) method
1 parent 3f078e7 commit 02bd129

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,23 @@ public <T> T read(byte[] bytes, T v) throws IOException {
340340
return read(bytes, v, tmpl);
341341
}
342342

343+
/**
344+
* Deserializes byte array to object.
345+
*
346+
* @since 0.6.0
347+
* @param bytes
348+
* input byte array
349+
* @param v
350+
* @return
351+
* @throws IOException
352+
*/
353+
public <T> T read(byte[] bytes, int off, int len, Class<T> c) throws IOException {
354+
@SuppressWarnings("unchecked")
355+
Template<T> tmpl = registry.lookup(c);
356+
BufferUnpacker u = createBufferUnpacker(bytes, off, len);
357+
return (T) tmpl.read(u, null);
358+
}
359+
343360
/**
344361
* Deserializes byte array to object according to template.
345362
*

0 commit comments

Comments
 (0)