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

124 lines
3.3 KiB
Java

package org.codehaus.jackson.io;
import java.io.IOException;
import java.io.InputStream;
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
/* loaded from: classes11.dex */
public final class MergedStream extends InputStream {
byte[] _buffer;
protected final IOContext _context;
final int _end;
final InputStream _in;
int _ptr;
public MergedStream(IOContext iOContext, InputStream inputStream, byte[] bArr, int i, int i2) {
this._context = iOContext;
this._in = inputStream;
this._buffer = bArr;
this._ptr = i;
this._end = i2;
}
private void freeMergedBuffer() {
byte[] bArr = this._buffer;
if (bArr != null) {
this._buffer = null;
IOContext iOContext = this._context;
if (iOContext != null) {
iOContext.releaseReadIOBuffer(bArr);
}
}
}
@Override // java.io.InputStream
public int available() throws IOException {
return this._buffer != null ? this._end - this._ptr : this._in.available();
}
@Override // java.io.InputStream, java.io.Closeable, java.lang.AutoCloseable
public void close() throws IOException {
freeMergedBuffer();
this._in.close();
}
@Override // java.io.InputStream
public void mark(int i) {
if (this._buffer == null) {
this._in.mark(i);
}
}
@Override // java.io.InputStream
public boolean markSupported() {
return this._buffer == null && this._in.markSupported();
}
@Override // java.io.InputStream
public int read(byte[] bArr, int i, int i2) throws IOException {
byte[] bArr2 = this._buffer;
if (bArr2 == null) {
return this._in.read(bArr, i, i2);
}
int i3 = this._end;
int i4 = this._ptr;
int i5 = i3 - i4;
if (i2 > i5) {
i2 = i5;
}
System.arraycopy(bArr2, i4, bArr, i, i2);
int i6 = this._ptr + i2;
this._ptr = i6;
if (i6 >= this._end) {
freeMergedBuffer();
}
return i2;
}
@Override // java.io.InputStream
public void reset() throws IOException {
if (this._buffer == null) {
this._in.reset();
}
}
@Override // java.io.InputStream
public long skip(long j) throws IOException {
long j2;
if (this._buffer != null) {
int i = this._end;
int i2 = this._ptr;
j2 = i - i2;
if (j2 > j) {
this._ptr = i2 + ((int) j);
return j;
}
freeMergedBuffer();
j -= j2;
} else {
j2 = 0;
}
return j > 0 ? this._in.skip(j) + j2 : j2;
}
@Override // java.io.InputStream
public int read(byte[] bArr) throws IOException {
return read(bArr, 0, bArr.length);
}
@Override // java.io.InputStream
public int read() throws IOException {
byte[] bArr = this._buffer;
if (bArr != null) {
int i = this._ptr;
int i2 = i + 1;
this._ptr = i2;
int i3 = bArr[i] & 255;
if (i2 >= this._end) {
freeMergedBuffer();
}
return i3;
}
return this._in.read();
}
}