alexandroid/decompiled/jadx/sources/org/codehaus/jackson/impl/JsonParserBase.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

618 lines
24 KiB
Java

package org.codehaus.jackson.impl;
import androidx.core.os.ParcelCompat$$ExternalSyntheticOutline0;
import com.amazon.alexa.ra.core.ui.markdown.parser.formatter.MarkdownConstants;
import defpackage.a$$ExternalSyntheticOutline0;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.BigInteger;
import org.codehaus.jackson.Base64Variant;
import org.codehaus.jackson.JsonLocation;
import org.codehaus.jackson.JsonParseException;
import org.codehaus.jackson.JsonParser;
import org.codehaus.jackson.JsonToken;
import org.codehaus.jackson.Version;
import org.codehaus.jackson.io.IOContext;
import org.codehaus.jackson.io.NumberInput;
import org.codehaus.jackson.util.ByteArrayBuilder;
import org.codehaus.jackson.util.TextBuffer;
import org.codehaus.jackson.util.VersionUtil;
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
/* loaded from: classes11.dex */
public abstract class JsonParserBase extends JsonParserMinimalBase {
static final BigDecimal BD_MAX_INT;
static final BigDecimal BD_MAX_LONG;
static final BigDecimal BD_MIN_INT;
static final BigDecimal BD_MIN_LONG;
static final BigInteger BI_MAX_INT;
static final BigInteger BI_MAX_LONG;
static final BigInteger BI_MIN_INT;
static final BigInteger BI_MIN_LONG;
protected static final char CHAR_NULL = 0;
protected static final int INT_0 = 48;
protected static final int INT_1 = 49;
protected static final int INT_2 = 50;
protected static final int INT_3 = 51;
protected static final int INT_4 = 52;
protected static final int INT_5 = 53;
protected static final int INT_6 = 54;
protected static final int INT_7 = 55;
protected static final int INT_8 = 56;
protected static final int INT_9 = 57;
protected static final int INT_DECIMAL_POINT = 46;
protected static final int INT_E = 69;
protected static final int INT_MINUS = 45;
protected static final int INT_PLUS = 43;
protected static final int INT_e = 101;
static final double MAX_INT_D = 2.147483647E9d;
static final long MAX_INT_L = 2147483647L;
static final double MAX_LONG_D = 9.223372036854776E18d;
static final double MIN_INT_D = -2.147483648E9d;
static final long MIN_INT_L = -2147483648L;
static final double MIN_LONG_D = -9.223372036854776E18d;
protected static final int NR_BIGDECIMAL = 16;
protected static final int NR_BIGINT = 4;
protected static final int NR_DOUBLE = 8;
protected static final int NR_INT = 1;
protected static final int NR_LONG = 2;
protected static final int NR_UNKNOWN = 0;
protected byte[] _binaryValue;
protected boolean _closed;
protected int _expLength;
protected int _fractLength;
protected int _intLength;
protected final IOContext _ioContext;
protected JsonToken _nextToken;
protected BigDecimal _numberBigDecimal;
protected BigInteger _numberBigInt;
protected double _numberDouble;
protected int _numberInt;
protected long _numberLong;
protected boolean _numberNegative;
protected JsonReadContext _parsingContext;
protected final TextBuffer _textBuffer;
protected int _inputPtr = 0;
protected int _inputEnd = 0;
protected long _currInputProcessed = 0;
protected int _currInputRow = 1;
protected int _currInputRowStart = 0;
protected long _tokenInputTotal = 0;
protected int _tokenInputRow = 1;
protected int _tokenInputCol = 0;
protected char[] _nameCopyBuffer = null;
protected boolean _nameCopied = false;
protected ByteArrayBuilder _byteArrayBuilder = null;
protected int _numTypesValid = 0;
static {
BigInteger valueOf = BigInteger.valueOf(-2147483648L);
BI_MIN_INT = valueOf;
BigInteger valueOf2 = BigInteger.valueOf(2147483647L);
BI_MAX_INT = valueOf2;
BigInteger valueOf3 = BigInteger.valueOf(Long.MIN_VALUE);
BI_MIN_LONG = valueOf3;
BigInteger valueOf4 = BigInteger.valueOf(Long.MAX_VALUE);
BI_MAX_LONG = valueOf4;
BD_MIN_LONG = new BigDecimal(valueOf3);
BD_MAX_LONG = new BigDecimal(valueOf4);
BD_MIN_INT = new BigDecimal(valueOf);
BD_MAX_INT = new BigDecimal(valueOf2);
}
public JsonParserBase(IOContext iOContext, int i) {
this._features = i;
this._ioContext = iOContext;
this._textBuffer = iOContext.constructTextBuffer();
this._parsingContext = JsonReadContext.createRootContext();
}
private final void _parseSlowFloatValue(int i) throws IOException, JsonParseException {
TextBuffer textBuffer = this._textBuffer;
try {
if (i == 16) {
this._numberBigDecimal = textBuffer.contentsAsDecimal();
this._numTypesValid = 16;
} else {
this._numberDouble = textBuffer.contentsAsDouble();
this._numTypesValid = 8;
}
} catch (NumberFormatException e) {
_wrapError("Malformed numeric value '" + this._textBuffer.contentsAsString() + "'", e);
}
}
private final void _parseSlowIntValue(int i, char[] cArr, int i2, int i3) throws IOException, JsonParseException {
String contentsAsString = this._textBuffer.contentsAsString();
try {
if (NumberInput.inLongRange(cArr, i2, i3, this._numberNegative)) {
this._numberLong = Long.parseLong(contentsAsString);
this._numTypesValid = 2;
} else {
this._numberBigInt = new BigInteger(contentsAsString);
this._numTypesValid = 4;
}
} catch (NumberFormatException e) {
_wrapError("Malformed numeric value '" + contentsAsString + "'", e);
}
}
public abstract void _closeInput() throws IOException;
public final int _decodeBase64Escape(Base64Variant base64Variant, int i, int i2) throws IOException, JsonParseException {
if (i != 92) {
throw reportInvalidBase64Char(base64Variant, i, i2);
}
char _decodeEscaped = _decodeEscaped();
if (_decodeEscaped <= ' ' && i2 == 0) {
return -1;
}
int decodeBase64Char = base64Variant.decodeBase64Char((int) _decodeEscaped);
if (decodeBase64Char >= 0) {
return decodeBase64Char;
}
throw reportInvalidBase64Char(base64Variant, _decodeEscaped, i2);
}
public char _decodeEscaped() throws IOException, JsonParseException {
throw new UnsupportedOperationException();
}
public abstract void _finishString() throws IOException, JsonParseException;
public ByteArrayBuilder _getByteArrayBuilder() {
ByteArrayBuilder byteArrayBuilder = this._byteArrayBuilder;
if (byteArrayBuilder == null) {
this._byteArrayBuilder = new ByteArrayBuilder();
} else {
byteArrayBuilder.reset();
}
return this._byteArrayBuilder;
}
@Override // org.codehaus.jackson.impl.JsonParserMinimalBase
public void _handleEOF() throws JsonParseException {
if (this._parsingContext.inRoot()) {
return;
}
_reportInvalidEOF(": expected close marker for " + this._parsingContext.getTypeDesc() + " (from " + this._parsingContext.getStartLocation(this._ioContext.getSourceReference()) + MarkdownConstants.RIGHT_PARENTHESIS);
}
public void _parseNumericValue(int i) throws IOException, JsonParseException {
JsonToken jsonToken = this._currToken;
if (jsonToken != JsonToken.VALUE_NUMBER_INT) {
if (jsonToken == JsonToken.VALUE_NUMBER_FLOAT) {
_parseSlowFloatValue(i);
return;
}
_reportError("Current token (" + this._currToken + ") not numeric, can not use numeric value accessors");
return;
}
char[] textBuffer = this._textBuffer.getTextBuffer();
int textOffset = this._textBuffer.getTextOffset();
int i2 = this._intLength;
if (this._numberNegative) {
textOffset++;
}
if (i2 <= 9) {
int parseInt = NumberInput.parseInt(textBuffer, textOffset, i2);
if (this._numberNegative) {
parseInt = -parseInt;
}
this._numberInt = parseInt;
this._numTypesValid = 1;
return;
}
if (i2 > 18) {
_parseSlowIntValue(i, textBuffer, textOffset, i2);
return;
}
long parseLong = NumberInput.parseLong(textBuffer, textOffset, i2);
boolean z = this._numberNegative;
if (z) {
parseLong = -parseLong;
}
if (i2 == 10) {
if (z) {
if (parseLong >= -2147483648L) {
this._numberInt = (int) parseLong;
this._numTypesValid = 1;
return;
}
} else if (parseLong <= 2147483647L) {
this._numberInt = (int) parseLong;
this._numTypesValid = 1;
return;
}
}
this._numberLong = parseLong;
this._numTypesValid = 2;
}
public void _releaseBuffers() throws IOException {
this._textBuffer.releaseBuffers();
char[] cArr = this._nameCopyBuffer;
if (cArr != null) {
this._nameCopyBuffer = null;
this._ioContext.releaseNameCopyBuffer(cArr);
}
}
public void _reportMismatchedEndMarker(int i, char c) throws JsonParseException {
_reportError("Unexpected close marker '" + ((char) i) + "': expected '" + c + "' (for " + this._parsingContext.getTypeDesc() + " starting at " + ("" + this._parsingContext.getStartLocation(this._ioContext.getSourceReference())) + MarkdownConstants.RIGHT_PARENTHESIS);
}
@Override // org.codehaus.jackson.impl.JsonParserMinimalBase, org.codehaus.jackson.JsonParser, java.io.Closeable, java.lang.AutoCloseable
public void close() throws IOException {
if (this._closed) {
return;
}
this._closed = true;
try {
_closeInput();
} finally {
_releaseBuffers();
}
}
public void convertNumberToBigDecimal() throws IOException, JsonParseException {
int i = this._numTypesValid;
if ((i & 8) != 0) {
this._numberBigDecimal = new BigDecimal(getText());
} else if ((i & 4) != 0) {
this._numberBigDecimal = new BigDecimal(this._numberBigInt);
} else if ((i & 2) != 0) {
this._numberBigDecimal = BigDecimal.valueOf(this._numberLong);
} else if ((i & 1) != 0) {
this._numberBigDecimal = BigDecimal.valueOf(this._numberInt);
} else {
_throwInternal();
}
this._numTypesValid |= 16;
}
public void convertNumberToBigInteger() throws IOException, JsonParseException {
int i = this._numTypesValid;
if ((i & 16) != 0) {
this._numberBigInt = this._numberBigDecimal.toBigInteger();
} else if ((i & 2) != 0) {
this._numberBigInt = BigInteger.valueOf(this._numberLong);
} else if ((i & 1) != 0) {
this._numberBigInt = BigInteger.valueOf(this._numberInt);
} else if ((i & 8) != 0) {
this._numberBigInt = BigDecimal.valueOf(this._numberDouble).toBigInteger();
} else {
_throwInternal();
}
this._numTypesValid |= 4;
}
public void convertNumberToDouble() throws IOException, JsonParseException {
int i = this._numTypesValid;
if ((i & 16) != 0) {
this._numberDouble = this._numberBigDecimal.doubleValue();
} else if ((i & 4) != 0) {
this._numberDouble = this._numberBigInt.doubleValue();
} else if ((i & 2) != 0) {
this._numberDouble = this._numberLong;
} else if ((i & 1) != 0) {
this._numberDouble = this._numberInt;
} else {
_throwInternal();
}
this._numTypesValid |= 8;
}
public void convertNumberToInt() throws IOException, JsonParseException {
int i = this._numTypesValid;
if ((i & 2) != 0) {
long j = this._numberLong;
int i2 = (int) j;
if (i2 != j) {
_reportError("Numeric value (" + getText() + ") out of range of int");
}
this._numberInt = i2;
} else if ((i & 4) != 0) {
if (BI_MIN_INT.compareTo(this._numberBigInt) > 0 || BI_MAX_INT.compareTo(this._numberBigInt) < 0) {
reportOverflowInt();
}
this._numberInt = this._numberBigInt.intValue();
} else if ((i & 8) != 0) {
double d = this._numberDouble;
if (d < MIN_INT_D || d > MAX_INT_D) {
reportOverflowInt();
}
this._numberInt = (int) this._numberDouble;
} else if ((i & 16) != 0) {
if (BD_MIN_INT.compareTo(this._numberBigDecimal) > 0 || BD_MAX_INT.compareTo(this._numberBigDecimal) < 0) {
reportOverflowInt();
}
this._numberInt = this._numberBigDecimal.intValue();
} else {
_throwInternal();
}
this._numTypesValid |= 1;
}
public void convertNumberToLong() throws IOException, JsonParseException {
int i = this._numTypesValid;
if ((i & 1) != 0) {
this._numberLong = this._numberInt;
} else if ((i & 4) != 0) {
if (BI_MIN_LONG.compareTo(this._numberBigInt) > 0 || BI_MAX_LONG.compareTo(this._numberBigInt) < 0) {
reportOverflowLong();
}
this._numberLong = this._numberBigInt.longValue();
} else if ((i & 8) != 0) {
double d = this._numberDouble;
if (d < MIN_LONG_D || d > MAX_LONG_D) {
reportOverflowLong();
}
this._numberLong = (long) this._numberDouble;
} else if ((i & 16) != 0) {
if (BD_MIN_LONG.compareTo(this._numberBigDecimal) > 0 || BD_MAX_LONG.compareTo(this._numberBigDecimal) < 0) {
reportOverflowLong();
}
this._numberLong = this._numberBigDecimal.longValue();
} else {
_throwInternal();
}
this._numTypesValid |= 2;
}
@Override // org.codehaus.jackson.JsonParser
public BigInteger getBigIntegerValue() throws IOException, JsonParseException {
int i = this._numTypesValid;
if ((i & 4) == 0) {
if (i == 0) {
_parseNumericValue(4);
}
if ((this._numTypesValid & 4) == 0) {
convertNumberToBigInteger();
}
}
return this._numberBigInt;
}
@Override // org.codehaus.jackson.JsonParser
public JsonLocation getCurrentLocation() {
return new JsonLocation(this._ioContext.getSourceReference(), (this._currInputProcessed + this._inputPtr) - 1, this._currInputRow, (this._inputPtr - this._currInputRowStart) + 1);
}
@Override // org.codehaus.jackson.impl.JsonParserMinimalBase, org.codehaus.jackson.JsonParser
public String getCurrentName() throws IOException, JsonParseException {
JsonToken jsonToken = this._currToken;
return (jsonToken == JsonToken.START_OBJECT || jsonToken == JsonToken.START_ARRAY) ? this._parsingContext.getParent().getCurrentName() : this._parsingContext.getCurrentName();
}
@Override // org.codehaus.jackson.JsonParser
public BigDecimal getDecimalValue() throws IOException, JsonParseException {
int i = this._numTypesValid;
if ((i & 16) == 0) {
if (i == 0) {
_parseNumericValue(16);
}
if ((this._numTypesValid & 16) == 0) {
convertNumberToBigDecimal();
}
}
return this._numberBigDecimal;
}
@Override // org.codehaus.jackson.JsonParser
public double getDoubleValue() throws IOException, JsonParseException {
int i = this._numTypesValid;
if ((i & 8) == 0) {
if (i == 0) {
_parseNumericValue(8);
}
if ((this._numTypesValid & 8) == 0) {
convertNumberToDouble();
}
}
return this._numberDouble;
}
@Override // org.codehaus.jackson.JsonParser
public float getFloatValue() throws IOException, JsonParseException {
return (float) getDoubleValue();
}
@Override // org.codehaus.jackson.JsonParser
public int getIntValue() throws IOException, JsonParseException {
int i = this._numTypesValid;
if ((i & 1) == 0) {
if (i == 0) {
_parseNumericValue(1);
}
if ((this._numTypesValid & 1) == 0) {
convertNumberToInt();
}
}
return this._numberInt;
}
@Override // org.codehaus.jackson.JsonParser
public long getLongValue() throws IOException, JsonParseException {
int i = this._numTypesValid;
if ((i & 2) == 0) {
if (i == 0) {
_parseNumericValue(2);
}
if ((this._numTypesValid & 2) == 0) {
convertNumberToLong();
}
}
return this._numberLong;
}
@Override // org.codehaus.jackson.JsonParser
public JsonParser.NumberType getNumberType() throws IOException, JsonParseException {
if (this._numTypesValid == 0) {
_parseNumericValue(0);
}
JsonToken jsonToken = this._currToken;
JsonToken jsonToken2 = JsonToken.VALUE_NUMBER_INT;
int i = this._numTypesValid;
return jsonToken == jsonToken2 ? (i & 1) != 0 ? JsonParser.NumberType.INT : (i & 2) != 0 ? JsonParser.NumberType.LONG : JsonParser.NumberType.BIG_INTEGER : (i & 16) != 0 ? JsonParser.NumberType.BIG_DECIMAL : JsonParser.NumberType.DOUBLE;
}
@Override // org.codehaus.jackson.JsonParser
public Number getNumberValue() throws IOException, JsonParseException {
if (this._numTypesValid == 0) {
_parseNumericValue(0);
}
JsonToken jsonToken = this._currToken;
JsonToken jsonToken2 = JsonToken.VALUE_NUMBER_INT;
int i = this._numTypesValid;
if (jsonToken == jsonToken2) {
return (i & 1) != 0 ? Integer.valueOf(this._numberInt) : (i & 2) != 0 ? Long.valueOf(this._numberLong) : (i & 4) != 0 ? this._numberBigInt : this._numberBigDecimal;
}
if ((i & 16) != 0) {
return this._numberBigDecimal;
}
if ((i & 8) == 0) {
_throwInternal();
}
return Double.valueOf(this._numberDouble);
}
public final long getTokenCharacterOffset() {
return this._tokenInputTotal;
}
public final int getTokenColumnNr() {
int i = this._tokenInputCol;
return i < 0 ? i : i + 1;
}
public final int getTokenLineNr() {
return this._tokenInputRow;
}
@Override // org.codehaus.jackson.JsonParser
public JsonLocation getTokenLocation() {
return new JsonLocation(this._ioContext.getSourceReference(), getTokenCharacterOffset(), getTokenLineNr(), getTokenColumnNr());
}
@Override // org.codehaus.jackson.impl.JsonParserMinimalBase, org.codehaus.jackson.JsonParser
public boolean hasTextCharacters() {
JsonToken jsonToken = this._currToken;
if (jsonToken == JsonToken.VALUE_STRING) {
return true;
}
if (jsonToken == JsonToken.FIELD_NAME) {
return this._nameCopied;
}
return false;
}
@Override // org.codehaus.jackson.impl.JsonParserMinimalBase, org.codehaus.jackson.JsonParser
public boolean isClosed() {
return this._closed;
}
public abstract boolean loadMore() throws IOException;
public final void loadMoreGuaranteed() throws IOException {
if (loadMore()) {
return;
}
_reportInvalidEOF();
}
public IllegalArgumentException reportInvalidBase64Char(Base64Variant base64Variant, int i, int i2, String str) throws IllegalArgumentException {
String m;
if (i <= 32) {
m = "Illegal white space character (code 0x" + Integer.toHexString(i) + ") as character #" + (i2 + 1) + " of 4-char base64 unit: can only used between units";
} else if (base64Variant.usesPaddingChar(i)) {
m = "Unexpected padding character ('" + base64Variant.getPaddingChar() + "') as character #" + (i2 + 1) + " of 4-char base64 unit: padding only legal as 3rd or 4th character";
} else if (!Character.isDefined(i) || Character.isISOControl(i)) {
m = ParcelCompat$$ExternalSyntheticOutline0.m(") in base64 content", i, new StringBuilder("Illegal character (code 0x"));
} else {
m = "Illegal character '" + ((char) i) + "' (code 0x" + Integer.toHexString(i) + ") in base64 content";
}
if (str != null) {
m = a$$ExternalSyntheticOutline0.m$1(m, ": ", str);
}
return new IllegalArgumentException(m);
}
public void reportInvalidNumber(String str) throws JsonParseException {
_reportError("Invalid numeric value: " + str);
}
public void reportOverflowInt() throws IOException, JsonParseException {
_reportError("Numeric value (" + getText() + ") out of range of int (-2147483648 - 2147483647)");
}
public void reportOverflowLong() throws IOException, JsonParseException {
_reportError("Numeric value (" + getText() + ") out of range of long (-9223372036854775808 - 9223372036854775807)");
}
public void reportUnexpectedNumberChar(int i, String str) throws JsonParseException {
String str2 = "Unexpected character (" + JsonParserMinimalBase._getCharDesc(i) + ") in numeric value";
if (str != null) {
str2 = a$$ExternalSyntheticOutline0.m$1(str2, ": ", str);
}
_reportError(str2);
}
public final JsonToken reset(boolean z, int i, int i2, int i3) {
return (i2 >= 1 || i3 >= 1) ? resetFloat(z, i, i2, i3) : resetInt(z, i);
}
public final JsonToken resetAsNaN(String str, double d) {
this._textBuffer.resetWithString(str);
this._numberDouble = d;
this._numTypesValid = 8;
return JsonToken.VALUE_NUMBER_FLOAT;
}
public final JsonToken resetFloat(boolean z, int i, int i2, int i3) {
this._numberNegative = z;
this._intLength = i;
this._fractLength = i2;
this._expLength = i3;
this._numTypesValid = 0;
return JsonToken.VALUE_NUMBER_FLOAT;
}
public final JsonToken resetInt(boolean z, int i) {
this._numberNegative = z;
this._intLength = i;
this._fractLength = 0;
this._expLength = 0;
this._numTypesValid = 0;
return JsonToken.VALUE_NUMBER_INT;
}
@Override // org.codehaus.jackson.JsonParser, org.codehaus.jackson.Versioned
public Version version() {
return VersionUtil.versionFor(getClass());
}
@Override // org.codehaus.jackson.impl.JsonParserMinimalBase, org.codehaus.jackson.JsonParser
public JsonReadContext getParsingContext() {
return this._parsingContext;
}
public final int _decodeBase64Escape(Base64Variant base64Variant, char c, int i) throws IOException, JsonParseException {
if (c == '\\') {
char _decodeEscaped = _decodeEscaped();
if (_decodeEscaped <= ' ' && i == 0) {
return -1;
}
int decodeBase64Char = base64Variant.decodeBase64Char(_decodeEscaped);
if (decodeBase64Char >= 0) {
return decodeBase64Char;
}
throw reportInvalidBase64Char(base64Variant, _decodeEscaped, i);
}
throw reportInvalidBase64Char(base64Variant, c, i);
}
public IllegalArgumentException reportInvalidBase64Char(Base64Variant base64Variant, int i, int i2) throws IllegalArgumentException {
return reportInvalidBase64Char(base64Variant, i, i2, null);
}
}