当前位置: 首页>>代码示例>>Java>>正文


Java AbstractMessageLite类代码示例

本文整理汇总了Java中com.google.protobuf.AbstractMessageLite的典型用法代码示例。如果您正苦于以下问题:Java AbstractMessageLite类的具体用法?Java AbstractMessageLite怎么用?Java AbstractMessageLite使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


AbstractMessageLite类属于com.google.protobuf包,在下文中一共展示了AbstractMessageLite类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: toChannelBuffer

import com.google.protobuf.AbstractMessageLite; //导入依赖的package包/类
/**
 * Serializes the given protobuf object into a Netty {@link ChannelBuffer}.
 * @param method The name of the method of the RPC we're going to send.
 * @param pb The protobuf to serialize.
 * @return A new channel buffer containing the serialized protobuf, with
 * enough free space at the beginning to tack on the RPC header.
 */
static final ChannelBuffer toChannelBuffer(final byte[] method,
                                           final AbstractMessageLite pb) {
  final int pblen = pb.getSerializedSize();
  final int vlen = CodedOutputStream.computeRawVarint32Size(pblen);
  final byte[] buf = new byte[4 + 19 + method.length + vlen + pblen];
  try {
    final CodedOutputStream out = CodedOutputStream.newInstance(buf, 4 + 19 + method.length,
                                                                vlen + pblen);
    out.writeRawVarint32(pblen);
    pb.writeTo(out);
    out.checkNoSpaceLeft();
  } catch (IOException e) {
    throw new RuntimeException("Should never happen", e);
  }
  return ChannelBuffers.wrappedBuffer(buf);
}
 
开发者ID:OpenTSDB,项目名称:asynccassandra,代码行数:24,代码来源:HBaseRpc.java

示例2: readEvents_multipleEventsInOneChunk

import com.google.protobuf.AbstractMessageLite; //导入依赖的package包/类
@Test
public void readEvents_multipleEventsInOneChunk() throws Exception {
    final List<Event> subHbOffer = newArrayList(
        TestingProtos.SUBSCRIBED,
        TestingProtos.HEARTBEAT,
        TestingProtos.OFFER
    );
    final List<byte[]> eventChunks = subHbOffer.stream()
        .map(AbstractMessageLite::toByteArray)
        .map(RecordIOUtils::createChunk)
        .collect(Collectors.toList());
    final List<ByteBuf> singleChunk = newArrayList(Unpooled.copiedBuffer(concatAllChunks(eventChunks)));

    final List<Event> events = runTestOnChunks(singleChunk);
    assertThat(events).isEqualTo(subHbOffer);
}
 
开发者ID:mesosphere,项目名称:mesos-rxjava,代码行数:17,代码来源:RecordIOOperatorTest.java

示例3: toBody

import com.google.protobuf.AbstractMessageLite; //导入依赖的package包/类
@Override
public TypedOutput toBody(Object object)
{
  if (!(object instanceof AbstractMessageLite))
  {
    throw new IllegalArgumentException(
        "Expected a protobuf message but was " + (object != null ? object.getClass().getName()
                                                                 : "null"));
  }
  byte[] bytes = ((AbstractMessageLite) object).toByteArray();
  return new TypedByteArray(MIME_TYPE, bytes);
}
 
开发者ID:toadzky,项目名称:retrofit-jaxrs,代码行数:13,代码来源:ProtoConverter.java

示例4: encode

import com.google.protobuf.AbstractMessageLite; //导入依赖的package包/类
public static String encode(AbstractMessageLite message) {
  return new String(Base64.encodeBase64(message.toByteArray()), CHAR_SET);
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:4,代码来源:Base64Util.java

示例5: ProtoDeterministicWriter

import com.google.protobuf.AbstractMessageLite; //导入依赖的package包/类
public ProtoDeterministicWriter(AbstractMessageLite message) {
  this.message = message;
}
 
开发者ID:bazelbuild,项目名称:bazel,代码行数:4,代码来源:ProtoDeterministicWriter.java

示例6: of

import com.google.protobuf.AbstractMessageLite; //导入依赖的package包/类
/** Returns a ProtoWrapper that wraps the provided object */
public static <M extends AbstractMessageLite> ProtoWrapper<M> of(M proto) {
  return new ProtoWrapper<M>(proto);
}
 
开发者ID:morristech,项目名称:android-chromium,代码行数:5,代码来源:ProtoWrapper.java


注:本文中的com.google.protobuf.AbstractMessageLite类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。