當前位置: 首頁>>代碼示例>>Java>>正文


Java CodedOutputStream.writeInt32NoTag方法代碼示例

本文整理匯總了Java中com.google.protobuf.CodedOutputStream.writeInt32NoTag方法的典型用法代碼示例。如果您正苦於以下問題:Java CodedOutputStream.writeInt32NoTag方法的具體用法?Java CodedOutputStream.writeInt32NoTag怎麽用?Java CodedOutputStream.writeInt32NoTag使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.protobuf.CodedOutputStream的用法示例。


在下文中一共展示了CodedOutputStream.writeInt32NoTag方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: serializeOneNestedSet

import com.google.protobuf.CodedOutputStream; //導入方法依賴的package包/類
private void serializeOneNestedSet(
    Object children, CodedOutputStream codedOut, Map<Object, byte[]> childToDigest)
    throws IOException, SerializationException {
  // Serialize nested set into an inner byte array so we can take its digest
  ByteArrayOutputStream childOutputStream = new ByteArrayOutputStream();
  HashingOutputStream hashingOutputStream =
      new HashingOutputStream(Hashing.md5(), childOutputStream);
  CodedOutputStream childCodedOut = CodedOutputStream.newInstance(hashingOutputStream);
  if (children instanceof Object[]) {
    serializeMultiItemChildArray((Object[]) children, childToDigest, childCodedOut);
  } else if (children != NestedSet.EMPTY_CHILDREN) {
    serializeSingleItemChildArray(children, childCodedOut);
  } else {
    // Empty set
    childCodedOut.writeInt32NoTag(0);
  }
  childCodedOut.flush();
  byte[] digest = hashingOutputStream.hash().asBytes();
  codedOut.writeByteArrayNoTag(digest);
  byte[] childBytes = childOutputStream.toByteArray();
  codedOut.writeByteArrayNoTag(childBytes);
  childToDigest.put(children, digest);
}
 
開發者ID:bazelbuild,項目名稱:bazel,代碼行數:24,代碼來源:NestedSetCodec.java

示例2: serializeMultiItemChildArray

import com.google.protobuf.CodedOutputStream; //導入方法依賴的package包/類
private void serializeMultiItemChildArray(
    Object[] children, Map<Object, byte[]> childToDigest, CodedOutputStream childCodedOut)
    throws IOException, SerializationException {
  childCodedOut.writeInt32NoTag(children.length);
  for (Object child : children) {
    if (child instanceof Object[]) {
      byte[] digest =
          Preconditions.checkNotNull(
              childToDigest.get(child),
              "Digest not available; Are nested sets serialized in the right order?");
      childCodedOut.writeBoolNoTag(true);
      childCodedOut.writeByteArrayNoTag(digest);
    } else {
      childCodedOut.writeBoolNoTag(false);
      objectCodec.serialize(cast(child), childCodedOut);
    }
  }
}
 
開發者ID:bazelbuild,項目名稱:bazel,代碼行數:19,代碼來源:NestedSetCodec.java

示例3: serialize

import com.google.protobuf.CodedOutputStream; //導入方法依賴的package包/類
@Override
public void serialize(NestedSet<T> obj, CodedOutputStream codedOut)
    throws SerializationException, IOException {
  // Topo sort the nested set to ensure digests are available for children at time of writing
  Collection<Object> topoSortedChildren = getTopologicallySortedChildren(obj);
  Map<Object, byte[]> childToDigest = new IdentityHashMap<>();
  codedOut.writeInt32NoTag(topoSortedChildren.size());
  orderCodec.serialize(obj.getOrder(), codedOut);
  for (Object children : topoSortedChildren) {
    serializeOneNestedSet(children, codedOut, childToDigest);
  }
}
 
開發者ID:bazelbuild,項目名稱:bazel,代碼行數:13,代碼來源:NestedSetCodec.java

示例4: serialize

import com.google.protobuf.CodedOutputStream; //導入方法依賴的package包/類
@Override
public void serialize(PathFragment pathFragment, CodedOutputStream codedOut)
    throws IOException, SerializationException {
  codedOut.writeInt32NoTag(pathFragment.getDriveLetter());
  codedOut.writeBoolNoTag(pathFragment.isAbsolute());
  codedOut.writeInt32NoTag(pathFragment.segmentCount());
  for (int i = 0; i < pathFragment.segmentCount(); i++) {
    stringCodec.serialize(pathFragment.getSegment(i), codedOut);
  }
}
 
