what-the-bank/sources/com/google/android/gms/common/server/response/FastParser.java

697 lines
25 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package com.google.android.gms.common.server.response;
import com.google.android.gms.common.server.response.FastJsonResponse;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Map;
import java.util.Stack;
import org.bouncycastle.asn1.cmp.PKIFailureInfo;
import org.simpleframework.xml.core.FieldScanner;
/* loaded from: classes.dex */
public class FastParser<T extends FastJsonResponse> {
private static final char[] zaa = {'u', 'l', 'l'};
private static final char[] zab = {'r', 'u', 'e'};
private static final char[] zac = {'r', 'u', 'e', '\"'};
private static final char[] zad = {'a', 'l', 's', 'e'};
private static final char[] zae = {'a', 'l', 's', 'e', '\"'};
private static final char[] zaf = {'\n'};
private static final zai<Integer> zag = new zaa();
private static final zai<Long> zah = new zab();
private static final zai<Float> zai = new zac();
private static final zai<Double> zaj = new zad();
private static final zai<Boolean> zak = new zae();
private static final zai<String> zal = new zaf();
private static final zai<BigInteger> zam = new zag();
private static final zai<BigDecimal> zan = new zah();
private final char[] zao = new char[1];
private final char[] zap = new char[32];
private final char[] zaq = new char[1024];
private final StringBuilder zar = new StringBuilder(32);
private final StringBuilder zas = new StringBuilder(1024);
private final Stack<Integer> zat = new Stack<>();
/* loaded from: classes.dex */
public static class ParseException extends Exception {
public ParseException(String str) {
super(str);
}
public ParseException(String str, Throwable th) {
super("Error instantiating inner object", th);
}
public ParseException(Throwable th) {
super(th);
}
}
/* JADX WARN: Code restructure failed: missing block: B:17:0x002f, code lost:
throw new com.google.android.gms.common.server.response.FastParser.ParseException("Unexpected control character while reading string");
*/
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
private static final java.lang.String zaA(java.io.BufferedReader r8, char[] r9, java.lang.StringBuilder r10, char[] r11) throws com.google.android.gms.common.server.response.FastParser.ParseException, java.io.IOException {
/*
r0 = 0
r10.setLength(r0)
int r1 = r9.length
r8.mark(r1)
r1 = r0
r2 = r1
La:
int r3 = r8.read(r9)
r4 = -1
if (r3 == r4) goto L66
r4 = r0
L12:
if (r4 >= r3) goto L5e
char r5 = r9[r4]
boolean r6 = java.lang.Character.isISOControl(r5)
if (r6 == 0) goto L30
if (r11 == 0) goto L28
r6 = r0
L1f:
if (r6 > 0) goto L28
char r7 = r11[r6]
if (r7 == r5) goto L30
int r6 = r6 + 1
goto L1f
L28:
com.google.android.gms.common.server.response.FastParser$ParseException r8 = new com.google.android.gms.common.server.response.FastParser$ParseException
java.lang.String r9 = "Unexpected control character while reading string"
r8.<init>(r9)
throw r8
L30:
r6 = 34
r7 = 1
if (r5 != r6) goto L52
if (r1 != 0) goto L5a
r10.append(r9, r0, r4)
r8.reset()
int r4 = r4 + r7
long r0 = (long) r4
r8.skip(r0)
if (r2 == 0) goto L4d
java.lang.String r8 = r10.toString()
java.lang.String r8 = com.google.android.gms.common.util.JsonUtils.unescapeString(r8)
return r8
L4d:
java.lang.String r8 = r10.toString()
return r8
L52:
r6 = 92
if (r5 != r6) goto L5a
r1 = r1 ^ 1
r2 = r7
goto L5b
L5a:
r1 = r0
L5b:
int r4 = r4 + 1
goto L12
L5e:
r10.append(r9, r0, r3)
int r3 = r9.length
r8.mark(r3)
goto La
L66:
com.google.android.gms.common.server.response.FastParser$ParseException r8 = new com.google.android.gms.common.server.response.FastParser$ParseException
java.lang.String r9 = "Unexpected EOF while parsing string"
r8.<init>(r9)
throw r8
*/
throw new UnsupportedOperationException("Method not decompiled: com.google.android.gms.common.server.response.FastParser.zaA(java.io.BufferedReader, char[], java.lang.StringBuilder, char[]):java.lang.String");
}
private final char zai(BufferedReader bufferedReader) throws ParseException, IOException {
if (bufferedReader.read(this.zao) == -1) {
return (char) 0;
}
while (Character.isWhitespace(this.zao[0])) {
if (bufferedReader.read(this.zao) == -1) {
return (char) 0;
}
}
return this.zao[0];
}
/* JADX INFO: Access modifiers changed from: private */
public final double zaj(BufferedReader bufferedReader) throws ParseException, IOException {
int zam2 = zam(bufferedReader, this.zaq);
if (zam2 == 0) {
return 0.0d;
}
return Double.parseDouble(new String(this.zaq, 0, zam2));
}
/* JADX INFO: Access modifiers changed from: private */
public final float zak(BufferedReader bufferedReader) throws ParseException, IOException {
int zam2 = zam(bufferedReader, this.zaq);
return zam2 == 0 ? BitmapDescriptorFactory.HUE_RED : Float.parseFloat(new String(this.zaq, 0, zam2));
}
/* JADX INFO: Access modifiers changed from: private */
public final int zal(BufferedReader bufferedReader) throws ParseException, IOException {
int i;
int i2;
int zam2 = zam(bufferedReader, this.zaq);
if (zam2 == 0) {
return 0;
}
char[] cArr = this.zaq;
if (zam2 <= 0) {
throw new ParseException("No number to parse");
}
char c = cArr[0];
int i3 = c == '-' ? PKIFailureInfo.systemUnavail : -2147483647;
int i4 = c == '-' ? 1 : 0;
if (i4 < zam2) {
i2 = i4 + 1;
int digit = Character.digit(cArr[i4], 10);
if (digit < 0) {
throw new ParseException("Unexpected non-digit character");
}
i = -digit;
} else {
i = 0;
i2 = i4;
}
while (i2 < zam2) {
int digit2 = Character.digit(cArr[i2], 10);
if (digit2 < 0) {
throw new ParseException("Unexpected non-digit character");
}
if (i < -214748364) {
throw new ParseException("Number too large");
}
int i5 = i * 10;
if (i5 < i3 + digit2) {
throw new ParseException("Number too large");
}
i = i5 - digit2;
i2++;
}
if (i4 == 0) {
return -i;
}
if (i2 > 1) {
return i;
}
throw new ParseException("No digits to parse");
}
private final int zam(BufferedReader bufferedReader, char[] cArr) throws ParseException, IOException {
int i;
char zai2 = zai(bufferedReader);
if (zai2 == 0) {
throw new ParseException("Unexpected EOF");
}
if (zai2 == ',') {
throw new ParseException("Missing value");
}
if (zai2 == 'n') {
zax(bufferedReader, zaa);
return 0;
}
bufferedReader.mark(1024);
if (zai2 == '\"') {
i = 0;
boolean z = false;
while (i < 1024 && bufferedReader.read(cArr, i, 1) != -1) {
char c = cArr[i];
if (Character.isISOControl(c)) {
throw new ParseException("Unexpected control character while reading string");
}
if (c == '\"') {
if (!z) {
bufferedReader.reset();
bufferedReader.skip(i + 1);
return i;
}
} else if (c == '\\') {
z = !z;
i++;
}
z = false;
i++;
}
} else {
cArr[0] = zai2;
i = 1;
while (i < 1024 && bufferedReader.read(cArr, i, 1) != -1) {
char c2 = cArr[i];
if (c2 == '}' || c2 == ',' || Character.isWhitespace(c2) || cArr[i] == ']') {
bufferedReader.reset();
bufferedReader.skip(i - 1);
cArr[i] = 0;
return i;
}
i++;
}
}
if (i == 1024) {
throw new ParseException("Absurdly long value");
}
throw new ParseException("Unexpected EOF");
}
/* JADX INFO: Access modifiers changed from: private */
public final long zan(BufferedReader bufferedReader) throws ParseException, IOException {
long j;
int i;
int zam2 = zam(bufferedReader, this.zaq);
if (zam2 == 0) {
return 0L;
}
char[] cArr = this.zaq;
if (zam2 <= 0) {
throw new ParseException("No number to parse");
}
char c = cArr[0];
long j2 = c == '-' ? Long.MIN_VALUE : -9223372036854775807L;
int i2 = c == '-' ? 1 : 0;
if (i2 < zam2) {
i = i2 + 1;
int digit = Character.digit(cArr[i2], 10);
if (digit < 0) {
throw new ParseException("Unexpected non-digit character");
}
j = -digit;
} else {
j = 0;
i = i2;
}
while (i < zam2) {
int digit2 = Character.digit(cArr[i], 10);
if (digit2 < 0) {
throw new ParseException("Unexpected non-digit character");
}
if (j < -922337203685477580L) {
throw new ParseException("Number too large");
}
long j3 = j * 10;
int i3 = zam2;
long j4 = digit2;
if (j3 < j2 + j4) {
throw new ParseException("Number too large");
}
j = j3 - j4;
i++;
zam2 = i3;
}
if (i2 == 0) {
return -j;
}
if (i > 1) {
return j;
}
throw new ParseException("No digits to parse");
}
/* JADX INFO: Access modifiers changed from: private */
public final String zao(BufferedReader bufferedReader) throws ParseException, IOException {
return zap(bufferedReader, this.zap, this.zar, null);
}
private final String zap(BufferedReader bufferedReader, char[] cArr, StringBuilder sb, char[] cArr2) throws ParseException, IOException {
char zai2 = zai(bufferedReader);
if (zai2 == '\"') {
return zaA(bufferedReader, cArr, sb, cArr2);
}
if (zai2 == 'n') {
zax(bufferedReader, zaa);
return null;
}
throw new ParseException("Expected string");
}
private final String zaq(BufferedReader bufferedReader) throws ParseException, IOException {
this.zat.push(2);
char zai2 = zai(bufferedReader);
if (zai2 == '\"') {
this.zat.push(3);
String zaA = zaA(bufferedReader, this.zap, this.zar, null);
zaw(3);
if (zai(bufferedReader) == ':') {
return zaA;
}
throw new ParseException("Expected key/value separator");
}
if (zai2 == ']') {
zaw(2);
zaw(1);
zaw(5);
return null;
}
if (zai2 == '}') {
zaw(2);
return null;
}
StringBuilder sb = new StringBuilder(19);
sb.append("Unexpected token: ");
sb.append(zai2);
throw new ParseException(sb.toString());
}
private final String zar(BufferedReader bufferedReader) throws ParseException, IOException {
bufferedReader.mark(1024);
char zai2 = zai(bufferedReader);
int i = 1;
if (zai2 == '\"') {
if (bufferedReader.read(this.zao) != -1) {
char c = this.zao[0];
boolean z = false;
do {
if (c == '\"') {
if (z) {
z = true;
c = '\"';
}
}
z = c == '\\' ? !z : false;
if (bufferedReader.read(this.zao) != -1) {
c = this.zao[0];
} else {
throw new ParseException("Unexpected EOF while parsing string");
}
} while (!Character.isISOControl(c));
throw new ParseException("Unexpected control character while reading string");
}
throw new ParseException("Unexpected EOF while parsing string");
}
if (zai2 == ',') {
throw new ParseException("Missing value");
}
if (zai2 == '[') {
this.zat.push(5);
bufferedReader.mark(32);
if (zai(bufferedReader) == ']') {
zaw(5);
} else {
bufferedReader.reset();
boolean z2 = false;
boolean z3 = false;
while (i > 0) {
char zai3 = zai(bufferedReader);
if (zai3 != 0) {
if (Character.isISOControl(zai3)) {
throw new ParseException("Unexpected control character while reading array");
}
if (zai3 == '\"') {
if (!z3) {
z2 = !z2;
}
zai3 = '\"';
}
if (zai3 == '[') {
if (!z2) {
i++;
}
zai3 = '[';
}
if (zai3 == ']' && !z2) {
i--;
}
z3 = (zai3 == '\\' && z2) ? !z3 : false;
} else {
throw new ParseException("Unexpected EOF while parsing array");
}
}
zaw(5);
}
} else if (zai2 == '{') {
this.zat.push(1);
bufferedReader.mark(32);
char zai4 = zai(bufferedReader);
if (zai4 == '}') {
zaw(1);
} else if (zai4 == '\"') {
bufferedReader.reset();
zaq(bufferedReader);
do {
} while (zar(bufferedReader) != null);
zaw(1);
} else {
StringBuilder sb = new StringBuilder(18);
sb.append("Unexpected token ");
sb.append(zai4);
throw new ParseException(sb.toString());
}
} else {
bufferedReader.reset();
zam(bufferedReader, this.zaq);
}
char zai5 = zai(bufferedReader);
if (zai5 == ',') {
zaw(2);
return zaq(bufferedReader);
}
if (zai5 == '}') {
zaw(2);
return null;
}
StringBuilder sb2 = new StringBuilder(18);
sb2.append("Unexpected token ");
sb2.append(zai5);
throw new ParseException(sb2.toString());
}
/* JADX INFO: Access modifiers changed from: private */
public final BigDecimal zas(BufferedReader bufferedReader) throws ParseException, IOException {
int zam2 = zam(bufferedReader, this.zaq);
if (zam2 == 0) {
return null;
}
return new BigDecimal(new String(this.zaq, 0, zam2));
}
/* JADX INFO: Access modifiers changed from: private */
public final BigInteger zat(BufferedReader bufferedReader) throws ParseException, IOException {
int zam2 = zam(bufferedReader, this.zaq);
if (zam2 == 0) {
return null;
}
return new BigInteger(new String(this.zaq, 0, zam2));
}
private final <O> ArrayList<O> zau(BufferedReader bufferedReader, zai<O> zaiVar) throws ParseException, IOException {
char zai2 = zai(bufferedReader);
if (zai2 == 'n') {
zax(bufferedReader, zaa);
return null;
}
if (zai2 != '[') {
throw new ParseException("Expected start of array");
}
this.zat.push(5);
ArrayList<O> arrayList = new ArrayList<>();
while (true) {
bufferedReader.mark(1024);
char zai3 = zai(bufferedReader);
if (zai3 == 0) {
throw new ParseException("Unexpected EOF");
}
if (zai3 != ',') {
if (zai3 != ']') {
bufferedReader.reset();
arrayList.add(zaiVar.zaa(this, bufferedReader));
} else {
zaw(5);
return arrayList;
}
}
}
}
private final <T extends FastJsonResponse> ArrayList<T> zav(BufferedReader bufferedReader, FastJsonResponse.Field<?, ?> field) throws ParseException, IOException {
FieldScanner fieldScanner = (ArrayList<T>) new ArrayList();
char zai2 = zai(bufferedReader);
if (zai2 == ']') {
zaw(5);
return fieldScanner;
}
if (zai2 == 'n') {
zax(bufferedReader, zaa);
zaw(5);
return null;
}
if (zai2 == '{') {
this.zat.push(1);
while (true) {
try {
FastJsonResponse zad2 = field.zad();
if (!zaz(bufferedReader, zad2)) {
return fieldScanner;
}
fieldScanner.add(zad2);
char zai3 = zai(bufferedReader);
if (zai3 != ',') {
if (zai3 == ']') {
zaw(5);
return fieldScanner;
}
StringBuilder sb = new StringBuilder(19);
sb.append("Unexpected token: ");
sb.append(zai3);
throw new ParseException(sb.toString());
}
if (zai(bufferedReader) == '{') {
this.zat.push(1);
} else {
throw new ParseException("Expected start of next object in array");
}
} catch (IllegalAccessException e) {
throw new ParseException("Error instantiating inner object", e);
} catch (InstantiationException e2) {
throw new ParseException("Error instantiating inner object", e2);
}
}
} else {
StringBuilder sb2 = new StringBuilder(19);
sb2.append("Unexpected token: ");
sb2.append(zai2);
throw new ParseException(sb2.toString());
}
}
private final void zaw(int i) throws ParseException {
if (this.zat.isEmpty()) {
StringBuilder sb = new StringBuilder(46);
sb.append("Expected state ");
sb.append(i);
sb.append(" but had empty stack");
throw new ParseException(sb.toString());
}
int intValue = this.zat.pop().intValue();
if (intValue == i) {
return;
}
StringBuilder sb2 = new StringBuilder(46);
sb2.append("Expected state ");
sb2.append(i);
sb2.append(" but had ");
sb2.append(intValue);
throw new ParseException(sb2.toString());
}
private final void zax(BufferedReader bufferedReader, char[] cArr) throws ParseException, IOException {
int i = 0;
while (true) {
int length = cArr.length;
if (i >= length) {
return;
}
int read = bufferedReader.read(this.zap, 0, length - i);
if (read == -1) {
throw new ParseException("Unexpected EOF");
}
for (int i2 = 0; i2 < read; i2++) {
if (cArr[i2 + i] != this.zap[i2]) {
throw new ParseException("Unexpected character");
}
}
i += read;
}
}
/* JADX INFO: Access modifiers changed from: private */
public final boolean zay(BufferedReader bufferedReader, boolean z) throws ParseException, IOException {
while (true) {
char zai2 = zai(bufferedReader);
if (zai2 != '\"') {
if (zai2 == 'f') {
zax(bufferedReader, z ? zae : zad);
return false;
}
if (zai2 == 'n') {
zax(bufferedReader, zaa);
return false;
}
if (zai2 == 't') {
zax(bufferedReader, z ? zac : zab);
return true;
}
StringBuilder sb = new StringBuilder(19);
sb.append("Unexpected token: ");
sb.append(zai2);
throw new ParseException(sb.toString());
}
if (z) {
throw new ParseException("No boolean value found in string");
}
z = true;
}
}
/* JADX WARN: Failed to find 'out' block for switch in B:8:0x003b. Please report as an issue. */
/* JADX WARN: Multi-variable type inference failed */
/* JADX WARN: Removed duplicated region for block: B:17:0x028e A[SYNTHETIC] */
/* JADX WARN: Removed duplicated region for block: B:21:0x0270 A[SYNTHETIC] */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
private final boolean zaz(java.io.BufferedReader r17, com.google.android.gms.common.server.response.FastJsonResponse r18) throws com.google.android.gms.common.server.response.FastParser.ParseException, java.io.IOException {
/*
Method dump skipped, instructions count: 698
To view this dump add '--comments-level debug' option
*/
throw new UnsupportedOperationException("Method not decompiled: com.google.android.gms.common.server.response.FastParser.zaz(java.io.BufferedReader, com.google.android.gms.common.server.response.FastJsonResponse):boolean");
}
public void parse(InputStream inputStream, T t) throws ParseException {
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream), 1024);
try {
try {
this.zat.push(0);
char zai2 = zai(bufferedReader);
if (zai2 != 0) {
if (zai2 == '[') {
this.zat.push(5);
Map<String, FastJsonResponse.Field<?, ?>> fieldMappings = t.getFieldMappings();
if (fieldMappings.size() != 1) {
throw new ParseException("Object array response class must have a single Field");
}
FastJsonResponse.Field<?, ?> value = fieldMappings.entrySet().iterator().next().getValue();
t.addConcreteTypeArrayInternal(value, value.zae, zav(bufferedReader, value));
} else if (zai2 == '{') {
this.zat.push(1);
zaz(bufferedReader, t);
} else {
StringBuilder sb = new StringBuilder(19);
sb.append("Unexpected token: ");
sb.append(zai2);
throw new ParseException(sb.toString());
}
zaw(0);
try {
bufferedReader.close();
return;
} catch (IOException unused) {
return;
}
}
throw new ParseException("No data to parse");
} catch (IOException e) {
throw new ParseException(e);
}
} catch (Throwable th) {
try {
bufferedReader.close();
} catch (IOException unused2) {
}
throw th;
}
}
}