- 28,932 files - Full Java source code - Smali files - Resources Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
892 lines
30 KiB
Java
892 lines
30 KiB
Java
package com.google.protobuf;
|
|
|
|
import com.google.protobuf.FieldSet;
|
|
import com.google.protobuf.Internal;
|
|
import java.io.IOException;
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
import java.util.RandomAccess;
|
|
|
|
/* loaded from: classes3.dex */
|
|
public final class SchemaUtil {
|
|
private static final int DEFAULT_LOOK_UP_START_NUMBER = 40;
|
|
private static final Class<?> GENERATED_MESSAGE_CLASS = getGeneratedMessageClass();
|
|
private static final UnknownFieldSchema PROTO2_UNKNOWN_FIELD_SET_SCHEMA = getUnknownFieldSetSchema(false);
|
|
private static final UnknownFieldSchema PROTO3_UNKNOWN_FIELD_SET_SCHEMA = getUnknownFieldSetSchema(true);
|
|
private static final UnknownFieldSchema UNKNOWN_FIELD_SET_LITE_SCHEMA = new UnknownFieldSetLiteSchema();
|
|
|
|
public static UnknownFieldSchema proto2UnknownFieldSetSchema() {
|
|
return PROTO2_UNKNOWN_FIELD_SET_SCHEMA;
|
|
}
|
|
|
|
public static UnknownFieldSchema proto3UnknownFieldSetSchema() {
|
|
return PROTO3_UNKNOWN_FIELD_SET_SCHEMA;
|
|
}
|
|
|
|
public static boolean shouldUseTableSwitch(int i, int i2, int i3) {
|
|
if (i2 < 40) {
|
|
return true;
|
|
}
|
|
long j = i2 - i;
|
|
long j2 = i3;
|
|
return j + 10 <= ((2 * j2) + 3) + ((j2 + 3) * 3);
|
|
}
|
|
|
|
public static UnknownFieldSchema unknownFieldSetLiteSchema() {
|
|
return UNKNOWN_FIELD_SET_LITE_SCHEMA;
|
|
}
|
|
|
|
private SchemaUtil() {
|
|
}
|
|
|
|
public static void requireGeneratedMessage(Class<?> cls) {
|
|
Class<?> cls2;
|
|
if (!GeneratedMessageLite.class.isAssignableFrom(cls) && (cls2 = GENERATED_MESSAGE_CLASS) != null && !cls2.isAssignableFrom(cls)) {
|
|
throw new IllegalArgumentException("Message classes must extend GeneratedMessageV3 or GeneratedMessageLite");
|
|
}
|
|
}
|
|
|
|
public static void writeDouble(int i, double d, Writer writer) throws IOException {
|
|
if (Double.doubleToRawLongBits(d) != 0) {
|
|
writer.writeDouble(i, d);
|
|
}
|
|
}
|
|
|
|
public static void writeFloat(int i, float f, Writer writer) throws IOException {
|
|
if (Float.floatToRawIntBits(f) != 0) {
|
|
writer.writeFloat(i, f);
|
|
}
|
|
}
|
|
|
|
public static void writeInt64(int i, long j, Writer writer) throws IOException {
|
|
if (j != 0) {
|
|
writer.writeInt64(i, j);
|
|
}
|
|
}
|
|
|
|
public static void writeUInt64(int i, long j, Writer writer) throws IOException {
|
|
if (j != 0) {
|
|
writer.writeUInt64(i, j);
|
|
}
|
|
}
|
|
|
|
public static void writeSInt64(int i, long j, Writer writer) throws IOException {
|
|
if (j != 0) {
|
|
writer.writeSInt64(i, j);
|
|
}
|
|
}
|
|
|
|
public static void writeFixed64(int i, long j, Writer writer) throws IOException {
|
|
if (j != 0) {
|
|
writer.writeFixed64(i, j);
|
|
}
|
|
}
|
|
|
|
public static void writeSFixed64(int i, long j, Writer writer) throws IOException {
|
|
if (j != 0) {
|
|
writer.writeSFixed64(i, j);
|
|
}
|
|
}
|
|
|
|
public static void writeInt32(int i, int i2, Writer writer) throws IOException {
|
|
if (i2 != 0) {
|
|
writer.writeInt32(i, i2);
|
|
}
|
|
}
|
|
|
|
public static void writeUInt32(int i, int i2, Writer writer) throws IOException {
|
|
if (i2 != 0) {
|
|
writer.writeUInt32(i, i2);
|
|
}
|
|
}
|
|
|
|
public static void writeSInt32(int i, int i2, Writer writer) throws IOException {
|
|
if (i2 != 0) {
|
|
writer.writeSInt32(i, i2);
|
|
}
|
|
}
|
|
|
|
public static void writeFixed32(int i, int i2, Writer writer) throws IOException {
|
|
if (i2 != 0) {
|
|
writer.writeFixed32(i, i2);
|
|
}
|
|
}
|
|
|
|
public static void writeSFixed32(int i, int i2, Writer writer) throws IOException {
|
|
if (i2 != 0) {
|
|
writer.writeSFixed32(i, i2);
|
|
}
|
|
}
|
|
|
|
public static void writeEnum(int i, int i2, Writer writer) throws IOException {
|
|
if (i2 != 0) {
|
|
writer.writeEnum(i, i2);
|
|
}
|
|
}
|
|
|
|
public static void writeBool(int i, boolean z, Writer writer) throws IOException {
|
|
if (z) {
|
|
writer.writeBool(i, true);
|
|
}
|
|
}
|
|
|
|
public static void writeString(int i, Object obj, Writer writer) throws IOException {
|
|
if (obj instanceof String) {
|
|
writeStringInternal(i, (String) obj, writer);
|
|
} else {
|
|
writeBytes(i, (ByteString) obj, writer);
|
|
}
|
|
}
|
|
|
|
private static void writeStringInternal(int i, String str, Writer writer) throws IOException {
|
|
if (str == null || str.isEmpty()) {
|
|
return;
|
|
}
|
|
writer.writeString(i, str);
|
|
}
|
|
|
|
public static void writeBytes(int i, ByteString byteString, Writer writer) throws IOException {
|
|
if (byteString == null || byteString.isEmpty()) {
|
|
return;
|
|
}
|
|
writer.writeBytes(i, byteString);
|
|
}
|
|
|
|
public static void writeMessage(int i, Object obj, Writer writer) throws IOException {
|
|
if (obj != null) {
|
|
writer.writeMessage(i, obj);
|
|
}
|
|
}
|
|
|
|
public static void writeDoubleList(int i, List<Double> list, Writer writer, boolean z) throws IOException {
|
|
if (list == null || list.isEmpty()) {
|
|
return;
|
|
}
|
|
writer.writeDoubleList(i, list, z);
|
|
}
|
|
|
|
public static void writeFloatList(int i, List<Float> list, Writer writer, boolean z) throws IOException {
|
|
if (list == null || list.isEmpty()) {
|
|
return;
|
|
}
|
|
writer.writeFloatList(i, list, z);
|
|
}
|
|
|
|
public static void writeInt64List(int i, List<Long> list, Writer writer, boolean z) throws IOException {
|
|
if (list == null || list.isEmpty()) {
|
|
return;
|
|
}
|
|
writer.writeInt64List(i, list, z);
|
|
}
|
|
|
|
public static void writeUInt64List(int i, List<Long> list, Writer writer, boolean z) throws IOException {
|
|
if (list == null || list.isEmpty()) {
|
|
return;
|
|
}
|
|
writer.writeUInt64List(i, list, z);
|
|
}
|
|
|
|
public static void writeSInt64List(int i, List<Long> list, Writer writer, boolean z) throws IOException {
|
|
if (list == null || list.isEmpty()) {
|
|
return;
|
|
}
|
|
writer.writeSInt64List(i, list, z);
|
|
}
|
|
|
|
public static void writeFixed64List(int i, List<Long> list, Writer writer, boolean z) throws IOException {
|
|
if (list == null || list.isEmpty()) {
|
|
return;
|
|
}
|
|
writer.writeFixed64List(i, list, z);
|
|
}
|
|
|
|
public static void writeSFixed64List(int i, List<Long> list, Writer writer, boolean z) throws IOException {
|
|
if (list == null || list.isEmpty()) {
|
|
return;
|
|
}
|
|
writer.writeSFixed64List(i, list, z);
|
|
}
|
|
|
|
public static void writeInt32List(int i, List<Integer> list, Writer writer, boolean z) throws IOException {
|
|
if (list == null || list.isEmpty()) {
|
|
return;
|
|
}
|
|
writer.writeInt32List(i, list, z);
|
|
}
|
|
|
|
public static void writeUInt32List(int i, List<Integer> list, Writer writer, boolean z) throws IOException {
|
|
if (list == null || list.isEmpty()) {
|
|
return;
|
|
}
|
|
writer.writeUInt32List(i, list, z);
|
|
}
|
|
|
|
public static void writeSInt32List(int i, List<Integer> list, Writer writer, boolean z) throws IOException {
|
|
if (list == null || list.isEmpty()) {
|
|
return;
|
|
}
|
|
writer.writeSInt32List(i, list, z);
|
|
}
|
|
|
|
public static void writeFixed32List(int i, List<Integer> list, Writer writer, boolean z) throws IOException {
|
|
if (list == null || list.isEmpty()) {
|
|
return;
|
|
}
|
|
writer.writeFixed32List(i, list, z);
|
|
}
|
|
|
|
public static void writeSFixed32List(int i, List<Integer> list, Writer writer, boolean z) throws IOException {
|
|
if (list == null || list.isEmpty()) {
|
|
return;
|
|
}
|
|
writer.writeSFixed32List(i, list, z);
|
|
}
|
|
|
|
public static void writeEnumList(int i, List<Integer> list, Writer writer, boolean z) throws IOException {
|
|
if (list == null || list.isEmpty()) {
|
|
return;
|
|
}
|
|
writer.writeEnumList(i, list, z);
|
|
}
|
|
|
|
public static void writeBoolList(int i, List<Boolean> list, Writer writer, boolean z) throws IOException {
|
|
if (list == null || list.isEmpty()) {
|
|
return;
|
|
}
|
|
writer.writeBoolList(i, list, z);
|
|
}
|
|
|
|
public static void writeStringList(int i, List<String> list, Writer writer) throws IOException {
|
|
if (list == null || list.isEmpty()) {
|
|
return;
|
|
}
|
|
writer.writeStringList(i, list);
|
|
}
|
|
|
|
public static void writeBytesList(int i, List<ByteString> list, Writer writer) throws IOException {
|
|
if (list == null || list.isEmpty()) {
|
|
return;
|
|
}
|
|
writer.writeBytesList(i, list);
|
|
}
|
|
|
|
public static void writeMessageList(int i, List<?> list, Writer writer) throws IOException {
|
|
if (list == null || list.isEmpty()) {
|
|
return;
|
|
}
|
|
writer.writeMessageList(i, list);
|
|
}
|
|
|
|
public static void writeMessageList(int i, List<?> list, Writer writer, Schema schema) throws IOException {
|
|
if (list == null || list.isEmpty()) {
|
|
return;
|
|
}
|
|
writer.writeMessageList(i, list, schema);
|
|
}
|
|
|
|
public static void writeLazyFieldList(int i, List<?> list, Writer writer) throws IOException {
|
|
if (list == null || list.isEmpty()) {
|
|
return;
|
|
}
|
|
Iterator<?> it = list.iterator();
|
|
while (it.hasNext()) {
|
|
((LazyFieldLite) it.next()).writeTo(writer, i);
|
|
}
|
|
}
|
|
|
|
public static void writeGroupList(int i, List<?> list, Writer writer) throws IOException {
|
|
if (list == null || list.isEmpty()) {
|
|
return;
|
|
}
|
|
writer.writeGroupList(i, list);
|
|
}
|
|
|
|
public static void writeGroupList(int i, List<?> list, Writer writer, Schema schema) throws IOException {
|
|
if (list == null || list.isEmpty()) {
|
|
return;
|
|
}
|
|
writer.writeGroupList(i, list, schema);
|
|
}
|
|
|
|
public static int computeSizeInt64ListNoTag(List<Long> list) {
|
|
int i;
|
|
int size = list.size();
|
|
int i2 = 0;
|
|
if (size == 0) {
|
|
return 0;
|
|
}
|
|
if (list instanceof LongArrayList) {
|
|
LongArrayList longArrayList = (LongArrayList) list;
|
|
i = 0;
|
|
while (i2 < size) {
|
|
i += CodedOutputStream.computeInt64SizeNoTag(longArrayList.getLong(i2));
|
|
i2++;
|
|
}
|
|
} else {
|
|
i = 0;
|
|
while (i2 < size) {
|
|
i += CodedOutputStream.computeInt64SizeNoTag(list.get(i2).longValue());
|
|
i2++;
|
|
}
|
|
}
|
|
return i;
|
|
}
|
|
|
|
public static int computeSizeInt64List(int i, List<Long> list, boolean z) {
|
|
if (list.size() == 0) {
|
|
return 0;
|
|
}
|
|
int computeSizeInt64ListNoTag = computeSizeInt64ListNoTag(list);
|
|
if (z) {
|
|
return CodedOutputStream.computeTagSize(i) + CodedOutputStream.computeLengthDelimitedFieldSize(computeSizeInt64ListNoTag);
|
|
}
|
|
return computeSizeInt64ListNoTag + (list.size() * CodedOutputStream.computeTagSize(i));
|
|
}
|
|
|
|
public static int computeSizeUInt64ListNoTag(List<Long> list) {
|
|
int i;
|
|
int size = list.size();
|
|
int i2 = 0;
|
|
if (size == 0) {
|
|
return 0;
|
|
}
|
|
if (list instanceof LongArrayList) {
|
|
LongArrayList longArrayList = (LongArrayList) list;
|
|
i = 0;
|
|
while (i2 < size) {
|
|
i += CodedOutputStream.computeUInt64SizeNoTag(longArrayList.getLong(i2));
|
|
i2++;
|
|
}
|
|
} else {
|
|
i = 0;
|
|
while (i2 < size) {
|
|
i += CodedOutputStream.computeUInt64SizeNoTag(list.get(i2).longValue());
|
|
i2++;
|
|
}
|
|
}
|
|
return i;
|
|
}
|
|
|
|
public static int computeSizeUInt64List(int i, List<Long> list, boolean z) {
|
|
int size = list.size();
|
|
if (size == 0) {
|
|
return 0;
|
|
}
|
|
int computeSizeUInt64ListNoTag = computeSizeUInt64ListNoTag(list);
|
|
if (z) {
|
|
return CodedOutputStream.computeTagSize(i) + CodedOutputStream.computeLengthDelimitedFieldSize(computeSizeUInt64ListNoTag);
|
|
}
|
|
return computeSizeUInt64ListNoTag + (size * CodedOutputStream.computeTagSize(i));
|
|
}
|
|
|
|
public static int computeSizeSInt64ListNoTag(List<Long> list) {
|
|
int i;
|
|
int size = list.size();
|
|
int i2 = 0;
|
|
if (size == 0) {
|
|
return 0;
|
|
}
|
|
if (list instanceof LongArrayList) {
|
|
LongArrayList longArrayList = (LongArrayList) list;
|
|
i = 0;
|
|
while (i2 < size) {
|
|
i += CodedOutputStream.computeSInt64SizeNoTag(longArrayList.getLong(i2));
|
|
i2++;
|
|
}
|
|
} else {
|
|
i = 0;
|
|
while (i2 < size) {
|
|
i += CodedOutputStream.computeSInt64SizeNoTag(list.get(i2).longValue());
|
|
i2++;
|
|
}
|
|
}
|
|
return i;
|
|
}
|
|
|
|
public static int computeSizeSInt64List(int i, List<Long> list, boolean z) {
|
|
int size = list.size();
|
|
if (size == 0) {
|
|
return 0;
|
|
}
|
|
int computeSizeSInt64ListNoTag = computeSizeSInt64ListNoTag(list);
|
|
if (z) {
|
|
return CodedOutputStream.computeTagSize(i) + CodedOutputStream.computeLengthDelimitedFieldSize(computeSizeSInt64ListNoTag);
|
|
}
|
|
return computeSizeSInt64ListNoTag + (size * CodedOutputStream.computeTagSize(i));
|
|
}
|
|
|
|
public static int computeSizeEnumListNoTag(List<Integer> list) {
|
|
int i;
|
|
int size = list.size();
|
|
int i2 = 0;
|
|
if (size == 0) {
|
|
return 0;
|
|
}
|
|
if (list instanceof IntArrayList) {
|
|
IntArrayList intArrayList = (IntArrayList) list;
|
|
i = 0;
|
|
while (i2 < size) {
|
|
i += CodedOutputStream.computeEnumSizeNoTag(intArrayList.getInt(i2));
|
|
i2++;
|
|
}
|
|
} else {
|
|
i = 0;
|
|
while (i2 < size) {
|
|
i += CodedOutputStream.computeEnumSizeNoTag(list.get(i2).intValue());
|
|
i2++;
|
|
}
|
|
}
|
|
return i;
|
|
}
|
|
|
|
public static int computeSizeEnumList(int i, List<Integer> list, boolean z) {
|
|
int size = list.size();
|
|
if (size == 0) {
|
|
return 0;
|
|
}
|
|
int computeSizeEnumListNoTag = computeSizeEnumListNoTag(list);
|
|
if (z) {
|
|
return CodedOutputStream.computeTagSize(i) + CodedOutputStream.computeLengthDelimitedFieldSize(computeSizeEnumListNoTag);
|
|
}
|
|
return computeSizeEnumListNoTag + (size * CodedOutputStream.computeTagSize(i));
|
|
}
|
|
|
|
public static int computeSizeInt32ListNoTag(List<Integer> list) {
|
|
int i;
|
|
int size = list.size();
|
|
int i2 = 0;
|
|
if (size == 0) {
|
|
return 0;
|
|
}
|
|
if (list instanceof IntArrayList) {
|
|
IntArrayList intArrayList = (IntArrayList) list;
|
|
i = 0;
|
|
while (i2 < size) {
|
|
i += CodedOutputStream.computeInt32SizeNoTag(intArrayList.getInt(i2));
|
|
i2++;
|
|
}
|
|
} else {
|
|
i = 0;
|
|
while (i2 < size) {
|
|
i += CodedOutputStream.computeInt32SizeNoTag(list.get(i2).intValue());
|
|
i2++;
|
|
}
|
|
}
|
|
return i;
|
|
}
|
|
|
|
public static int computeSizeInt32List(int i, List<Integer> list, boolean z) {
|
|
int size = list.size();
|
|
if (size == 0) {
|
|
return 0;
|
|
}
|
|
int computeSizeInt32ListNoTag = computeSizeInt32ListNoTag(list);
|
|
if (z) {
|
|
return CodedOutputStream.computeTagSize(i) + CodedOutputStream.computeLengthDelimitedFieldSize(computeSizeInt32ListNoTag);
|
|
}
|
|
return computeSizeInt32ListNoTag + (size * CodedOutputStream.computeTagSize(i));
|
|
}
|
|
|
|
public static int computeSizeUInt32ListNoTag(List<Integer> list) {
|
|
int i;
|
|
int size = list.size();
|
|
int i2 = 0;
|
|
if (size == 0) {
|
|
return 0;
|
|
}
|
|
if (list instanceof IntArrayList) {
|
|
IntArrayList intArrayList = (IntArrayList) list;
|
|
i = 0;
|
|
while (i2 < size) {
|
|
i += CodedOutputStream.computeUInt32SizeNoTag(intArrayList.getInt(i2));
|
|
i2++;
|
|
}
|
|
} else {
|
|
i = 0;
|
|
while (i2 < size) {
|
|
i += CodedOutputStream.computeUInt32SizeNoTag(list.get(i2).intValue());
|
|
i2++;
|
|
}
|
|
}
|
|
return i;
|
|
}
|
|
|
|
public static int computeSizeUInt32List(int i, List<Integer> list, boolean z) {
|
|
int size = list.size();
|
|
if (size == 0) {
|
|
return 0;
|
|
}
|
|
int computeSizeUInt32ListNoTag = computeSizeUInt32ListNoTag(list);
|
|
if (z) {
|
|
return CodedOutputStream.computeTagSize(i) + CodedOutputStream.computeLengthDelimitedFieldSize(computeSizeUInt32ListNoTag);
|
|
}
|
|
return computeSizeUInt32ListNoTag + (size * CodedOutputStream.computeTagSize(i));
|
|
}
|
|
|
|
public static int computeSizeSInt32ListNoTag(List<Integer> list) {
|
|
int i;
|
|
int size = list.size();
|
|
int i2 = 0;
|
|
if (size == 0) {
|
|
return 0;
|
|
}
|
|
if (list instanceof IntArrayList) {
|
|
IntArrayList intArrayList = (IntArrayList) list;
|
|
i = 0;
|
|
while (i2 < size) {
|
|
i += CodedOutputStream.computeSInt32SizeNoTag(intArrayList.getInt(i2));
|
|
i2++;
|
|
}
|
|
} else {
|
|
i = 0;
|
|
while (i2 < size) {
|
|
i += CodedOutputStream.computeSInt32SizeNoTag(list.get(i2).intValue());
|
|
i2++;
|
|
}
|
|
}
|
|
return i;
|
|
}
|
|
|
|
public static int computeSizeSInt32List(int i, List<Integer> list, boolean z) {
|
|
int size = list.size();
|
|
if (size == 0) {
|
|
return 0;
|
|
}
|
|
int computeSizeSInt32ListNoTag = computeSizeSInt32ListNoTag(list);
|
|
if (z) {
|
|
return CodedOutputStream.computeTagSize(i) + CodedOutputStream.computeLengthDelimitedFieldSize(computeSizeSInt32ListNoTag);
|
|
}
|
|
return computeSizeSInt32ListNoTag + (size * CodedOutputStream.computeTagSize(i));
|
|
}
|
|
|
|
public static int computeSizeFixed32ListNoTag(List<?> list) {
|
|
return list.size() * 4;
|
|
}
|
|
|
|
public static int computeSizeFixed32List(int i, List<?> list, boolean z) {
|
|
int size = list.size();
|
|
if (size == 0) {
|
|
return 0;
|
|
}
|
|
if (z) {
|
|
return CodedOutputStream.computeTagSize(i) + CodedOutputStream.computeLengthDelimitedFieldSize(size * 4);
|
|
}
|
|
return size * CodedOutputStream.computeFixed32Size(i, 0);
|
|
}
|
|
|
|
public static int computeSizeFixed64ListNoTag(List<?> list) {
|
|
return list.size() * 8;
|
|
}
|
|
|
|
public static int computeSizeFixed64List(int i, List<?> list, boolean z) {
|
|
int size = list.size();
|
|
if (size == 0) {
|
|
return 0;
|
|
}
|
|
if (z) {
|
|
return CodedOutputStream.computeTagSize(i) + CodedOutputStream.computeLengthDelimitedFieldSize(size * 8);
|
|
}
|
|
return size * CodedOutputStream.computeFixed64Size(i, 0L);
|
|
}
|
|
|
|
public static int computeSizeBoolListNoTag(List<?> list) {
|
|
return list.size();
|
|
}
|
|
|
|
public static int computeSizeBoolList(int i, List<?> list, boolean z) {
|
|
int size = list.size();
|
|
if (size == 0) {
|
|
return 0;
|
|
}
|
|
if (z) {
|
|
return CodedOutputStream.computeTagSize(i) + CodedOutputStream.computeLengthDelimitedFieldSize(size);
|
|
}
|
|
return size * CodedOutputStream.computeBoolSize(i, true);
|
|
}
|
|
|
|
public static int computeSizeStringList(int i, List<?> list) {
|
|
int computeStringSizeNoTag;
|
|
int computeStringSizeNoTag2;
|
|
int size = list.size();
|
|
int i2 = 0;
|
|
if (size == 0) {
|
|
return 0;
|
|
}
|
|
int computeTagSize = CodedOutputStream.computeTagSize(i) * size;
|
|
if (list instanceof LazyStringList) {
|
|
LazyStringList lazyStringList = (LazyStringList) list;
|
|
while (i2 < size) {
|
|
Object raw = lazyStringList.getRaw(i2);
|
|
if (raw instanceof ByteString) {
|
|
computeStringSizeNoTag2 = CodedOutputStream.computeBytesSizeNoTag((ByteString) raw);
|
|
} else {
|
|
computeStringSizeNoTag2 = CodedOutputStream.computeStringSizeNoTag((String) raw);
|
|
}
|
|
computeTagSize += computeStringSizeNoTag2;
|
|
i2++;
|
|
}
|
|
} else {
|
|
while (i2 < size) {
|
|
Object obj = list.get(i2);
|
|
if (obj instanceof ByteString) {
|
|
computeStringSizeNoTag = CodedOutputStream.computeBytesSizeNoTag((ByteString) obj);
|
|
} else {
|
|
computeStringSizeNoTag = CodedOutputStream.computeStringSizeNoTag((String) obj);
|
|
}
|
|
computeTagSize += computeStringSizeNoTag;
|
|
i2++;
|
|
}
|
|
}
|
|
return computeTagSize;
|
|
}
|
|
|
|
public static int computeSizeMessage(int i, Object obj, Schema schema) {
|
|
if (obj instanceof LazyFieldLite) {
|
|
return CodedOutputStream.computeLazyFieldSize(i, (LazyFieldLite) obj);
|
|
}
|
|
return CodedOutputStream.computeMessageSize(i, (MessageLite) obj, schema);
|
|
}
|
|
|
|
public static int computeSizeMessageList(int i, List<?> list) {
|
|
int computeMessageSizeNoTag;
|
|
int size = list.size();
|
|
if (size == 0) {
|
|
return 0;
|
|
}
|
|
int computeTagSize = CodedOutputStream.computeTagSize(i) * size;
|
|
for (int i2 = 0; i2 < size; i2++) {
|
|
Object obj = list.get(i2);
|
|
if (obj instanceof LazyFieldLite) {
|
|
computeMessageSizeNoTag = CodedOutputStream.computeLazyFieldSizeNoTag((LazyFieldLite) obj);
|
|
} else {
|
|
computeMessageSizeNoTag = CodedOutputStream.computeMessageSizeNoTag((MessageLite) obj);
|
|
}
|
|
computeTagSize += computeMessageSizeNoTag;
|
|
}
|
|
return computeTagSize;
|
|
}
|
|
|
|
public static int computeSizeMessageList(int i, List<?> list, Schema schema) {
|
|
int computeMessageSizeNoTag;
|
|
int size = list.size();
|
|
if (size == 0) {
|
|
return 0;
|
|
}
|
|
int computeTagSize = CodedOutputStream.computeTagSize(i) * size;
|
|
for (int i2 = 0; i2 < size; i2++) {
|
|
Object obj = list.get(i2);
|
|
if (obj instanceof LazyFieldLite) {
|
|
computeMessageSizeNoTag = CodedOutputStream.computeLazyFieldSizeNoTag((LazyFieldLite) obj);
|
|
} else {
|
|
computeMessageSizeNoTag = CodedOutputStream.computeMessageSizeNoTag((MessageLite) obj, schema);
|
|
}
|
|
computeTagSize += computeMessageSizeNoTag;
|
|
}
|
|
return computeTagSize;
|
|
}
|
|
|
|
public static int computeSizeByteStringList(int i, List<ByteString> list) {
|
|
int size = list.size();
|
|
if (size == 0) {
|
|
return 0;
|
|
}
|
|
int computeTagSize = size * CodedOutputStream.computeTagSize(i);
|
|
for (int i2 = 0; i2 < list.size(); i2++) {
|
|
computeTagSize += CodedOutputStream.computeBytesSizeNoTag(list.get(i2));
|
|
}
|
|
return computeTagSize;
|
|
}
|
|
|
|
public static int computeSizeGroupList(int i, List<MessageLite> list) {
|
|
int size = list.size();
|
|
if (size == 0) {
|
|
return 0;
|
|
}
|
|
int i2 = 0;
|
|
for (int i3 = 0; i3 < size; i3++) {
|
|
i2 += CodedOutputStream.computeGroupSize(i, list.get(i3));
|
|
}
|
|
return i2;
|
|
}
|
|
|
|
public static int computeSizeGroupList(int i, List<MessageLite> list, Schema schema) {
|
|
int size = list.size();
|
|
if (size == 0) {
|
|
return 0;
|
|
}
|
|
int i2 = 0;
|
|
for (int i3 = 0; i3 < size; i3++) {
|
|
i2 += CodedOutputStream.computeGroupSize(i, list.get(i3), schema);
|
|
}
|
|
return i2;
|
|
}
|
|
|
|
public static boolean shouldUseTableSwitch(FieldInfo[] fieldInfoArr) {
|
|
if (fieldInfoArr.length == 0) {
|
|
return false;
|
|
}
|
|
return shouldUseTableSwitch(fieldInfoArr[0].getFieldNumber(), fieldInfoArr[fieldInfoArr.length - 1].getFieldNumber(), fieldInfoArr.length);
|
|
}
|
|
|
|
private static UnknownFieldSchema getUnknownFieldSetSchema(boolean z) {
|
|
try {
|
|
Class<?> unknownFieldSetSchemaClass = getUnknownFieldSetSchemaClass();
|
|
if (unknownFieldSetSchemaClass == null) {
|
|
return null;
|
|
}
|
|
return (UnknownFieldSchema) unknownFieldSetSchemaClass.getConstructor(Boolean.TYPE).newInstance(Boolean.valueOf(z));
|
|
} catch (Throwable unused) {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
private static Class<?> getGeneratedMessageClass() {
|
|
try {
|
|
return Class.forName("com.google.protobuf.GeneratedMessageV3");
|
|
} catch (Throwable unused) {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
private static Class<?> getUnknownFieldSetSchemaClass() {
|
|
try {
|
|
return Class.forName("com.google.protobuf.UnknownFieldSetSchema");
|
|
} catch (Throwable unused) {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public static Object getMapDefaultEntry(Class<?> cls, String str) {
|
|
try {
|
|
java.lang.reflect.Field[] declaredFields = Class.forName(cls.getName() + "$" + toCamelCase(str, true) + "DefaultEntryHolder").getDeclaredFields();
|
|
if (declaredFields.length != 1) {
|
|
throw new IllegalStateException("Unable to look up map field default entry holder class for " + str + " in " + cls.getName());
|
|
}
|
|
return UnsafeUtil.getStaticObject(declaredFields[0]);
|
|
} catch (Throwable th) {
|
|
throw new RuntimeException(th);
|
|
}
|
|
}
|
|
|
|
public static String toCamelCase(String str, boolean z) {
|
|
StringBuilder sb = new StringBuilder();
|
|
for (int i = 0; i < str.length(); i++) {
|
|
char charAt = str.charAt(i);
|
|
if ('a' > charAt || charAt > 'z') {
|
|
if ('A' > charAt || charAt > 'Z') {
|
|
if ('0' <= charAt && charAt <= '9') {
|
|
sb.append(charAt);
|
|
}
|
|
z = true;
|
|
} else if (i == 0 && !z) {
|
|
sb.append((char) (charAt + ' '));
|
|
} else {
|
|
sb.append(charAt);
|
|
}
|
|
} else if (z) {
|
|
sb.append((char) (charAt - ' '));
|
|
} else {
|
|
sb.append(charAt);
|
|
}
|
|
z = false;
|
|
}
|
|
return sb.toString();
|
|
}
|
|
|
|
public static boolean safeEquals(Object obj, Object obj2) {
|
|
return obj == obj2 || (obj != null && obj.equals(obj2));
|
|
}
|
|
|
|
public static <T> void mergeMap(MapFieldSchema mapFieldSchema, T t, T t2, long j) {
|
|
UnsafeUtil.putObject(t, j, mapFieldSchema.mergeFrom(UnsafeUtil.getObject(t, j), UnsafeUtil.getObject(t2, j)));
|
|
}
|
|
|
|
public static <T, FT extends FieldSet.FieldDescriptorLite<FT>> void mergeExtensions(ExtensionSchema extensionSchema, T t, T t2) {
|
|
FieldSet extensions = extensionSchema.getExtensions(t2);
|
|
if (extensions.isEmpty()) {
|
|
return;
|
|
}
|
|
extensionSchema.getMutableExtensions(t).mergeFrom(extensions);
|
|
}
|
|
|
|
public static <T, UT, UB> void mergeUnknownFields(UnknownFieldSchema unknownFieldSchema, T t, T t2) {
|
|
unknownFieldSchema.setToMessage(t, unknownFieldSchema.merge(unknownFieldSchema.getFromMessage(t), unknownFieldSchema.getFromMessage(t2)));
|
|
}
|
|
|
|
public static <UT, UB> UB filterUnknownEnumList(Object obj, int i, List<Integer> list, Internal.EnumLiteMap<?> enumLiteMap, UB ub, UnknownFieldSchema unknownFieldSchema) {
|
|
if (enumLiteMap == null) {
|
|
return ub;
|
|
}
|
|
if (list instanceof RandomAccess) {
|
|
int size = list.size();
|
|
int i2 = 0;
|
|
for (int i3 = 0; i3 < size; i3++) {
|
|
int intValue = list.get(i3).intValue();
|
|
if (enumLiteMap.findValueByNumber(intValue) != null) {
|
|
if (i3 != i2) {
|
|
list.set(i2, Integer.valueOf(intValue));
|
|
}
|
|
i2++;
|
|
} else {
|
|
ub = (UB) storeUnknownEnum(obj, i, intValue, ub, unknownFieldSchema);
|
|
}
|
|
}
|
|
if (i2 != size) {
|
|
list.subList(i2, size).clear();
|
|
}
|
|
} else {
|
|
Iterator<Integer> it = list.iterator();
|
|
while (it.hasNext()) {
|
|
int intValue2 = it.next().intValue();
|
|
if (enumLiteMap.findValueByNumber(intValue2) == null) {
|
|
ub = (UB) storeUnknownEnum(obj, i, intValue2, ub, unknownFieldSchema);
|
|
it.remove();
|
|
}
|
|
}
|
|
}
|
|
return ub;
|
|
}
|
|
|
|
public static <UT, UB> UB filterUnknownEnumList(Object obj, int i, List<Integer> list, Internal.EnumVerifier enumVerifier, UB ub, UnknownFieldSchema unknownFieldSchema) {
|
|
if (enumVerifier == null) {
|
|
return ub;
|
|
}
|
|
if (list instanceof RandomAccess) {
|
|
int size = list.size();
|
|
int i2 = 0;
|
|
for (int i3 = 0; i3 < size; i3++) {
|
|
int intValue = list.get(i3).intValue();
|
|
if (enumVerifier.isInRange(intValue)) {
|
|
if (i3 != i2) {
|
|
list.set(i2, Integer.valueOf(intValue));
|
|
}
|
|
i2++;
|
|
} else {
|
|
ub = (UB) storeUnknownEnum(obj, i, intValue, ub, unknownFieldSchema);
|
|
}
|
|
}
|
|
if (i2 != size) {
|
|
list.subList(i2, size).clear();
|
|
}
|
|
} else {
|
|
Iterator<Integer> it = list.iterator();
|
|
while (it.hasNext()) {
|
|
int intValue2 = it.next().intValue();
|
|
if (!enumVerifier.isInRange(intValue2)) {
|
|
ub = (UB) storeUnknownEnum(obj, i, intValue2, ub, unknownFieldSchema);
|
|
it.remove();
|
|
}
|
|
}
|
|
}
|
|
return ub;
|
|
}
|
|
|
|
public static <UT, UB> UB storeUnknownEnum(Object obj, int i, int i2, UB ub, UnknownFieldSchema unknownFieldSchema) {
|
|
if (ub == null) {
|
|
ub = (UB) unknownFieldSchema.getBuilderFromMessage(obj);
|
|
}
|
|
unknownFieldSchema.addVarint(ub, i, i2);
|
|
return ub;
|
|
}
|
|
}
|