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


Java CodedOutputStream.writeUInt32NoTag方法代碼示例

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


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

示例1: writeToList

import com.google.protobuf.CodedOutputStream; //導入方法依賴的package包/類
/**
 * write list to {@link CodedOutputStream} object.
 *
 * @param out target output stream to write
 * @param order field order
 * @param type field type
 * @param list target list object to be serialized
 * @param packed the packed
 * @throws IOException Signals that an I/O exception has occurred.
 */
public static void writeToList(CodedOutputStream out, int order, FieldType type, List list, boolean packed)
        throws IOException {
    if (list == null || list.isEmpty()) {
        return;
    }

    if (packed) {
        out.writeUInt32NoTag(makeTag(order, WireFormat.WIRETYPE_LENGTH_DELIMITED));
        out.writeUInt32NoTag(computeListSize(order, list, type, false, null, packed, true));
    }

    for (Object object : list) {
        writeObject(out, order, type, object, true, !packed);

    }

}
 
開發者ID:jhunters,項目名稱:jprotobuf,代碼行數:28,代碼來源:CodedConstant.java

示例2: savePreprocessedBlock

import com.google.protobuf.CodedOutputStream; //導入方法依賴的package包/類
private void savePreprocessedBlock(BlockContext context, List<RtbImpression> impressions) throws IOException {
    try (OutputStream os = context.createOutputStream(PREPROCESS)) {
        CodedOutputStream cos = CodedOutputStream.newInstance(os);
        for (RtbImpression impression : impressions) {
            if (impression == null) continue;;
            byte[] bytes = impression.toByteArray();
            cos.writeUInt32NoTag(bytes.length);
            cos.writeRawBytes(bytes);
        }
        cos.flush();
    }
}
 
開發者ID:papyrusglobal,項目名稱:state-channels,代碼行數:13,代碼來源:RtbValidator.java

示例3: serializeTo

import com.google.protobuf.CodedOutputStream; //導入方法依賴的package包/類
/**
 * Serializes the provided key and value as though they were wrapped by a {@link MapEntryLite} to the output stream.
 * This helper method avoids allocation of a {@link MapEntryLite} built with a key and value and is called from
 * generated code directly.
 *
 * @param output the output
 * @param fieldNumber the field number
 * @param key the key
 * @param value the value
 * @throws IOException Signals that an I/O exception has occurred.
 */
public void serializeTo(CodedOutputStream output, int fieldNumber, K key, V value) throws IOException {
    output.writeTag(fieldNumber, WireFormat.WIRETYPE_LENGTH_DELIMITED);
    output.writeUInt32NoTag(computeSerializedSize(metadata, key, value));
    writeTo(output, metadata, key, value);
}
 
開發者ID:jhunters,項目名稱:jprotobuf,代碼行數:17,代碼來源:MapEntryLite.java


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