This commit is contained in:
@@ -20,7 +20,7 @@ public final class BsonByteBufferWriter extends BsonWriter {
|
||||
|
||||
private int index;
|
||||
|
||||
public BsonByteBufferWriter(Supplier<ByteBuffer> supplier) {
|
||||
protected BsonByteBufferWriter(Supplier<ByteBuffer> supplier) {
|
||||
super((byte[]) null);
|
||||
this.supplier = supplier;
|
||||
}
|
||||
|
||||
@@ -44,6 +44,10 @@ public final class BsonConvert extends Convert<BsonReader, BsonWriter> {
|
||||
this.tiny = tiny;
|
||||
}
|
||||
|
||||
public BsonByteBufferWriter pollBsonWriter(final Supplier<ByteBuffer> supplier) {
|
||||
return new BsonByteBufferWriter(supplier).setTiny(tiny);
|
||||
}
|
||||
|
||||
public BsonWriter pollBsonWriter() {
|
||||
return writerPool.get().setTiny(tiny);
|
||||
}
|
||||
|
||||
@@ -27,15 +27,21 @@ public final class JsonByteBufferWriter extends JsonWriter {
|
||||
|
||||
private int index;
|
||||
|
||||
public JsonByteBufferWriter(Supplier<ByteBuffer> supplier) {
|
||||
protected JsonByteBufferWriter(Supplier<ByteBuffer> supplier) {
|
||||
this(null, supplier);
|
||||
}
|
||||
|
||||
public JsonByteBufferWriter(Charset charset, Supplier<ByteBuffer> supplier) {
|
||||
protected JsonByteBufferWriter(Charset charset, Supplier<ByteBuffer> supplier) {
|
||||
this.charset = UTF8.equals(charset) ? null : charset;
|
||||
this.supplier = supplier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonByteBufferWriter setTiny(boolean tiny) {
|
||||
this.tiny = tiny;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean recycle() {
|
||||
this.index = 0;
|
||||
|
||||
@@ -33,6 +33,14 @@ public final class JsonConvert extends Convert<JsonReader, JsonWriter> {
|
||||
this.tiny = tiny;
|
||||
}
|
||||
|
||||
public JsonByteBufferWriter pollJsonWriter(final Supplier<ByteBuffer> supplier) {
|
||||
return new JsonByteBufferWriter(supplier).setTiny(tiny);
|
||||
}
|
||||
|
||||
public JsonByteBufferWriter pollJsonWriter(final Charset charset, final Supplier<ByteBuffer> supplier) {
|
||||
return new JsonByteBufferWriter(charset, supplier).setTiny(tiny);
|
||||
}
|
||||
|
||||
public JsonWriter pollJsonWriter() {
|
||||
return writerPool.get().setTiny(tiny);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user