mirror of
https://github.com/VibedByKaKi/alexandroid.git
synced 2026-11-13 17:37:16 +01:00
755 lines
27 KiB
Java
755 lines
27 KiB
Java
package com.google.protobuf;
|
|
|
|
import androidx.biometric.ErrorUtils$$ExternalSyntheticOutline0;
|
|
import com.facebook.hermes.intl.Intl$$ExternalSyntheticBUOutline0;
|
|
import com.google.common.base.Verify$$ExternalSyntheticBUOutline0;
|
|
import com.google.gson.Gson$$ExternalSyntheticBUOutline0;
|
|
import defpackage.a$$ExternalSyntheticOutline0;
|
|
import io.ktor.util.PathKt$$ExternalSyntheticBUOutline0;
|
|
import java.io.ByteArrayInputStream;
|
|
import java.io.IOException;
|
|
import java.io.InputStream;
|
|
import java.io.InvalidObjectException;
|
|
import java.io.ObjectInputStream;
|
|
import java.io.OutputStream;
|
|
import java.io.Serializable;
|
|
import java.io.UnsupportedEncodingException;
|
|
import java.nio.ByteBuffer;
|
|
import java.nio.charset.Charset;
|
|
import java.nio.charset.UnsupportedCharsetException;
|
|
import java.util.ArrayList;
|
|
import java.util.Arrays;
|
|
import java.util.Collection;
|
|
import java.util.Collections;
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
import org.json.XML$$ExternalSyntheticBUOutline0;
|
|
import rx.Single$$ExternalSyntheticBUOutline0;
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
/* loaded from: classes8.dex */
|
|
public abstract class ByteString implements Iterable<Byte>, Serializable {
|
|
static final int CONCATENATE_BY_COPY_SIZE = 128;
|
|
public static final ByteString EMPTY = new LiteralByteString(Internal.EMPTY_BYTE_ARRAY);
|
|
static final int MAX_READ_FROM_CHUNK_SIZE = 8192;
|
|
static final int MIN_READ_FROM_CHUNK_SIZE = 256;
|
|
private static final ByteArrayCopier byteArrayCopier;
|
|
private int hash = 0;
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
public static final class ArraysByteArrayCopier implements ByteArrayCopier {
|
|
private ArraysByteArrayCopier() {
|
|
}
|
|
|
|
@Override // com.google.protobuf.ByteString.ByteArrayCopier
|
|
public byte[] copyFrom(byte[] bArr, int i, int i2) {
|
|
return Arrays.copyOfRange(bArr, i, i2 + i);
|
|
}
|
|
}
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
public static final class BoundedByteString extends LiteralByteString {
|
|
private static final long serialVersionUID = 1;
|
|
private final int bytesLength;
|
|
private final int bytesOffset;
|
|
|
|
public BoundedByteString(byte[] bArr, int i, int i2) {
|
|
super(bArr);
|
|
ByteString.checkRange(i, i + i2, bArr.length);
|
|
this.bytesOffset = i;
|
|
this.bytesLength = i2;
|
|
}
|
|
|
|
private void readObject(ObjectInputStream objectInputStream) throws IOException {
|
|
throw new InvalidObjectException("BoundedByteStream instances are not to be serialized directly");
|
|
}
|
|
|
|
@Override // com.google.protobuf.ByteString.LiteralByteString, com.google.protobuf.ByteString
|
|
public byte byteAt(int i) {
|
|
ByteString.checkIndex(i, size());
|
|
return this.bytes[this.bytesOffset + i];
|
|
}
|
|
|
|
@Override // com.google.protobuf.ByteString.LiteralByteString, com.google.protobuf.ByteString
|
|
public void copyToInternal(byte[] bArr, int i, int i2, int i3) {
|
|
System.arraycopy(this.bytes, getOffsetIntoBytes() + i, bArr, i2, i3);
|
|
}
|
|
|
|
@Override // com.google.protobuf.ByteString.LiteralByteString
|
|
public int getOffsetIntoBytes() {
|
|
return this.bytesOffset;
|
|
}
|
|
|
|
@Override // com.google.protobuf.ByteString.LiteralByteString, com.google.protobuf.ByteString
|
|
public int size() {
|
|
return this.bytesLength;
|
|
}
|
|
|
|
public Object writeReplace() {
|
|
return ByteString.wrap(toByteArray());
|
|
}
|
|
}
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
public interface ByteArrayCopier {
|
|
byte[] copyFrom(byte[] bArr, int i, int i2);
|
|
}
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
public interface ByteIterator extends Iterator<Byte> {
|
|
byte nextByte();
|
|
}
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
public static final class CodedBuilder {
|
|
private final byte[] buffer;
|
|
private final CodedOutputStream output;
|
|
|
|
private CodedBuilder(int i) {
|
|
byte[] bArr = new byte[i];
|
|
this.buffer = bArr;
|
|
this.output = CodedOutputStream.newInstance(bArr);
|
|
}
|
|
|
|
public ByteString build() {
|
|
this.output.checkNoSpaceLeft();
|
|
return new LiteralByteString(this.buffer);
|
|
}
|
|
|
|
public CodedOutputStream getCodedOutput() {
|
|
return this.output;
|
|
}
|
|
}
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
public static abstract class LeafByteString extends ByteString {
|
|
public abstract boolean equalsRange(ByteString byteString, int i, int i2);
|
|
|
|
@Override // com.google.protobuf.ByteString
|
|
public final int getTreeDepth() {
|
|
return 0;
|
|
}
|
|
|
|
@Override // com.google.protobuf.ByteString
|
|
public final boolean isBalanced() {
|
|
return true;
|
|
}
|
|
|
|
@Override // com.google.protobuf.ByteString, java.lang.Iterable
|
|
public /* bridge */ /* synthetic */ Iterator<Byte> iterator() {
|
|
return iterator2();
|
|
}
|
|
}
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
public static final class SystemByteArrayCopier implements ByteArrayCopier {
|
|
private SystemByteArrayCopier() {
|
|
}
|
|
|
|
@Override // com.google.protobuf.ByteString.ByteArrayCopier
|
|
public byte[] copyFrom(byte[] bArr, int i, int i2) {
|
|
byte[] bArr2 = new byte[i2];
|
|
System.arraycopy(bArr, i, bArr2, 0, i2);
|
|
return bArr2;
|
|
}
|
|
}
|
|
|
|
static {
|
|
ByteArrayCopier arraysByteArrayCopier;
|
|
try {
|
|
Class.forName("android.content.Context");
|
|
arraysByteArrayCopier = new SystemByteArrayCopier();
|
|
} catch (ClassNotFoundException unused) {
|
|
arraysByteArrayCopier = new ArraysByteArrayCopier();
|
|
}
|
|
byteArrayCopier = arraysByteArrayCopier;
|
|
}
|
|
|
|
private static ByteString balancedConcat(Iterator<ByteString> it2, int i) {
|
|
if (i < 1) {
|
|
Single$$ExternalSyntheticBUOutline0.m$3(a$$ExternalSyntheticOutline0.m(i, "length (", ") must be >= 1"));
|
|
return null;
|
|
}
|
|
if (i == 1) {
|
|
return it2.next();
|
|
}
|
|
int i2 = i >>> 1;
|
|
return balancedConcat(it2, i2).concat(balancedConcat(it2, i - i2));
|
|
}
|
|
|
|
public static void checkIndex(int i, int i2) {
|
|
if (((i2 - (i + 1)) | i) < 0) {
|
|
if (i < 0) {
|
|
Verify$$ExternalSyntheticBUOutline0.m(a$$ExternalSyntheticOutline0.m(i, "Index < 0: "));
|
|
} else {
|
|
Verify$$ExternalSyntheticBUOutline0.m(a$$ExternalSyntheticOutline0.m("Index > length: ", i, ", ", i2));
|
|
}
|
|
}
|
|
}
|
|
|
|
public static int checkRange(int i, int i2, int i3) {
|
|
int i4 = i2 - i;
|
|
if ((i | i2 | i4 | (i3 - i2)) >= 0) {
|
|
return i4;
|
|
}
|
|
if (i < 0) {
|
|
XML$$ExternalSyntheticBUOutline0.m(a$$ExternalSyntheticOutline0.m(i, "Beginning index: ", " < 0"));
|
|
return 0;
|
|
}
|
|
if (i2 < i) {
|
|
XML$$ExternalSyntheticBUOutline0.m(a$$ExternalSyntheticOutline0.m("Beginning index larger than ending index: ", i, ", ", i2));
|
|
return 0;
|
|
}
|
|
XML$$ExternalSyntheticBUOutline0.m(a$$ExternalSyntheticOutline0.m("End index: ", i2, " >= ", i3));
|
|
return 0;
|
|
}
|
|
|
|
public static ByteString copyFrom(Iterable<ByteString> iterable) {
|
|
int size;
|
|
if (iterable instanceof Collection) {
|
|
size = ((Collection) iterable).size();
|
|
} else {
|
|
Iterator<ByteString> it2 = iterable.iterator();
|
|
size = 0;
|
|
while (it2.hasNext()) {
|
|
it2.next();
|
|
size++;
|
|
}
|
|
}
|
|
return size == 0 ? EMPTY : balancedConcat(iterable.iterator(), size);
|
|
}
|
|
|
|
public static ByteString copyFromUtf8(String str) {
|
|
return new LiteralByteString(str.getBytes(Internal.UTF_8));
|
|
}
|
|
|
|
public static CodedBuilder newCodedBuilder(int i) {
|
|
return new CodedBuilder(i);
|
|
}
|
|
|
|
public static Output newOutput() {
|
|
return new Output(128);
|
|
}
|
|
|
|
private static ByteString readChunk(InputStream inputStream, int i) throws IOException {
|
|
byte[] bArr = new byte[i];
|
|
int i2 = 0;
|
|
while (i2 < i) {
|
|
int read = inputStream.read(bArr, i2, i - i2);
|
|
if (read == -1) {
|
|
break;
|
|
}
|
|
i2 += read;
|
|
}
|
|
if (i2 == 0) {
|
|
return null;
|
|
}
|
|
return copyFrom(bArr, 0, i2);
|
|
}
|
|
|
|
public static ByteString readFrom(InputStream inputStream, int i, int i2) throws IOException {
|
|
ArrayList arrayList = new ArrayList();
|
|
while (true) {
|
|
ByteString readChunk = readChunk(inputStream, i);
|
|
if (readChunk == null) {
|
|
return copyFrom(arrayList);
|
|
}
|
|
arrayList.add(readChunk);
|
|
i = Math.min(i * 2, i2);
|
|
}
|
|
}
|
|
|
|
public static ByteString wrap(ByteBuffer byteBuffer) {
|
|
if (!byteBuffer.hasArray()) {
|
|
return new NioByteString(byteBuffer);
|
|
}
|
|
return wrap(byteBuffer.array(), byteBuffer.position() + byteBuffer.arrayOffset(), byteBuffer.remaining());
|
|
}
|
|
|
|
public abstract ByteBuffer asReadOnlyByteBuffer();
|
|
|
|
public abstract List<ByteBuffer> asReadOnlyByteBufferList();
|
|
|
|
public abstract byte byteAt(int i);
|
|
|
|
public final ByteString concat(ByteString byteString) {
|
|
if (Integer.MAX_VALUE - size() >= byteString.size()) {
|
|
return RopeByteString.concatenate(this, byteString);
|
|
}
|
|
Gson$$ExternalSyntheticBUOutline0.m("+", size(), byteString.size(), "ByteString would be too long: ");
|
|
return null;
|
|
}
|
|
|
|
public abstract void copyTo(ByteBuffer byteBuffer);
|
|
|
|
public final void copyTo(byte[] bArr, int i, int i2, int i3) {
|
|
checkRange(i, i + i3, size());
|
|
checkRange(i2, i2 + i3, bArr.length);
|
|
if (i3 > 0) {
|
|
copyToInternal(bArr, i, i2, i3);
|
|
}
|
|
}
|
|
|
|
public abstract void copyToInternal(byte[] bArr, int i, int i2, int i3);
|
|
|
|
public final boolean endsWith(ByteString byteString) {
|
|
return size() >= byteString.size() && substring(size() - byteString.size()).equals(byteString);
|
|
}
|
|
|
|
public abstract boolean equals(Object obj);
|
|
|
|
public abstract int getTreeDepth();
|
|
|
|
public final int hashCode() {
|
|
int i = this.hash;
|
|
if (i == 0) {
|
|
int size = size();
|
|
i = partialHash(size, 0, size);
|
|
if (i == 0) {
|
|
i = 1;
|
|
}
|
|
this.hash = i;
|
|
}
|
|
return i;
|
|
}
|
|
|
|
public abstract boolean isBalanced();
|
|
|
|
public final boolean isEmpty() {
|
|
return size() == 0;
|
|
}
|
|
|
|
public abstract boolean isValidUtf8();
|
|
|
|
@Override // java.lang.Iterable
|
|
/* renamed from: iterator, reason: merged with bridge method [inline-methods] */
|
|
public final Iterator<Byte> iterator2() {
|
|
return new ByteIterator() { // from class: com.google.protobuf.ByteString.1
|
|
private final int limit;
|
|
private int position = 0;
|
|
|
|
{
|
|
this.limit = ByteString.this.size();
|
|
}
|
|
|
|
@Override // java.util.Iterator
|
|
public boolean hasNext() {
|
|
return this.position < this.limit;
|
|
}
|
|
|
|
/* JADX WARN: Can't rename method to resolve collision */
|
|
@Override // java.util.Iterator
|
|
public Byte next() {
|
|
return Byte.valueOf(nextByte());
|
|
}
|
|
|
|
@Override // com.google.protobuf.ByteString.ByteIterator
|
|
public byte nextByte() {
|
|
try {
|
|
ByteString byteString = ByteString.this;
|
|
int i = this.position;
|
|
this.position = i + 1;
|
|
return byteString.byteAt(i);
|
|
} catch (IndexOutOfBoundsException e) {
|
|
PathKt$$ExternalSyntheticBUOutline0.m(e.getMessage());
|
|
return (byte) 0;
|
|
}
|
|
}
|
|
|
|
@Override // java.util.Iterator
|
|
public void remove() {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
};
|
|
}
|
|
|
|
public abstract CodedInputStream newCodedInput();
|
|
|
|
public abstract InputStream newInput();
|
|
|
|
public abstract int partialHash(int i, int i2, int i3);
|
|
|
|
public abstract int partialIsValidUtf8(int i, int i2, int i3);
|
|
|
|
public final int peekCachedHashCode() {
|
|
return this.hash;
|
|
}
|
|
|
|
public abstract int size();
|
|
|
|
public final boolean startsWith(ByteString byteString) {
|
|
return size() >= byteString.size() && substring(0, byteString.size()).equals(byteString);
|
|
}
|
|
|
|
public final ByteString substring(int i) {
|
|
return substring(i, size());
|
|
}
|
|
|
|
public abstract ByteString substring(int i, int i2);
|
|
|
|
public final byte[] toByteArray() {
|
|
int size = size();
|
|
if (size == 0) {
|
|
return Internal.EMPTY_BYTE_ARRAY;
|
|
}
|
|
byte[] bArr = new byte[size];
|
|
copyToInternal(bArr, 0, 0, size);
|
|
return bArr;
|
|
}
|
|
|
|
public final String toString() {
|
|
return String.format("<ByteString@%s size=%d>", Integer.toHexString(System.identityHashCode(this)), Integer.valueOf(size()));
|
|
}
|
|
|
|
public abstract String toStringInternal(Charset charset);
|
|
|
|
public final String toStringUtf8() {
|
|
return toString(Internal.UTF_8);
|
|
}
|
|
|
|
public abstract void writeTo(ByteOutput byteOutput) throws IOException;
|
|
|
|
public abstract void writeTo(OutputStream outputStream) throws IOException;
|
|
|
|
public final void writeTo(OutputStream outputStream, int i, int i2) throws IOException {
|
|
checkRange(i, i + i2, size());
|
|
if (i2 > 0) {
|
|
writeToInternal(outputStream, i, i2);
|
|
}
|
|
}
|
|
|
|
public abstract void writeToInternal(OutputStream outputStream, int i, int i2) throws IOException;
|
|
|
|
public static Output newOutput(int i) {
|
|
return new Output(i);
|
|
}
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
public static class LiteralByteString extends LeafByteString {
|
|
private static final long serialVersionUID = 1;
|
|
protected final byte[] bytes;
|
|
|
|
public LiteralByteString(byte[] bArr) {
|
|
this.bytes = bArr;
|
|
}
|
|
|
|
@Override // com.google.protobuf.ByteString
|
|
public final ByteBuffer asReadOnlyByteBuffer() {
|
|
return ByteBuffer.wrap(this.bytes, getOffsetIntoBytes(), size()).asReadOnlyBuffer();
|
|
}
|
|
|
|
@Override // com.google.protobuf.ByteString
|
|
public final List<ByteBuffer> asReadOnlyByteBufferList() {
|
|
return Collections.singletonList(asReadOnlyByteBuffer());
|
|
}
|
|
|
|
@Override // com.google.protobuf.ByteString
|
|
public byte byteAt(int i) {
|
|
return this.bytes[i];
|
|
}
|
|
|
|
@Override // com.google.protobuf.ByteString
|
|
public final void copyTo(ByteBuffer byteBuffer) {
|
|
byteBuffer.put(this.bytes, getOffsetIntoBytes(), size());
|
|
}
|
|
|
|
@Override // com.google.protobuf.ByteString
|
|
public void copyToInternal(byte[] bArr, int i, int i2, int i3) {
|
|
System.arraycopy(this.bytes, i, bArr, i2, i3);
|
|
}
|
|
|
|
@Override // com.google.protobuf.ByteString
|
|
public final boolean equals(Object obj) {
|
|
if (obj == this) {
|
|
return true;
|
|
}
|
|
if (!(obj instanceof ByteString) || size() != ((ByteString) obj).size()) {
|
|
return false;
|
|
}
|
|
if (size() == 0) {
|
|
return true;
|
|
}
|
|
if (!(obj instanceof LiteralByteString)) {
|
|
return obj.equals(this);
|
|
}
|
|
LiteralByteString literalByteString = (LiteralByteString) obj;
|
|
int peekCachedHashCode = peekCachedHashCode();
|
|
int peekCachedHashCode2 = literalByteString.peekCachedHashCode();
|
|
if (peekCachedHashCode == 0 || peekCachedHashCode2 == 0 || peekCachedHashCode == peekCachedHashCode2) {
|
|
return equalsRange(literalByteString, 0, size());
|
|
}
|
|
return false;
|
|
}
|
|
|
|
@Override // com.google.protobuf.ByteString.LeafByteString
|
|
public final boolean equalsRange(ByteString byteString, int i, int i2) {
|
|
if (i2 > byteString.size()) {
|
|
Intl$$ExternalSyntheticBUOutline0.m(i2, size());
|
|
return false;
|
|
}
|
|
int i3 = i + i2;
|
|
if (i3 > byteString.size()) {
|
|
Single$$ExternalSyntheticBUOutline0.m(byteString.size(), ErrorUtils$$ExternalSyntheticOutline0.m29m(i, i2, "Ran off end of other: ", ", ", ", "));
|
|
return false;
|
|
}
|
|
if (!(byteString instanceof LiteralByteString)) {
|
|
return byteString.substring(i, i3).equals(substring(0, i2));
|
|
}
|
|
LiteralByteString literalByteString = (LiteralByteString) byteString;
|
|
byte[] bArr = this.bytes;
|
|
byte[] bArr2 = literalByteString.bytes;
|
|
int offsetIntoBytes = getOffsetIntoBytes() + i2;
|
|
int offsetIntoBytes2 = getOffsetIntoBytes();
|
|
int offsetIntoBytes3 = literalByteString.getOffsetIntoBytes() + i;
|
|
while (offsetIntoBytes2 < offsetIntoBytes) {
|
|
if (bArr[offsetIntoBytes2] != bArr2[offsetIntoBytes3]) {
|
|
return false;
|
|
}
|
|
offsetIntoBytes2++;
|
|
offsetIntoBytes3++;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public int getOffsetIntoBytes() {
|
|
return 0;
|
|
}
|
|
|
|
@Override // com.google.protobuf.ByteString
|
|
public final boolean isValidUtf8() {
|
|
int offsetIntoBytes = getOffsetIntoBytes();
|
|
return Utf8.isValidUtf8(this.bytes, offsetIntoBytes, size() + offsetIntoBytes);
|
|
}
|
|
|
|
@Override // com.google.protobuf.ByteString
|
|
public final CodedInputStream newCodedInput() {
|
|
return CodedInputStream.newInstance(this.bytes, getOffsetIntoBytes(), size(), true);
|
|
}
|
|
|
|
@Override // com.google.protobuf.ByteString
|
|
public final InputStream newInput() {
|
|
return new ByteArrayInputStream(this.bytes, getOffsetIntoBytes(), size());
|
|
}
|
|
|
|
@Override // com.google.protobuf.ByteString
|
|
public final int partialHash(int i, int i2, int i3) {
|
|
return Internal.partialHash(i, this.bytes, getOffsetIntoBytes() + i2, i3);
|
|
}
|
|
|
|
@Override // com.google.protobuf.ByteString
|
|
public final int partialIsValidUtf8(int i, int i2, int i3) {
|
|
int offsetIntoBytes = getOffsetIntoBytes() + i2;
|
|
return Utf8.partialIsValidUtf8(i, this.bytes, offsetIntoBytes, i3 + offsetIntoBytes);
|
|
}
|
|
|
|
@Override // com.google.protobuf.ByteString
|
|
public int size() {
|
|
return this.bytes.length;
|
|
}
|
|
|
|
@Override // com.google.protobuf.ByteString
|
|
public final ByteString substring(int i, int i2) {
|
|
int checkRange = ByteString.checkRange(i, i2, size());
|
|
return checkRange == 0 ? ByteString.EMPTY : new BoundedByteString(this.bytes, getOffsetIntoBytes() + i, checkRange);
|
|
}
|
|
|
|
@Override // com.google.protobuf.ByteString
|
|
public final String toStringInternal(Charset charset) {
|
|
return new String(this.bytes, getOffsetIntoBytes(), size(), charset);
|
|
}
|
|
|
|
@Override // com.google.protobuf.ByteString
|
|
public final void writeTo(ByteOutput byteOutput) throws IOException {
|
|
byteOutput.writeLazy(this.bytes, getOffsetIntoBytes(), size());
|
|
}
|
|
|
|
@Override // com.google.protobuf.ByteString
|
|
public final void writeToInternal(OutputStream outputStream, int i, int i2) throws IOException {
|
|
outputStream.write(this.bytes, getOffsetIntoBytes() + i, i2);
|
|
}
|
|
|
|
@Override // com.google.protobuf.ByteString
|
|
public final void writeTo(OutputStream outputStream) throws IOException {
|
|
outputStream.write(toByteArray());
|
|
}
|
|
}
|
|
|
|
public void copyTo(byte[] bArr, int i) {
|
|
copyTo(bArr, 0, i, size());
|
|
}
|
|
|
|
public static ByteString readFrom(InputStream inputStream, int i) throws IOException {
|
|
return readFrom(inputStream, i, i);
|
|
}
|
|
|
|
public static ByteString readFrom(InputStream inputStream) throws IOException {
|
|
return readFrom(inputStream, 256, 8192);
|
|
}
|
|
|
|
public final String toString(Charset charset) {
|
|
return size() == 0 ? "" : toStringInternal(charset);
|
|
}
|
|
|
|
public final String toString(String str) throws UnsupportedEncodingException {
|
|
try {
|
|
return toString(Charset.forName(str));
|
|
} catch (UnsupportedCharsetException e) {
|
|
UnsupportedEncodingException unsupportedEncodingException = new UnsupportedEncodingException(str);
|
|
unsupportedEncodingException.initCause(e);
|
|
throw unsupportedEncodingException;
|
|
}
|
|
}
|
|
|
|
public static ByteString wrap(byte[] bArr) {
|
|
return new LiteralByteString(bArr);
|
|
}
|
|
|
|
public static ByteString wrap(byte[] bArr, int i, int i2) {
|
|
return new BoundedByteString(bArr, i, i2);
|
|
}
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
public static final class Output extends OutputStream {
|
|
private static final byte[] EMPTY_BYTE_ARRAY = new byte[0];
|
|
private byte[] buffer;
|
|
private int bufferPos;
|
|
private final ArrayList<ByteString> flushedBuffers;
|
|
private int flushedBuffersTotalBytes;
|
|
private final int initialCapacity;
|
|
|
|
public Output(int i) {
|
|
if (i < 0) {
|
|
Single$$ExternalSyntheticBUOutline0.m$3("Buffer size < 0");
|
|
throw null;
|
|
}
|
|
this.initialCapacity = i;
|
|
this.flushedBuffers = new ArrayList<>();
|
|
this.buffer = new byte[i];
|
|
}
|
|
|
|
private byte[] copyArray(byte[] bArr, int i) {
|
|
byte[] bArr2 = new byte[i];
|
|
System.arraycopy(bArr, 0, bArr2, 0, Math.min(bArr.length, i));
|
|
return bArr2;
|
|
}
|
|
|
|
private void flushFullBuffer(int i) {
|
|
this.flushedBuffers.add(new LiteralByteString(this.buffer));
|
|
int length = this.flushedBuffersTotalBytes + this.buffer.length;
|
|
this.flushedBuffersTotalBytes = length;
|
|
this.buffer = new byte[Math.max(this.initialCapacity, Math.max(i, length >>> 1))];
|
|
this.bufferPos = 0;
|
|
}
|
|
|
|
private void flushLastBuffer() {
|
|
int i = this.bufferPos;
|
|
byte[] bArr = this.buffer;
|
|
if (i >= bArr.length) {
|
|
this.flushedBuffers.add(new LiteralByteString(this.buffer));
|
|
this.buffer = EMPTY_BYTE_ARRAY;
|
|
} else if (i > 0) {
|
|
this.flushedBuffers.add(new LiteralByteString(copyArray(bArr, i)));
|
|
}
|
|
this.flushedBuffersTotalBytes += this.bufferPos;
|
|
this.bufferPos = 0;
|
|
}
|
|
|
|
public synchronized void reset() {
|
|
this.flushedBuffers.clear();
|
|
this.flushedBuffersTotalBytes = 0;
|
|
this.bufferPos = 0;
|
|
}
|
|
|
|
public synchronized int size() {
|
|
return this.flushedBuffersTotalBytes + this.bufferPos;
|
|
}
|
|
|
|
public synchronized ByteString toByteString() {
|
|
flushLastBuffer();
|
|
return ByteString.copyFrom(this.flushedBuffers);
|
|
}
|
|
|
|
public String toString() {
|
|
return String.format("<ByteString.Output@%s size=%d>", Integer.toHexString(System.identityHashCode(this)), Integer.valueOf(size()));
|
|
}
|
|
|
|
@Override // java.io.OutputStream
|
|
public synchronized void write(byte[] bArr, int i, int i2) {
|
|
try {
|
|
byte[] bArr2 = this.buffer;
|
|
int length = bArr2.length;
|
|
int i3 = this.bufferPos;
|
|
if (i2 <= length - i3) {
|
|
System.arraycopy(bArr, i, bArr2, i3, i2);
|
|
this.bufferPos += i2;
|
|
} else {
|
|
int length2 = bArr2.length - i3;
|
|
System.arraycopy(bArr, i, bArr2, i3, length2);
|
|
int i4 = i2 - length2;
|
|
flushFullBuffer(i4);
|
|
System.arraycopy(bArr, i + length2, this.buffer, 0, i4);
|
|
this.bufferPos = i4;
|
|
}
|
|
} catch (Throwable th) {
|
|
throw th;
|
|
}
|
|
}
|
|
|
|
public void writeTo(OutputStream outputStream) throws IOException {
|
|
ByteString[] byteStringArr;
|
|
byte[] bArr;
|
|
int i;
|
|
synchronized (this) {
|
|
ArrayList<ByteString> arrayList = this.flushedBuffers;
|
|
byteStringArr = (ByteString[]) arrayList.toArray(new ByteString[arrayList.size()]);
|
|
bArr = this.buffer;
|
|
i = this.bufferPos;
|
|
}
|
|
for (ByteString byteString : byteStringArr) {
|
|
byteString.writeTo(outputStream);
|
|
}
|
|
outputStream.write(copyArray(bArr, i));
|
|
}
|
|
|
|
@Override // java.io.OutputStream
|
|
public synchronized void write(int i) {
|
|
try {
|
|
if (this.bufferPos == this.buffer.length) {
|
|
flushFullBuffer(1);
|
|
}
|
|
byte[] bArr = this.buffer;
|
|
int i2 = this.bufferPos;
|
|
this.bufferPos = i2 + 1;
|
|
bArr[i2] = (byte) i;
|
|
} catch (Throwable th) {
|
|
throw th;
|
|
}
|
|
}
|
|
}
|
|
|
|
public static ByteString copyFrom(byte[] bArr) {
|
|
return copyFrom(bArr, 0, bArr.length);
|
|
}
|
|
|
|
public static ByteString copyFrom(ByteBuffer byteBuffer, int i) {
|
|
byte[] bArr = new byte[i];
|
|
byteBuffer.get(bArr);
|
|
return new LiteralByteString(bArr);
|
|
}
|
|
|
|
public static ByteString copyFrom(ByteBuffer byteBuffer) {
|
|
return copyFrom(byteBuffer, byteBuffer.remaining());
|
|
}
|
|
|
|
public static ByteString copyFrom(String str, String str2) throws UnsupportedEncodingException {
|
|
return new LiteralByteString(str.getBytes(str2));
|
|
}
|
|
|
|
public static ByteString copyFrom(String str, Charset charset) {
|
|
return new LiteralByteString(str.getBytes(charset));
|
|
}
|
|
|
|
public static ByteString copyFrom(byte[] bArr, int i, int i2) {
|
|
return new LiteralByteString(byteArrayCopier.copyFrom(bArr, i, i2));
|
|
}
|
|
}
|