mirror of
https://github.com/VibedByKaKi/alexandroid.git
synced 2026-11-28 08:43:22 +01:00
172 lines
4.4 KiB
Java
172 lines
4.4 KiB
Java
package org.apache.http.util;
|
|
|
|
import androidx.biometric.ErrorUtils$$ExternalSyntheticOutline0;
|
|
import defpackage.a$$ExternalSyntheticOutline0;
|
|
import java.io.Serializable;
|
|
import kotlin.text.Regex$$ExternalSyntheticBUOutline0;
|
|
import okio.Utf8;
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
/* loaded from: classes11.dex */
|
|
public final class ByteArrayBuffer implements Serializable {
|
|
private static final long serialVersionUID = 4359112959524048036L;
|
|
private byte[] buffer;
|
|
private int len;
|
|
|
|
public ByteArrayBuffer(int i) {
|
|
Args.notNegative(i, "Buffer capacity");
|
|
this.buffer = new byte[i];
|
|
}
|
|
|
|
private void expand(int i) {
|
|
byte[] bArr = new byte[Math.max(this.buffer.length << 1, i)];
|
|
System.arraycopy(this.buffer, 0, bArr, 0, this.len);
|
|
this.buffer = bArr;
|
|
}
|
|
|
|
public void append(char[] cArr, int i, int i2) {
|
|
int i3;
|
|
if (cArr == null) {
|
|
return;
|
|
}
|
|
if (i < 0 || i > cArr.length || i2 < 0 || (i3 = i + i2) < 0 || i3 > cArr.length) {
|
|
Regex$$ExternalSyntheticBUOutline0.m(cArr.length, ErrorUtils$$ExternalSyntheticOutline0.m29m(i, i2, "off: ", " len: ", " b.length: "));
|
|
return;
|
|
}
|
|
if (i2 == 0) {
|
|
return;
|
|
}
|
|
int i4 = this.len;
|
|
int i5 = i2 + i4;
|
|
if (i5 > this.buffer.length) {
|
|
expand(i5);
|
|
}
|
|
while (i4 < i5) {
|
|
char c = cArr[i];
|
|
if ((c < ' ' || c > '~') && ((c < 160 || c > 255) && c != '\t')) {
|
|
this.buffer[i4] = Utf8.REPLACEMENT_BYTE;
|
|
} else {
|
|
this.buffer[i4] = (byte) c;
|
|
}
|
|
i++;
|
|
i4++;
|
|
}
|
|
this.len = i5;
|
|
}
|
|
|
|
public byte[] buffer() {
|
|
return this.buffer;
|
|
}
|
|
|
|
public int byteAt(int i) {
|
|
return this.buffer[i];
|
|
}
|
|
|
|
public int capacity() {
|
|
return this.buffer.length;
|
|
}
|
|
|
|
public void clear() {
|
|
this.len = 0;
|
|
}
|
|
|
|
public void ensureCapacity(int i) {
|
|
if (i <= 0) {
|
|
return;
|
|
}
|
|
int length = this.buffer.length;
|
|
int i2 = this.len;
|
|
if (i > length - i2) {
|
|
expand(i2 + i);
|
|
}
|
|
}
|
|
|
|
public int indexOf(byte b, int i, int i2) {
|
|
if (i < 0) {
|
|
i = 0;
|
|
}
|
|
int i3 = this.len;
|
|
if (i2 > i3) {
|
|
i2 = i3;
|
|
}
|
|
if (i > i2) {
|
|
return -1;
|
|
}
|
|
while (i < i2) {
|
|
if (this.buffer[i] == b) {
|
|
return i;
|
|
}
|
|
i++;
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
public boolean isEmpty() {
|
|
return this.len == 0;
|
|
}
|
|
|
|
public boolean isFull() {
|
|
return this.len == this.buffer.length;
|
|
}
|
|
|
|
public int length() {
|
|
return this.len;
|
|
}
|
|
|
|
public void setLength(int i) {
|
|
if (i >= 0 && i <= this.buffer.length) {
|
|
this.len = i;
|
|
} else {
|
|
Regex$$ExternalSyntheticBUOutline0.m(this.buffer.length, a$$ExternalSyntheticOutline0.m0m(i, "len: ", " < 0 or > buffer len: "));
|
|
}
|
|
}
|
|
|
|
public byte[] toByteArray() {
|
|
int i = this.len;
|
|
byte[] bArr = new byte[i];
|
|
if (i > 0) {
|
|
System.arraycopy(this.buffer, 0, bArr, 0, i);
|
|
}
|
|
return bArr;
|
|
}
|
|
|
|
public int indexOf(byte b) {
|
|
return indexOf(b, 0, this.len);
|
|
}
|
|
|
|
public void append(int i) {
|
|
int i2 = this.len + 1;
|
|
if (i2 > this.buffer.length) {
|
|
expand(i2);
|
|
}
|
|
this.buffer[this.len] = (byte) i;
|
|
this.len = i2;
|
|
}
|
|
|
|
public void append(byte[] bArr, int i, int i2) {
|
|
int i3;
|
|
if (bArr == null) {
|
|
return;
|
|
}
|
|
if (i < 0 || i > bArr.length || i2 < 0 || (i3 = i + i2) < 0 || i3 > bArr.length) {
|
|
Regex$$ExternalSyntheticBUOutline0.m(bArr.length, ErrorUtils$$ExternalSyntheticOutline0.m29m(i, i2, "off: ", " len: ", " b.length: "));
|
|
return;
|
|
}
|
|
if (i2 == 0) {
|
|
return;
|
|
}
|
|
int i4 = this.len + i2;
|
|
if (i4 > this.buffer.length) {
|
|
expand(i4);
|
|
}
|
|
System.arraycopy(bArr, i, this.buffer, this.len, i2);
|
|
this.len = i4;
|
|
}
|
|
|
|
public void append(CharArrayBuffer charArrayBuffer, int i, int i2) {
|
|
if (charArrayBuffer == null) {
|
|
return;
|
|
}
|
|
append(charArrayBuffer.buffer(), i, i2);
|
|
}
|
|
}
|