This commit is contained in:
@@ -49,6 +49,7 @@ public final class JsonByteBufferWriter extends JsonWriter {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer[] toBuffers() {
|
||||
if (buffers == null) return new ByteBuffer[0];
|
||||
for (int i = index; i < this.buffers.length; i++) {
|
||||
@@ -58,16 +59,6 @@ public final class JsonByteBufferWriter extends JsonWriter {
|
||||
return this.buffers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public char[] toArray() {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] toUTF8Bytes() {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int count() {
|
||||
if (this.buffers == null) return 0;
|
||||
|
||||
@@ -134,19 +134,4 @@ public final class JsonConvert extends Convert<JsonReader, JsonWriter> {
|
||||
}
|
||||
return out.toBuffers();
|
||||
}
|
||||
|
||||
public byte[] convertToUTF8Bytes(Object value) {
|
||||
if (value == null) return new byte[]{110, 117, 108, 108};
|
||||
return convertToUTF8Bytes(value.getClass(), value);
|
||||
}
|
||||
|
||||
public byte[] convertToUTF8Bytes(final Type type, Object value) {
|
||||
if (type == null) return null;
|
||||
if (value == null) return new byte[]{110, 117, 108, 108};
|
||||
final JsonWriter out = writerPool.get().setTiny(tiny);
|
||||
factory.loadEncoder(type).convertTo(out, value);
|
||||
byte[] result = out.toUTF8Bytes();
|
||||
writerPool.offer(out);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ package com.wentch.redkale.convert.json;
|
||||
|
||||
import com.wentch.redkale.convert.*;
|
||||
import com.wentch.redkale.util.*;
|
||||
import java.nio.*;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -101,15 +102,8 @@ public class JsonWriter implements Writer {
|
||||
return true;
|
||||
}
|
||||
|
||||
public char[] toArray() {
|
||||
if (count == content.length) return content;
|
||||
char[] newdata = new char[count];
|
||||
System.arraycopy(content, 0, newdata, 0, count);
|
||||
return newdata;
|
||||
}
|
||||
|
||||
public byte[] toUTF8Bytes() {
|
||||
return Utility.encodeUTF8(content, 0, count);
|
||||
public ByteBuffer[] toBuffers() {
|
||||
return new ByteBuffer[]{ByteBuffer.wrap(Utility.encodeUTF8(content, 0, count))};
|
||||
}
|
||||
|
||||
public int count() {
|
||||
|
||||
Reference in New Issue
Block a user