public class CodedConstant extends Object
| 构造器和说明 |
|---|
CodedConstant() |
| 限定符和类型 | 方法和说明 |
|---|---|
static List |
asList(String value)
As list.
|
static String |
capitalize(String str)
Capitalizes a String changing the first letter to title case as per
Character.toTitleCase(char). |
static int |
computeElementSize(com.google.protobuf.WireFormat.FieldType type,
int number,
Object value)
Compute the number of bytes that would be needed to encode a single tag/value pair of arbitrary type.
|
static int |
computeElementSizeNoTag(com.google.protobuf.WireFormat.FieldType type,
Object value)
Compute the number of bytes that would be needed to encode a particular value of arbitrary type, excluding tag.
|
static int |
computeLengthDelimitedFieldSize(int fieldLength)
Compute length delimited field size.
|
static int |
computeListSize(int order,
Collection<?> list,
FieldType type,
boolean debug,
File path)
Compute list size.
|
static int |
computeListSize(int order,
Collection list,
FieldType type,
boolean debug,
File path,
boolean packed)
Compute list size.
|
static int |
computeListSize(int order,
Collection list,
FieldType type,
boolean debug,
File path,
boolean packed,
boolean sizeOnly)
Compute list size.
|
static <K,V> int |
computeMapSize(int order,
Map<K,V> map,
com.google.protobuf.WireFormat.FieldType keyType,
K defaultKey,
com.google.protobuf.WireFormat.FieldType valueType,
V defalutValue)
Compute map size.
|
static int |
computeObjectSizeNoTag(Object o)
Compute object size no tag.
|
static int |
computeSize(int order,
Object o,
FieldType type,
boolean list,
boolean debug,
File path)
get object size by
FieldType. |
static int |
computeSize(int order,
Object o,
FieldType type,
boolean debug,
File path)
get object size by
FieldType. |
static com.google.protobuf.Descriptors.Descriptor |
getDescriptor(Class<?> cls)
Gets the descriptor.
|
static String |
getEnumName(Enum[] e,
int value)
Gets the enum name.
|
static <T extends Enum<T>> |
getEnumValue(Class<T> enumType,
String name)
Gets the enumeration value.
|
static int |
getEnumValue(Enum en)
Gets the enum value.
|
static String |
getFieldName(int order)
get field name.
|
static String |
getFiledType(FieldType type,
boolean isList)
Gets the filed type.
|
static String |
getMapFieldGenericParameterString(FieldInfo field)
Gets the map field generic parameter string.
|
static String |
getMappedTypeDefined(int order,
FieldType type,
String express,
boolean isList,
boolean isMap)
get mapped type defined java expression.
|
static String |
getMappedTypeSize(FieldInfo field,
int order,
FieldType type,
boolean isList,
boolean isMap,
boolean debug,
File path)
Gets the mapped type size.
|
static String |
getMappedWriteCode(FieldInfo field,
String prefix,
int order,
FieldType type,
boolean isList,
boolean isMap)
get mapped object byte write java expression.
|
static String |
getRequiredCheck(int order,
Field field)
get required field check java expression.
|
static String |
getRetRequiredCheck(String express,
Field field)
get return required field check java expression.
|
static String |
getWriteValueToField(FieldType type,
String express,
boolean isList)
Gets the write value to field.
|
static boolean |
isNull(byte o)
check byte is null.
|
static boolean |
isNull(char o)
check char is null.
|
static boolean |
isNull(double o)
check double is null.
|
static boolean |
isNull(float o)
check float is null.
|
static boolean |
isNull(int o)
check int is null.
|
static boolean |
isNull(long o)
check long is null.
|
static boolean |
isNull(Object o)
check object is null.
|
static boolean |
isNull(short o)
check short is null.
|
static int |
makeTag(int fieldNumber,
int wireType)
make protobuf tag.
|
static <K,V> void |
putMapValue(com.google.protobuf.CodedInputStream input,
Map<K,V> map,
com.google.protobuf.WireFormat.FieldType keyType,
K defaultKey,
com.google.protobuf.WireFormat.FieldType valueType,
V defalutValue)
Put map value.
|
static <K,V> void |
putMapValue(com.google.protobuf.CodedInputStream input,
Map<K,V> map,
com.google.protobuf.WireFormat.FieldType keyType,
K defaultKey,
com.google.protobuf.WireFormat.FieldType valueType,
V defalutValue,
EnumHandler<K> keyHandler,
EnumHandler<V> valHandler) |
static <K,V> void |
putMapValue(com.google.protobuf.CodedInputStream input,
Map<K,V> map,
com.google.protobuf.WireFormat.FieldType keyType,
K defaultKey,
com.google.protobuf.WireFormat.FieldType valueType,
V defalutValue,
EnumHandler<V> handler) |
static Object |
readPrimitiveField(com.google.protobuf.CodedInputStream input,
com.google.protobuf.WireFormat.FieldType type,
boolean checkUtf8)
Read a field of any primitive type for immutable messages from a CodedInputStream.
|
static void |
writeElement(com.google.protobuf.CodedOutputStream output,
com.google.protobuf.WireFormat.FieldType type,
int number,
Object value)
Write a single tag-value pair to the stream.
|
static void |
writeElementNoTag(com.google.protobuf.CodedOutputStream output,
com.google.protobuf.WireFormat.FieldType type,
Object value)
Write a field of arbitrary type, without its tag, to the stream.
|
static void |
writeObject(com.google.protobuf.CodedOutputStream out,
int order,
FieldType type,
Object o,
boolean list)
Write object.
|
static void |
writeObject(com.google.protobuf.CodedOutputStream out,
int order,
FieldType type,
Object o,
boolean list,
boolean withTag)
Write object to byte array by
FieldType. |
static void |
writeToList(com.google.protobuf.CodedOutputStream out,
int order,
FieldType type,
Collection list)
Write to list.
|
static void |
writeToList(com.google.protobuf.CodedOutputStream out,
int order,
FieldType type,
Collection list,
boolean packed)
write list to
CodedOutputStream object. |
static <K,V> void |
writeToMap(com.google.protobuf.CodedOutputStream output,
int order,
Map<K,V> map,
com.google.protobuf.WireFormat.FieldType keyType,
K defaultKey,
com.google.protobuf.WireFormat.FieldType valueType,
V defalutValue)
Write to map.
|
public static String getFieldName(int order)
order - field orderpublic static int computeElementSize(com.google.protobuf.WireFormat.FieldType type,
int number,
Object value)
type - The field's type.number - The field's number.value - Object representing the field's value. Must be of the exact type which would be returned by
MessageOrBuilder.getField(Descriptors.FieldDescriptor) for this field.public static String getMappedTypeDefined(int order, FieldType type, String express, boolean isList, boolean isMap)
public static String getFiledType(FieldType type, boolean isList)
type - the typeisList - the is listpublic static String getWriteValueToField(FieldType type, String express, boolean isList)
type - the typeexpress - the expressisList - the is listpublic static String getMappedTypeSize(FieldInfo field, int order, FieldType type, boolean isList, boolean isMap, boolean debug, File path)
field - fieldorder - field ordertype - field typeisList - is field type is a ListisMap - the is mapdebug - debug mode if true enable debug.path - the pathpublic static String getMapFieldGenericParameterString(FieldInfo field)
field - the fieldpublic static int computeListSize(int order,
Collection<?> list,
FieldType type,
boolean debug,
File path)
order - field orderlist - field valuetype - field type of list objdebug - the debugpath - the pathpublic static int computeListSize(int order,
Collection list,
FieldType type,
boolean debug,
File path,
boolean packed)
order - the orderlist - the listtype - the typedebug - the debugpath - the pathpacked - the packedpublic static int computeListSize(int order,
Collection list,
FieldType type,
boolean debug,
File path,
boolean packed,
boolean sizeOnly)
order - the orderlist - the listtype - the typedebug - the debugpath - the pathpacked - the packedsizeOnly - the size only if true will not include order size and tag sizepublic static <K,V> int computeMapSize(int order,
Map<K,V> map,
com.google.protobuf.WireFormat.FieldType keyType,
K defaultKey,
com.google.protobuf.WireFormat.FieldType valueType,
V defalutValue)
K - the key typeV - the value typeorder - the ordermap - the mapkeyType - the key typedefaultKey - the default keyvalueType - the value typedefalutValue - the defalut valuepublic static <K,V> void putMapValue(com.google.protobuf.CodedInputStream input,
Map<K,V> map,
com.google.protobuf.WireFormat.FieldType keyType,
K defaultKey,
com.google.protobuf.WireFormat.FieldType valueType,
V defalutValue)
throws IOException
K - the key typeV - the value typeinput - the inputmap - the mapkeyType - the key typedefaultKey - the default keyvalueType - the value typedefalutValue - the defalut valueIOException - Signals that an I/O exception has occurred.public static <K,V> void putMapValue(com.google.protobuf.CodedInputStream input,
Map<K,V> map,
com.google.protobuf.WireFormat.FieldType keyType,
K defaultKey,
com.google.protobuf.WireFormat.FieldType valueType,
V defalutValue,
EnumHandler<V> handler)
throws IOException
IOExceptionpublic static <K,V> void putMapValue(com.google.protobuf.CodedInputStream input,
Map<K,V> map,
com.google.protobuf.WireFormat.FieldType keyType,
K defaultKey,
com.google.protobuf.WireFormat.FieldType valueType,
V defalutValue,
EnumHandler<K> keyHandler,
EnumHandler<V> valHandler)
throws IOException
IOExceptionpublic static <K,V> void writeToMap(com.google.protobuf.CodedOutputStream output,
int order,
Map<K,V> map,
com.google.protobuf.WireFormat.FieldType keyType,
K defaultKey,
com.google.protobuf.WireFormat.FieldType valueType,
V defalutValue)
throws IOException
K - the key typeV - the value typeoutput - the outputorder - the ordermap - the mapkeyType - the key typedefaultKey - the default keyvalueType - the value typedefalutValue - the defalut valueIOException - Signals that an I/O exception has occurred.public static int computeSize(int order,
Object o,
FieldType type,
boolean debug,
File path)
FieldType.order - the ordero - the otype - the typedebug - the debugpath - the pathpublic static int computeObjectSizeNoTag(Object o)
o - the opublic static int computeSize(int order,
Object o,
FieldType type,
boolean list,
boolean debug,
File path)
FieldType.order - the ordero - the otype - the typelist - the listdebug - the debugpath - the pathpublic static String getMappedWriteCode(FieldInfo field, String prefix, int order, FieldType type, boolean isList, boolean isMap)
field - the fieldprefix - the prefixorder - field ordertype - field typeisList - the is listisMap - the is mappublic static void writeToList(com.google.protobuf.CodedOutputStream out,
int order,
FieldType type,
Collection list)
throws IOException
out - the outorder - the ordertype - the typelist - the listIOException - Signals that an I/O exception has occurred.public static void writeToList(com.google.protobuf.CodedOutputStream out,
int order,
FieldType type,
Collection list,
boolean packed)
throws IOException
CodedOutputStream object.out - target output stream to writeorder - field ordertype - field typelist - target list object to be serializedpacked - the packedIOException - Signals that an I/O exception has occurred.public static void writeObject(com.google.protobuf.CodedOutputStream out,
int order,
FieldType type,
Object o,
boolean list)
throws IOException
out - the outorder - the ordertype - the typeo - the olist - the listIOException - Signals that an I/O exception has occurred.public static void writeObject(com.google.protobuf.CodedOutputStream out,
int order,
FieldType type,
Object o,
boolean list,
boolean withTag)
throws IOException
FieldType.out - the outorder - the ordertype - the typeo - the olist - the listwithTag - the with tagIOException - Signals that an I/O exception has occurred.public static String getRequiredCheck(int order, Field field)
order - field orderfield - java fieldpublic static String getRetRequiredCheck(String express, Field field)
express - java expressionfield - java fieldpublic static boolean isNull(Object o)
o - to checkpublic static boolean isNull(double o)
o - to checkpublic static boolean isNull(int o)
o - to checkpublic static boolean isNull(byte o)
o - to checkpublic static boolean isNull(short o)
o - to checkpublic static boolean isNull(long o)
o - to checkpublic static boolean isNull(float o)
o - to checkpublic static boolean isNull(char o)
o - to checkpublic static String capitalize(String str)
Capitalizes a String changing the first letter to title case as per Character.toTitleCase(char). No other
letters are changed.
str - the String to capitalize, may be nullnull if null String inputpublic static int makeTag(int fieldNumber,
int wireType)
fieldNumber - field number orderwireType - wireformat typepublic static String getEnumName(Enum[] e, int value)
e - the evalue - the valuepublic static int getEnumValue(Enum en)
en - the enpublic static <T extends Enum<T>> T getEnumValue(Class<T> enumType, String name)
T - the generic typeenumType - the enum typename - the namepublic static Object readPrimitiveField(com.google.protobuf.CodedInputStream input, com.google.protobuf.WireFormat.FieldType type, boolean checkUtf8) throws IOException
input - The stream from which to read.type - Declared type of the field.checkUtf8 - When true, check that the input is valid utf8.MessageOrBuilder.getField(Descriptors.FieldDescriptor) for this field.IOException - Signals that an I/O exception has occurred.public static void writeElement(com.google.protobuf.CodedOutputStream output,
com.google.protobuf.WireFormat.FieldType type,
int number,
Object value)
throws IOException
output - The output stream.type - The field's type.number - The field's number.value - Object representing the field's value. Must be of the exact type which would be returned by
MessageOrBuilder.getField(Descriptors.FieldDescriptor) for this field.IOException - Signals that an I/O exception has occurred.public static void writeElementNoTag(com.google.protobuf.CodedOutputStream output,
com.google.protobuf.WireFormat.FieldType type,
Object value)
throws IOException
output - The output stream.type - The field's type.value - Object representing the field's value. Must be of the exact type which would be returned by
MessageOrBuilder.getField(Descriptors.FieldDescriptor) for this field.IOException - Signals that an I/O exception has occurred.public static int computeLengthDelimitedFieldSize(int fieldLength)
fieldLength - the field lengthpublic static int computeElementSizeNoTag(com.google.protobuf.WireFormat.FieldType type,
Object value)
type - The field's type.value - Object representing the field's value. Must be of the exact type which would be returned by
MessageOrBuilder.getField(Descriptors.FieldDescriptor) for this field.public static com.google.protobuf.Descriptors.Descriptor getDescriptor(Class<?> cls) throws IOException
cls - the clsIOException - Signals that an I/O exception has occurred.Copyright © 2022 Baidu, Inc.. All rights reserved.