172 lines
6.9 KiB
Java
172 lines
6.9 KiB
Java
package com.google.android.gms.internal.firebase_ml;
|
|
|
|
import com.huawei.hms.framework.common.ContainerUtils;
|
|
import java.util.HashMap;
|
|
import java.util.Iterator;
|
|
import java.util.LinkedHashMap;
|
|
import java.util.ListIterator;
|
|
import java.util.Map;
|
|
|
|
/* loaded from: classes2.dex */
|
|
public final class zzfr {
|
|
static final Map<Character, zzfs> zzvi = new HashMap();
|
|
|
|
private static Map<String, Object> zzb(Object obj) {
|
|
LinkedHashMap linkedHashMap = new LinkedHashMap();
|
|
for (Map.Entry<String, Object> entry : zzhf.zzf(obj).entrySet()) {
|
|
Object value = entry.getValue();
|
|
if (value != null && !zzhf.isNull(value)) {
|
|
linkedHashMap.put(entry.getKey(), value);
|
|
}
|
|
}
|
|
return linkedHashMap;
|
|
}
|
|
|
|
public static String zza(String str, String str2, Object obj, boolean z) {
|
|
Object zza;
|
|
String str3;
|
|
if (str2.startsWith("/")) {
|
|
zzez zzezVar = new zzez(str);
|
|
zzezVar.zzv(null);
|
|
String valueOf = String.valueOf(zzezVar.zzew());
|
|
String valueOf2 = String.valueOf(str2);
|
|
str2 = valueOf2.length() != 0 ? valueOf.concat(valueOf2) : new String(valueOf);
|
|
} else if (!str2.startsWith("http://") && !str2.startsWith("https://")) {
|
|
String valueOf3 = String.valueOf(str);
|
|
String valueOf4 = String.valueOf(str2);
|
|
str2 = valueOf4.length() != 0 ? valueOf3.concat(valueOf4) : new String(valueOf3);
|
|
}
|
|
Map<String, Object> zzb = zzb(obj);
|
|
StringBuilder sb = new StringBuilder();
|
|
int length = str2.length();
|
|
int i = 0;
|
|
while (true) {
|
|
if (i >= length) {
|
|
break;
|
|
}
|
|
int indexOf = str2.indexOf(123, i);
|
|
if (indexOf == -1) {
|
|
sb.append(str2.substring(i));
|
|
break;
|
|
}
|
|
sb.append(str2.substring(i, indexOf));
|
|
int indexOf2 = str2.indexOf(125, indexOf + 2);
|
|
String substring = str2.substring(indexOf + 1, indexOf2);
|
|
zzfs zzfsVar = zzvi.get(Character.valueOf(substring.charAt(0)));
|
|
if (zzfsVar == null) {
|
|
zzfsVar = zzfs.SIMPLE;
|
|
}
|
|
ListIterator<String> listIterator = zzku.zza(zzkc.zza(',')).zza(substring).listIterator();
|
|
boolean z2 = true;
|
|
while (listIterator.hasNext()) {
|
|
String next = listIterator.next();
|
|
boolean endsWith = next.endsWith("*");
|
|
int zzfu = listIterator.nextIndex() == 1 ? zzfsVar.zzfu() : 0;
|
|
int length2 = next.length();
|
|
if (endsWith) {
|
|
length2--;
|
|
}
|
|
String substring2 = next.substring(zzfu, length2);
|
|
Object remove = zzb.remove(substring2);
|
|
if (remove != null) {
|
|
if (!z2) {
|
|
sb.append(zzfsVar.zzfs());
|
|
} else {
|
|
sb.append(zzfsVar.zzfr());
|
|
z2 = false;
|
|
}
|
|
if (remove instanceof Iterator) {
|
|
zza = zza(substring2, (Iterator<?>) remove, endsWith, zzfsVar);
|
|
} else if ((remove instanceof Iterable) || remove.getClass().isArray()) {
|
|
zza = zza(substring2, (Iterator<?>) zzia.zzi(remove).iterator(), endsWith, zzfsVar);
|
|
} else if (remove.getClass().isEnum()) {
|
|
if (zzhl.zza((Enum<?>) remove).getName() != null) {
|
|
if (zzfsVar.zzft()) {
|
|
remove = String.format("%s=%s", substring2, remove);
|
|
}
|
|
remove = zzie.zzas(remove.toString());
|
|
}
|
|
zza = remove;
|
|
} else if (!zzhf.zzg(remove)) {
|
|
Map<String, Object> zzb2 = zzb(remove);
|
|
if (zzb2.isEmpty()) {
|
|
zza = "";
|
|
} else {
|
|
StringBuilder sb2 = new StringBuilder();
|
|
String str4 = ContainerUtils.KEY_VALUE_DELIMITER;
|
|
if (endsWith) {
|
|
str3 = zzfsVar.zzfs();
|
|
} else {
|
|
if (zzfsVar.zzft()) {
|
|
sb2.append(zzie.zzas(substring2));
|
|
sb2.append(ContainerUtils.KEY_VALUE_DELIMITER);
|
|
}
|
|
str4 = ",";
|
|
str3 = ",";
|
|
}
|
|
Iterator<Map.Entry<String, Object>> it = zzb2.entrySet().iterator();
|
|
while (it.hasNext()) {
|
|
Map.Entry<String, Object> next2 = it.next();
|
|
String zzak = zzfsVar.zzak(next2.getKey());
|
|
String zzak2 = zzfsVar.zzak(next2.getValue().toString());
|
|
sb2.append(zzak);
|
|
sb2.append(str4);
|
|
sb2.append(zzak2);
|
|
if (it.hasNext()) {
|
|
sb2.append(str3);
|
|
}
|
|
}
|
|
zza = sb2.toString();
|
|
}
|
|
} else {
|
|
if (zzfsVar.zzft()) {
|
|
remove = String.format("%s=%s", substring2, remove);
|
|
}
|
|
if (zzfsVar.zzfv()) {
|
|
zza = zzie.zzat(remove.toString());
|
|
} else {
|
|
zza = zzie.zzas(remove.toString());
|
|
}
|
|
}
|
|
sb.append(zza);
|
|
}
|
|
}
|
|
i = indexOf2 + 1;
|
|
}
|
|
zzez.zza(zzb.entrySet(), sb);
|
|
return sb.toString();
|
|
}
|
|
|
|
private static String zza(String str, Iterator<?> it, boolean z, zzfs zzfsVar) {
|
|
String str2;
|
|
if (!it.hasNext()) {
|
|
return "";
|
|
}
|
|
StringBuilder sb = new StringBuilder();
|
|
if (z) {
|
|
str2 = zzfsVar.zzfs();
|
|
} else {
|
|
if (zzfsVar.zzft()) {
|
|
sb.append(zzie.zzas(str));
|
|
sb.append(ContainerUtils.KEY_VALUE_DELIMITER);
|
|
}
|
|
str2 = ",";
|
|
}
|
|
while (it.hasNext()) {
|
|
if (z && zzfsVar.zzft()) {
|
|
sb.append(zzie.zzas(str));
|
|
sb.append(ContainerUtils.KEY_VALUE_DELIMITER);
|
|
}
|
|
sb.append(zzfsVar.zzak(it.next().toString()));
|
|
if (it.hasNext()) {
|
|
sb.append(str2);
|
|
}
|
|
}
|
|
return sb.toString();
|
|
}
|
|
|
|
static {
|
|
zzfs.values();
|
|
}
|
|
}
|