alexandroid/decompiled/jadx/sources/org/codehaus/jackson/util/VersionUtil.java
KaKi87 a47fad5135 📦 Add decompiled Alexa 2.2.730155.0 (jadx, apktool, Hermes strings)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-07 00:04:16 +01:00

70 lines
2.4 KiB
Java

package org.codehaus.jackson.util;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.regex.Pattern;
import org.codehaus.jackson.Version;
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
/* loaded from: classes11.dex */
public class VersionUtil {
public static final String VERSION_FILE = "VERSION.txt";
private static final Pattern VERSION_SEPARATOR = Pattern.compile("[-_./;:]");
public static Version parseVersion(String str) {
if (str == null) {
return null;
}
String trim = str.trim();
if (trim.length() == 0) {
return null;
}
String[] split = VERSION_SEPARATOR.split(trim);
if (split.length < 2) {
return null;
}
return new Version(parseVersionPart(split[0]), parseVersionPart(split[1]), split.length > 2 ? parseVersionPart(split[2]) : 0, split.length > 3 ? split[3] : null);
}
public static int parseVersionPart(String str) {
String str2 = str.toString();
int length = str2.length();
int i = 0;
for (int i2 = 0; i2 < length; i2++) {
char charAt = str2.charAt(i2);
if (charAt > '9' || charAt < '0') {
break;
}
i = (i * 10) + (charAt - '0');
}
return i;
}
public static Version versionFor(Class<?> cls) {
Version version = null;
try {
InputStream resourceAsStream = cls.getResourceAsStream(VERSION_FILE);
if (resourceAsStream != null) {
try {
version = parseVersion(new BufferedReader(new InputStreamReader(resourceAsStream, "UTF-8")).readLine());
try {
resourceAsStream.close();
} catch (IOException e) {
throw new RuntimeException(e);
}
} catch (Throwable th) {
try {
resourceAsStream.close();
throw th;
} catch (IOException e2) {
throw new RuntimeException(e2);
}
}
}
} catch (IOException unused) {
}
return version == null ? Version.unknownVersion() : version;
}
}