mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-03-20 05:27:56 +01: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
@ -399,6 +399,11 @@ public class Packer {
|
|||||||
return packRawBody(b, off, length);
|
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 {
|
public Packer packString(String s) throws IOException {
|
||||||
byte[] b = ((String)s).getBytes("UTF-8");
|
byte[] b = ((String)s).getBytes("UTF-8");
|
||||||
packRaw(b.length);
|
packRaw(b.length);
|
||||||
@ -495,9 +500,8 @@ public class Packer {
|
|||||||
|
|
||||||
public Packer pack(ByteBuffer o) throws IOException {
|
public Packer pack(ByteBuffer o) throws IOException {
|
||||||
if (o == null) { return packNil(); }
|
if (o == null) { return packNil(); }
|
||||||
ByteBuffer buf = (ByteBuffer) o;
|
packRaw(o.remaining());
|
||||||
packRaw(buf.remaining());
|
return packRawBody(o.array(), o.arrayOffset() + o.position(), o.remaining());
|
||||||
return packRawBody(buf.array(), buf.arrayOffset() + buf.position(), buf.remaining());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Packer pack(List o) throws IOException {
|
public Packer pack(List o) throws IOException {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user