diff --git a/src/com/wentch/redkale/convert/json/JsonByteBufferWriter.java b/src/com/wentch/redkale/convert/json/JsonByteBufferWriter.java index 34882e304..6482e3a0f 100644 --- a/src/com/wentch/redkale/convert/json/JsonByteBufferWriter.java +++ b/src/com/wentch/redkale/convert/json/JsonByteBufferWriter.java @@ -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; diff --git a/src/com/wentch/redkale/convert/json/JsonConvert.java b/src/com/wentch/redkale/convert/json/JsonConvert.java index cfa34e3be..2fd8b709c 100644 --- a/src/com/wentch/redkale/convert/json/JsonConvert.java +++ b/src/com/wentch/redkale/convert/json/JsonConvert.java @@ -134,19 +134,4 @@ public final class JsonConvert extends Convert { } 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; - } } diff --git a/src/com/wentch/redkale/convert/json/JsonWriter.java b/src/com/wentch/redkale/convert/json/JsonWriter.java index 1b18456dc..c51867215 100644 --- a/src/com/wentch/redkale/convert/json/JsonWriter.java +++ b/src/com/wentch/redkale/convert/json/JsonWriter.java @@ -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() {