105 lines
3.6 KiB
Java
105 lines
3.6 KiB
Java
package com.facetec.sdk;
|
|
|
|
import java.nio.charset.Charset;
|
|
import java.util.Locale;
|
|
import java.util.regex.Matcher;
|
|
import java.util.regex.Pattern;
|
|
|
|
/* loaded from: classes.dex */
|
|
public final class jz {
|
|
private static final Pattern c = Pattern.compile("([a-zA-Z0-9-!#$%&'*+.^_`{|}~]+)/([a-zA-Z0-9-!#$%&'*+.^_`{|}~]+)");
|
|
private static final Pattern d = Pattern.compile(";\\s*(?:([a-zA-Z0-9-!#$%&'*+.^_`{|}~]+)=(?:([a-zA-Z0-9-!#$%&'*+.^_`{|}~]+)|\"([^\"]*)\"))?");
|
|
private final String a;
|
|
private final String b;
|
|
private final String e;
|
|
private final String f;
|
|
|
|
private jz(String str, String str2, String str3, String str4) {
|
|
this.e = str;
|
|
this.b = str2;
|
|
this.a = str3;
|
|
this.f = str4;
|
|
}
|
|
|
|
public static jz d(String str) {
|
|
Matcher matcher = c.matcher(str);
|
|
if (!matcher.lookingAt()) {
|
|
StringBuilder sb = new StringBuilder("No subtype found for: \"");
|
|
sb.append(str);
|
|
sb.append('\"');
|
|
throw new IllegalArgumentException(sb.toString());
|
|
}
|
|
String lowerCase = matcher.group(1).toLowerCase(Locale.US);
|
|
String lowerCase2 = matcher.group(2).toLowerCase(Locale.US);
|
|
Matcher matcher2 = d.matcher(str);
|
|
String str2 = null;
|
|
for (int end = matcher.end(); end < str.length(); end = matcher2.end()) {
|
|
matcher2.region(end, str.length());
|
|
if (!matcher2.lookingAt()) {
|
|
StringBuilder sb2 = new StringBuilder("Parameter is not formatted correctly: \"");
|
|
sb2.append(str.substring(end));
|
|
sb2.append("\" for: \"");
|
|
sb2.append(str);
|
|
sb2.append('\"');
|
|
throw new IllegalArgumentException(sb2.toString());
|
|
}
|
|
String group = matcher2.group(1);
|
|
if (group != null && group.equalsIgnoreCase("charset")) {
|
|
String group2 = matcher2.group(2);
|
|
if (group2 != null) {
|
|
if (group2.startsWith("'") && group2.endsWith("'") && group2.length() > 2) {
|
|
group2 = group2.substring(1, group2.length() - 1);
|
|
}
|
|
} else {
|
|
group2 = matcher2.group(3);
|
|
}
|
|
if (str2 != null && !group2.equalsIgnoreCase(str2)) {
|
|
StringBuilder sb3 = new StringBuilder("Multiple charsets defined: \"");
|
|
sb3.append(str2);
|
|
sb3.append("\" and: \"");
|
|
sb3.append(group2);
|
|
sb3.append("\" for: \"");
|
|
sb3.append(str);
|
|
sb3.append('\"');
|
|
throw new IllegalArgumentException(sb3.toString());
|
|
}
|
|
str2 = group2;
|
|
}
|
|
}
|
|
return new jz(str, lowerCase, lowerCase2, str2);
|
|
}
|
|
|
|
public static jz a(String str) {
|
|
try {
|
|
return d(str);
|
|
} catch (IllegalArgumentException unused) {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public final Charset e() {
|
|
return d((Charset) null);
|
|
}
|
|
|
|
public final Charset d(Charset charset) {
|
|
try {
|
|
String str = this.f;
|
|
return str != null ? Charset.forName(str) : charset;
|
|
} catch (IllegalArgumentException unused) {
|
|
return charset;
|
|
}
|
|
}
|
|
|
|
public final boolean equals(Object obj) {
|
|
return (obj instanceof jz) && ((jz) obj).e.equals(this.e);
|
|
}
|
|
|
|
public final int hashCode() {
|
|
return this.e.hashCode();
|
|
}
|
|
|
|
public final String toString() {
|
|
return this.e;
|
|
}
|
|
}
|