protobuf
This commit is contained in:
@@ -685,13 +685,13 @@ public class ProtobufConvert extends BinaryConvert<ProtobufReader, ProtobufWrite
|
|||||||
if (encoder == null || encoder.getType() != t) {
|
if (encoder == null || encoder.getType() != t) {
|
||||||
encoder = factory.loadEncoder(t);
|
encoder = factory.loadEncoder(t);
|
||||||
this.lastEncodeable = encoder;
|
this.lastEncodeable = encoder;
|
||||||
|
if (!(encoder instanceof ObjectEncoder) && !(encoder instanceof SimpledCoder)) {
|
||||||
|
throw new ConvertException(this.getClass().getSimpleName() + " not supported type(" + t + ")");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (encoder.specifyable()) {
|
if (encoder.specifyable()) {
|
||||||
writer.specificObjectType(t);
|
writer.specificObjectType(t);
|
||||||
}
|
}
|
||||||
if (!(encoder instanceof ObjectEncoder) && !(encoder instanceof SimpledCoder)) {
|
|
||||||
throw new ConvertException(this.getClass().getSimpleName() + " not supported type(" + t + ")");
|
|
||||||
}
|
|
||||||
encoder.convertTo(writer, value);
|
encoder.convertTo(writer, value);
|
||||||
byte[] result = writer.toArray();
|
byte[] result = writer.toArray();
|
||||||
offerWriter(writer);
|
offerWriter(writer);
|
||||||
|
|||||||
@@ -207,12 +207,9 @@ public class ProtobufWriter extends Writer implements ByteTuple {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public byte[] toArray() {
|
public byte[] toArray() {
|
||||||
if (count == content.length) {
|
byte[] copy = new byte[count];
|
||||||
return content;
|
System.arraycopy(content, 0, copy, 0, count);
|
||||||
}
|
return copy;
|
||||||
byte[] newdata = new byte[count];
|
|
||||||
System.arraycopy(content, 0, newdata, 0, count);
|
|
||||||
return newdata;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProtobufWriter enumtostring(boolean enumtostring) {
|
public ProtobufWriter enumtostring(boolean enumtostring) {
|
||||||
|
|||||||
Reference in New Issue
Block a user