mirror of
https://github.com/msgpack/msgpack-python.git
synced 2026-02-07 10:19:51 +00:00
java: add packByteBuffer method in Packer.java because I needed non-nullcheck pack(ByteBuffer) for refining ByteBufferTemplate.java
This commit is contained in:
parent
cb7a4b3116
commit
4e4678edfa
1 changed files with 7 additions and 3 deletions
|
|
@ -399,6 +399,11 @@ public class Packer {
|
|||
return packRawBody(b, off, length);
|
||||
}
|
||||
|
||||
public Packer packByteBuffer(ByteBuffer buf) throws IOException {
|
||||
packRaw(buf.remaining());
|
||||
return packRawBody(buf.array(), buf.arrayOffset() + buf.position(), buf.remaining());
|
||||
}
|
||||
|
||||
public Packer packString(String s) throws IOException {
|
||||
byte[] b = ((String)s).getBytes("UTF-8");
|
||||
packRaw(b.length);
|
||||
|
|
@ -495,9 +500,8 @@ public class Packer {
|
|||
|
||||
public Packer pack(ByteBuffer o) throws IOException {
|
||||
if (o == null) { return packNil(); }
|
||||
ByteBuffer buf = (ByteBuffer) o;
|
||||
packRaw(buf.remaining());
|
||||
return packRawBody(buf.array(), buf.arrayOffset() + buf.position(), buf.remaining());
|
||||
packRaw(o.remaining());
|
||||
return packRawBody(o.array(), o.arrayOffset() + o.position(), o.remaining());
|
||||
}
|
||||
|
||||
public Packer pack(List o) throws IOException {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue