what-the-bank/sources/o/OmK.java

107 lines
3.8 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package o;
import com.google.common.base.Preconditions;
import com.huawei.hms.framework.common.ContainerUtils;
import java.util.Locale;
import java.util.Map;
import java.util.SortedMap;
import java.util.TreeMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/* loaded from: classes2.dex */
public final class OmK {
private String a;
private final SortedMap<String, String> f = new TreeMap();
private String h;
private String i;
private static final Pattern c = Pattern.compile("[\\w!#$&.+\\-\\^_]+|[*]");
private static final Pattern d = Pattern.compile("[\\p{ASCII}&&[^\\p{Cntrl} ;/=\\[\\]\\(\\)\\<\\>\\@\\,\\:\\\"\\?\\=]]+");
private static final Pattern e = Pattern.compile("\\s*([^\\s/=;\"]+)/([^\\s/=;\"]+)\\s*(;.*)?", 32);
private static final Pattern b = Pattern.compile("\\s*;\\s*([^\\s/=;\"]+)=(\"([^\"]*)\"|[^\\s;\"]*)");
public OmK(String str) {
this.i = "application";
this.h = "octet-stream";
Matcher matcher = e.matcher(str);
Preconditions.checkArgument(matcher.matches(), "Type must be in the 'maintype/subtype; parameter=value' format");
String group = matcher.group(1);
Pattern pattern = c;
Preconditions.checkArgument(pattern.matcher(group).matches(), "Type contains reserved characters");
this.i = group;
this.a = null;
String group2 = matcher.group(2);
Preconditions.checkArgument(pattern.matcher(group2).matches(), "Subtype contains reserved characters");
this.h = group2;
this.a = null;
String group3 = matcher.group(3);
if (group3 != null) {
Matcher matcher2 = b.matcher(group3);
while (matcher2.find()) {
String group4 = matcher2.group(1);
String group5 = matcher2.group(3);
if (group5 == null) {
group5 = matcher2.group(2);
}
b(group4, group5);
}
}
}
public final OmK b(String str, String str2) {
if (str2 == null) {
this.a = null;
this.f.remove(str.toLowerCase(Locale.US));
return this;
}
Preconditions.checkArgument(d.matcher(str).matches(), "Name contains reserved characters");
this.a = null;
this.f.put(str.toLowerCase(Locale.US), str2);
return this;
}
private String b() {
String str = this.a;
if (str != null) {
return str;
}
StringBuilder sb = new StringBuilder();
sb.append(this.i);
sb.append('/');
sb.append(this.h);
SortedMap<String, String> sortedMap = this.f;
if (sortedMap != null) {
for (Map.Entry<String, String> entry : sortedMap.entrySet()) {
String value = entry.getValue();
sb.append("; ");
sb.append(entry.getKey());
sb.append(ContainerUtils.KEY_VALUE_DELIMITER);
if (!d.matcher(value).matches()) {
String replace = value.replace("\\", "\\\\").replace("\"", "\\\"");
StringBuilder sb2 = new StringBuilder("\"");
sb2.append(replace);
sb2.append("\"");
value = sb2.toString();
}
sb.append(value);
}
}
String obj = sb.toString();
this.a = obj;
return obj;
}
public final String toString() {
return b();
}
public final int hashCode() {
return b().hashCode();
}
public final boolean equals(Object obj) {
OmK omK;
return (obj instanceof OmK) && (omK = (OmK) obj) != null && this.i.equalsIgnoreCase(omK.i) && this.h.equalsIgnoreCase(omK.h) && this.f.equals(omK.f);
}
}