@Override public byte[] outputEncode(Object output) throws IOException { if (outputCodec != null) { return outputCodec.encode(output); } return null; }
/** * Encode. * * @return the byte[] * @throws IOException Signals that an I/O exception has occurred. */ public byte[] encode() throws IOException { return codec.encode(target); }
@Override public byte[] inputEncode(Object input) throws IOException { if (inputCodec != null) { return inputCodec.encode(input); } return null; }
@Override public byte[] inputEncode(Object input) throws IOException { if (inputCodec != null) { return inputCodec.encode(input); } return null; }
@Override public byte[] inputEncode(Object input) throws IOException { if (inputCodec != null) { return inputCodec.encode(input); } return null; }
@Override public byte[] outputEncode(Object output) throws IOException { if (outputCodec != null) { return outputCodec.encode(output); } return null; }
public byte[] write() { try { return CODEC.encode(this); } catch (IOException e) { throw new RuntimeException(e.getMessage(), e); } }
public byte[] write() { try { return CODEC.encode(this); } catch (IOException e) { throw new RuntimeException(e.getMessage(), e); } }
public byte[] write() { try { return CODEC.encode(this); } catch (IOException e) { throw new RuntimeException(e.getMessage(), e); } }
public byte[] write() { try { return CODEC.encode(this); } catch (IOException e) { throw new RuntimeException(e.getMessage(), e); } }
@Override public byte[] serialize(Object o) { Codec codec = ProtobufProxy.create(o.getClass()); try { return codec.encode(o); } catch (IOException e) { throw new IllegalArgumentException("serialize error", e); } }
@Override public byte[] writeMessageBody(Message message) { //写入具体消息的内容 byte[] body = null; Class<Message> msgClazz = (Class<Message>) message.getClass(); try { Codec<Message> codec = ProtobufProxy.create(msgClazz); body = codec.encode(message); } catch (IOException e) { logger.error("", e); } return body; }
Codec<FileDescriptorProtoPOJO> descriptorCodec = ProtobufProxy.create(FileDescriptorProtoPOJO.class, ProtobufProxy.isCacheEnabled(), ProtobufProxy.OUTPUT_PATH.get()); byte[] bs = descriptorCodec.encode(fileDescriptorProto); fileproto = FileDescriptorProto.parseFrom(bs); } catch (InvalidProtocolBufferException e) {