This commit is contained in:
redkale
2024-09-29 00:23:01 +08:00
parent 71cfd9e1cd
commit 73eb306eb2
8 changed files with 30 additions and 9 deletions

View File

@@ -67,7 +67,6 @@ public class BsonByteBufferReader extends BsonReader {
/**
* 判断下一个非空白字节是否为[
*
* @param member DeMember
* @param typevals byte[]
* @param componentDecoder Decodeable
* @return 数组长度或 SIGN_NULL

View File

@@ -137,7 +137,7 @@ public class BsonByteBufferWriter extends BsonWriter {
@Override
public final byte[] toArray() {
throw new UnsupportedOperationException("Not supported yet."); // 无需实现
return toByteArray().getBytes();
}
@Override

View File

@@ -25,7 +25,7 @@ public class JsonByteBufferReader extends JsonReader {
private ByteBuffer[] buffers;
private ByteBuffer currentBuffer;
private int currBufIndex = 0;
protected JsonByteBufferReader(ByteBuffer... buffers) {

View File

@@ -65,6 +65,17 @@ public class JsonByteBufferWriter extends JsonWriter {
return this.buffers;
}
public ByteArray toByteArray() {
ByteArray array = new ByteArray();
if (buffers != null) {
for (ByteBuffer buf : toBuffers()) {
array.put(buf);
buf.flip();
}
}
return array;
}
public int count() {
if (this.buffers == null) {
return 0;

View File

@@ -8,6 +8,7 @@ package org.redkale.convert.pb;
import java.nio.ByteBuffer;
import java.util.Objects;
import java.util.function.Supplier;
import org.redkale.util.ByteArray;
import org.redkale.util.Utility;
/** @author zhangjx */
@@ -48,6 +49,17 @@ public class ProtobufByteBufferWriter extends ProtobufWriter {
return this.buffers;
}
public ByteArray toByteArray() {
ByteArray array = new ByteArray();
if (buffers != null) {
for (ByteBuffer buf : toBuffers()) {
array.put(buf);
buf.flip();
}
}
return array;
}
@Override
protected int expand(final int byteLength) {
if (this.buffers == null) {
@@ -154,7 +166,7 @@ public class ProtobufByteBufferWriter extends ProtobufWriter {
@Override
public final byte[] toArray() {
throw new UnsupportedOperationException("Not supported yet."); // 无需实现
return toByteArray().getBytes();
}
@Override

View File

@@ -52,7 +52,7 @@ public class ProtobufMapEncoder<K, V> extends MapEncoder<ProtobufWriter, K, V> {
kencoder.convertTo(tmp, key);
tmp.writeTag(valTag);
vencoder.convertTo(tmp, v);
out.writeTuple(tmp);
out.offerChild(tmp);
}

View File

@@ -137,7 +137,6 @@ public class ProtobufReader extends Reader {
/**
* 判断下一个非空白字符是否为[
*
* @param member DeMember
* @param componentDecoder Decodeable
* @return SIGN_VARIABLE 或 SIGN_NULL
*/