開發者ID:bazelbuild,項目名稱:bazel,代碼行數:11,代碼來源:PathFragment.java

示例5: serialize

import com.google.protobuf.CodedOutputStream; //導入方法依賴的package包/類
@Override
public void serialize(ImmutableList<T> list, CodedOutputStream codedOut)
    throws SerializationException, IOException {
  codedOut.writeInt32NoTag(list.size());
  for (T item : list) {
    codec.serialize(item, codedOut);
  }
}
 
開發者ID:bazelbuild,項目名稱:bazel,代碼行數:9,代碼來源:ImmutableListCodec.java

示例6: serialize

import com.google.protobuf.CodedOutputStream; //導入方法依賴的package包/類
@Override
public void serialize(Key obj, CodedOutputStream codedOut)
    throws SerializationException, IOException {
  BuildOptions.CODEC.serialize(obj.buildOptions, codedOut);
  codedOut.writeInt32NoTag(obj.fragments.fragmentClasses().size());
  for (Class<? extends BuildConfiguration.Fragment> fragment :
      obj.fragments.fragmentClasses()) {
    StringCodecs.asciiOptimized().serialize(fragment.getName(), codedOut);
  }
}
 
開發者ID:bazelbuild,項目名稱:bazel,代碼行數:11,代碼來源:BuildConfigurationValue.java

示例7: serialize

import com.google.protobuf.CodedOutputStream; //導入方法依賴的package包/類
@Override
public void serialize(DottedVersion obj, CodedOutputStream codedOut) throws IOException {
  codedOut.writeInt32NoTag(obj.components.size());
  for (Component component : obj.components) {
    component.serialize(codedOut);
  }
  codedOut.writeStringNoTag(obj.stringRepresentation);
  codedOut.writeInt32NoTag(obj.numOriginalComponents);
}
 
開發者ID:bazelbuild,項目名稱:bazel,代碼行數:10,代碼來源:DottedVersion.java

示例8: serialize

import com.google.protobuf.CodedOutputStream; //導入方法依賴的package包/類
@Override
public void serialize(
    FileSystemProvider fsProvider, BuildConfiguration obj, CodedOutputStream codedOut)
    throws SerializationException, IOException {
  BlazeDirectories.CODEC.serialize(fsProvider, obj.directories, codedOut);
  codedOut.writeInt32NoTag(obj.fragments.size());
  for (Fragment fragment : obj.fragments.values()) {
    Fragment.CODEC.serialize(fsProvider, fragment, codedOut);
  }
  BuildOptions.CODEC.serialize(obj.buildOptions, codedOut);
  StringCodecs.asciiOptimized().serialize(obj.repositoryName, codedOut);
}
 
開發者ID:bazelbuild,項目名稱:bazel,代碼行數:13,代碼來源:BuildConfiguration.java

示例9: serialize

import com.google.protobuf.CodedOutputStream; //導入方法依賴的package包/類
@Override
public void serialize(BuildOptions buildOptions, CodedOutputStream codedOut)
    throws IOException, SerializationException {
  Collection<FragmentOptions> fragmentOptions = buildOptions.getOptions();
  codedOut.writeInt32NoTag(fragmentOptions.size());
  for (FragmentOptions options : buildOptions.getOptions()) {
    FragmentOptions.CODEC.serialize(options, codedOut);
  }
}
 
開發者ID:bazelbuild,項目名稱:bazel,代碼行數:10,代碼來源:BuildOptions.java

示例10: serializeSingleItemChildArray

import com.google.protobuf.CodedOutputStream; //導入方法依賴的package包/類
private void serializeSingleItemChildArray(Object children, CodedOutputStream childCodedOut)
    throws IOException, SerializationException {
  childCodedOut.writeInt32NoTag(1);
  T singleChild = cast(children);
  objectCodec.serialize(singleChild, childCodedOut);
}
 
開發者ID:bazelbuild,項目名稱:bazel,代碼行數:7,代碼來源:NestedSetCodec.java

示例11: serialize

import com.google.protobuf.CodedOutputStream; //導入方法依賴的package包/類
@Override
public void serialize(Integer obj, CodedOutputStream codedOut)
    throws SerializationException, IOException {
  codedOut.writeInt32NoTag(obj);
}
 
開發者ID:bazelbuild,項目名稱:bazel,代碼行數:6,代碼來源:ObjectCodecsTest.java


注:本文中的com.google.protobuf.CodedOutputStream.writeInt32NoTag方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。