135 lines
6.2 KiB
Java
135 lines
6.2 KiB
Java
|
package com.google.android.gms.internal.vision;
|
||
|
|
||
|
import com.google.common.primitives.UnsignedBytes;
|
||
|
import java.lang.reflect.Array;
|
||
|
import java.lang.reflect.Field;
|
||
|
import java.lang.reflect.InvocationTargetException;
|
||
|
import java.lang.reflect.Method;
|
||
|
import org.bouncycastle.asn1.x509.DisplayText;
|
||
|
|
||
|
/* loaded from: classes2.dex */
|
||
|
public final class zzju {
|
||
|
public static <T extends zzjt> String zzb(T t) {
|
||
|
if (t == null) {
|
||
|
return "";
|
||
|
}
|
||
|
StringBuffer stringBuffer = new StringBuffer();
|
||
|
try {
|
||
|
zza(null, t, new StringBuffer(), stringBuffer);
|
||
|
return stringBuffer.toString();
|
||
|
} catch (IllegalAccessException e) {
|
||
|
String valueOf = String.valueOf(e.getMessage());
|
||
|
return valueOf.length() != 0 ? "Error printing proto: ".concat(valueOf) : new String("Error printing proto: ");
|
||
|
} catch (InvocationTargetException e2) {
|
||
|
String valueOf2 = String.valueOf(e2.getMessage());
|
||
|
return valueOf2.length() != 0 ? "Error printing proto: ".concat(valueOf2) : new String("Error printing proto: ");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private static void zza(String str, Object obj, StringBuffer stringBuffer, StringBuffer stringBuffer2) throws IllegalAccessException, InvocationTargetException {
|
||
|
if (obj != null) {
|
||
|
int i = 0;
|
||
|
if (obj instanceof zzjt) {
|
||
|
int length = stringBuffer.length();
|
||
|
if (str != null) {
|
||
|
stringBuffer2.append(stringBuffer).append(zzs(str)).append(" <\n");
|
||
|
stringBuffer.append(" ");
|
||
|
}
|
||
|
Class<?> cls = obj.getClass();
|
||
|
for (Field field : cls.getFields()) {
|
||
|
int modifiers = field.getModifiers();
|
||
|
String name = field.getName();
|
||
|
if (!"cachedSize".equals(name) && (modifiers & 1) == 1 && (modifiers & 8) != 8 && !name.startsWith("_") && !name.endsWith("_")) {
|
||
|
Class<?> type = field.getType();
|
||
|
Object obj2 = field.get(obj);
|
||
|
if (type.isArray() && type.getComponentType() != Byte.TYPE) {
|
||
|
int length2 = obj2 == null ? 0 : Array.getLength(obj2);
|
||
|
for (int i2 = 0; i2 < length2; i2++) {
|
||
|
zza(name, Array.get(obj2, i2), stringBuffer, stringBuffer2);
|
||
|
}
|
||
|
} else {
|
||
|
zza(name, obj2, stringBuffer, stringBuffer2);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
for (Method method : cls.getMethods()) {
|
||
|
String name2 = method.getName();
|
||
|
if (name2.startsWith("set")) {
|
||
|
String substring = name2.substring(3);
|
||
|
try {
|
||
|
String valueOf = String.valueOf(substring);
|
||
|
if (((Boolean) cls.getMethod(valueOf.length() != 0 ? "has".concat(valueOf) : new String("has"), new Class[0]).invoke(obj, new Object[0])).booleanValue()) {
|
||
|
String valueOf2 = String.valueOf(substring);
|
||
|
zza(substring, cls.getMethod(valueOf2.length() != 0 ? "get".concat(valueOf2) : new String("get"), new Class[0]).invoke(obj, new Object[0]), stringBuffer, stringBuffer2);
|
||
|
}
|
||
|
} catch (NoSuchMethodException unused) {
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
if (str != null) {
|
||
|
stringBuffer.setLength(length);
|
||
|
stringBuffer2.append(stringBuffer).append(">\n");
|
||
|
return;
|
||
|
}
|
||
|
return;
|
||
|
}
|
||
|
stringBuffer2.append(stringBuffer).append(zzs(str)).append(": ");
|
||
|
if (obj instanceof String) {
|
||
|
String str2 = (String) obj;
|
||
|
if (!str2.startsWith("http") && str2.length() > 200) {
|
||
|
str2 = String.valueOf(str2.substring(0, DisplayText.DISPLAY_TEXT_MAXIMUM_SIZE)).concat("[...]");
|
||
|
}
|
||
|
int length3 = str2.length();
|
||
|
StringBuilder sb = new StringBuilder(length3);
|
||
|
while (i < length3) {
|
||
|
char charAt = str2.charAt(i);
|
||
|
if (charAt >= ' ' && charAt <= '~' && charAt != '\"' && charAt != '\'') {
|
||
|
sb.append(charAt);
|
||
|
} else {
|
||
|
sb.append(String.format("\\u%04x", Integer.valueOf(charAt)));
|
||
|
}
|
||
|
i++;
|
||
|
}
|
||
|
stringBuffer2.append("\"").append(sb.toString()).append("\"");
|
||
|
} else if (obj instanceof byte[]) {
|
||
|
byte[] bArr = (byte[]) obj;
|
||
|
if (bArr == null) {
|
||
|
stringBuffer2.append("\"\"");
|
||
|
} else {
|
||
|
stringBuffer2.append('\"');
|
||
|
while (i < bArr.length) {
|
||
|
int i3 = bArr[i] & UnsignedBytes.MAX_VALUE;
|
||
|
if (i3 == 92 || i3 == 34) {
|
||
|
stringBuffer2.append('\\').append((char) i3);
|
||
|
} else if (i3 >= 32 && i3 < 127) {
|
||
|
stringBuffer2.append((char) i3);
|
||
|
} else {
|
||
|
stringBuffer2.append(String.format("\\%03o", Integer.valueOf(i3)));
|
||
|
}
|
||
|
i++;
|
||
|
}
|
||
|
stringBuffer2.append('\"');
|
||
|
}
|
||
|
} else {
|
||
|
stringBuffer2.append(obj);
|
||
|
}
|
||
|
stringBuffer2.append("\n");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private static String zzs(String str) {
|
||
|
StringBuffer stringBuffer = new StringBuffer();
|
||
|
for (int i = 0; i < str.length(); i++) {
|
||
|
char charAt = str.charAt(i);
|
||
|
if (i == 0) {
|
||
|
stringBuffer.append(Character.toLowerCase(charAt));
|
||
|
} else if (Character.isUpperCase(charAt)) {
|
||
|
stringBuffer.append('_').append(Character.toLowerCase(charAt));
|
||
|
} else {
|
||
|
stringBuffer.append(charAt);
|
||
|
}
|
||
|
}
|
||
|
return stringBuffer.toString();
|
||
|
}
|
||
|
}
|