Files
rr3-apk/decompiled/sources/com/google/protobuf/CodedOutputStream.java
Daniel Elliott f9d20bb3fc Add decompiled APK source code (JADX)
- 28,932 files
- Full Java source code
- Smali files
- Resources

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-02-18 14:52:23 -08:00

2323 lines
85 KiB
Java

package com.google.protobuf;
import androidx.work.WorkInfo;
import com.google.protobuf.Utf8;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.BufferOverflowException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.logging.Level;
import java.util.logging.Logger;
/* loaded from: classes3.dex */
public abstract class CodedOutputStream extends ByteOutput {
public static final int DEFAULT_BUFFER_SIZE = 4096;
@Deprecated
public static final int LITTLE_ENDIAN_32_SIZE = 4;
private boolean serializationDeterministic;
CodedOutputStreamWriter wrapper;
private static final Logger logger = Logger.getLogger(CodedOutputStream.class.getName());
private static final boolean HAS_UNSAFE_ARRAY_OPERATIONS = UnsafeUtil.hasUnsafeArrayOperations();
public static int computeBoolSizeNoTag(boolean z) {
return 1;
}
public static int computeDoubleSizeNoTag(double d) {
return 8;
}
public static int computeFixed32SizeNoTag(int i) {
return 4;
}
public static int computeFixed64SizeNoTag(long j) {
return 8;
}
public static int computeFloatSizeNoTag(float f) {
return 4;
}
public static int computePreferredBufferSize(int i) {
if (i > 4096) {
return 4096;
}
return i;
}
public static int computeSFixed32SizeNoTag(int i) {
return 4;
}
public static int computeSFixed64SizeNoTag(long j) {
return 8;
}
public static int computeUInt32SizeNoTag(int i) {
if ((i & WorkInfo.STOP_REASON_FOREGROUND_SERVICE_TIMEOUT) == 0) {
return 1;
}
if ((i & (-16384)) == 0) {
return 2;
}
if (((-2097152) & i) == 0) {
return 3;
}
return (i & (-268435456)) == 0 ? 4 : 5;
}
public static int computeUInt64SizeNoTag(long j) {
int i;
if (((-128) & j) == 0) {
return 1;
}
if (j < 0) {
return 10;
}
if (((-34359738368L) & j) != 0) {
j >>>= 28;
i = 6;
} else {
i = 2;
}
if (((-2097152) & j) != 0) {
i += 2;
j >>>= 14;
}
return (j & (-16384)) != 0 ? i + 1 : i;
}
public static int encodeZigZag32(int i) {
return (i >> 31) ^ (i << 1);
}
public static long encodeZigZag64(long j) {
return (j >> 63) ^ (j << 1);
}
public abstract void flush() throws IOException;
public abstract int getTotalBytesWritten();
public boolean isSerializationDeterministic() {
return this.serializationDeterministic;
}
public abstract int spaceLeft();
public void useDeterministicSerialization() {
this.serializationDeterministic = true;
}
@Override // com.google.protobuf.ByteOutput
public abstract void write(byte b) throws IOException;
@Override // com.google.protobuf.ByteOutput
public abstract void write(ByteBuffer byteBuffer) throws IOException;
@Override // com.google.protobuf.ByteOutput
public abstract void write(byte[] bArr, int i, int i2) throws IOException;
public abstract void writeBool(int i, boolean z) throws IOException;
public abstract void writeByteArray(int i, byte[] bArr) throws IOException;
public abstract void writeByteArray(int i, byte[] bArr, int i2, int i3) throws IOException;
public abstract void writeByteArrayNoTag(byte[] bArr, int i, int i2) throws IOException;
public abstract void writeByteBuffer(int i, ByteBuffer byteBuffer) throws IOException;
public abstract void writeBytes(int i, ByteString byteString) throws IOException;
public abstract void writeBytesNoTag(ByteString byteString) throws IOException;
public abstract void writeFixed32(int i, int i2) throws IOException;
public abstract void writeFixed32NoTag(int i) throws IOException;
public abstract void writeFixed64(int i, long j) throws IOException;
public abstract void writeFixed64NoTag(long j) throws IOException;
public abstract void writeInt32(int i, int i2) throws IOException;
public abstract void writeInt32NoTag(int i) throws IOException;
@Override // com.google.protobuf.ByteOutput
public abstract void writeLazy(ByteBuffer byteBuffer) throws IOException;
@Override // com.google.protobuf.ByteOutput
public abstract void writeLazy(byte[] bArr, int i, int i2) throws IOException;
public abstract void writeMessage(int i, MessageLite messageLite) throws IOException;
public abstract void writeMessage(int i, MessageLite messageLite, Schema schema) throws IOException;
public abstract void writeMessageNoTag(MessageLite messageLite) throws IOException;
public abstract void writeMessageNoTag(MessageLite messageLite, Schema schema) throws IOException;
public abstract void writeMessageSetExtension(int i, MessageLite messageLite) throws IOException;
public abstract void writeRawBytes(ByteBuffer byteBuffer) throws IOException;
public abstract void writeRawMessageSetExtension(int i, ByteString byteString) throws IOException;
public abstract void writeString(int i, String str) throws IOException;
public abstract void writeStringNoTag(String str) throws IOException;
public abstract void writeTag(int i, int i2) throws IOException;
public abstract void writeUInt32(int i, int i2) throws IOException;
public abstract void writeUInt32NoTag(int i) throws IOException;
public abstract void writeUInt64(int i, long j) throws IOException;
public abstract void writeUInt64NoTag(long j) throws IOException;
public static CodedOutputStream newInstance(OutputStream outputStream) {
return newInstance(outputStream, 4096);
}
public static CodedOutputStream newInstance(OutputStream outputStream, int i) {
return new OutputStreamEncoder(outputStream, i);
}
public static CodedOutputStream newInstance(byte[] bArr) {
return newInstance(bArr, 0, bArr.length);
}
public static CodedOutputStream newInstance(byte[] bArr, int i, int i2) {
return new ArrayEncoder(bArr, i, i2);
}
public static CodedOutputStream newInstance(ByteBuffer byteBuffer) {
if (byteBuffer.hasArray()) {
return new HeapNioEncoder(byteBuffer);
}
if (byteBuffer.isDirect() && !byteBuffer.isReadOnly()) {
if (UnsafeDirectNioEncoder.isSupported()) {
return newUnsafeInstance(byteBuffer);
}
return newSafeInstance(byteBuffer);
}
throw new IllegalArgumentException("ByteBuffer is read-only");
}
public static CodedOutputStream newUnsafeInstance(ByteBuffer byteBuffer) {
return new UnsafeDirectNioEncoder(byteBuffer);
}
public static CodedOutputStream newSafeInstance(ByteBuffer byteBuffer) {
return new SafeDirectNioEncoder(byteBuffer);
}
@Deprecated
public static CodedOutputStream newInstance(ByteBuffer byteBuffer, int i) {
return newInstance(byteBuffer);
}
public static CodedOutputStream newInstance(ByteOutput byteOutput, int i) {
if (i < 0) {
throw new IllegalArgumentException("bufferSize must be positive");
}
return new ByteOutputEncoder(byteOutput, i);
}
private CodedOutputStream() {
}
public final void writeSInt32(int i, int i2) throws IOException {
writeUInt32(i, encodeZigZag32(i2));
}
public final void writeSFixed32(int i, int i2) throws IOException {
writeFixed32(i, i2);
}
public final void writeInt64(int i, long j) throws IOException {
writeUInt64(i, j);
}
public final void writeSInt64(int i, long j) throws IOException {
writeUInt64(i, encodeZigZag64(j));
}
public final void writeSFixed64(int i, long j) throws IOException {
writeFixed64(i, j);
}
public final void writeFloat(int i, float f) throws IOException {
writeFixed32(i, Float.floatToRawIntBits(f));
}
public final void writeDouble(int i, double d) throws IOException {
writeFixed64(i, Double.doubleToRawLongBits(d));
}
public final void writeEnum(int i, int i2) throws IOException {
writeInt32(i, i2);
}
public final void writeRawByte(byte b) throws IOException {
write(b);
}
public final void writeRawByte(int i) throws IOException {
write((byte) i);
}
public final void writeRawBytes(byte[] bArr) throws IOException {
write(bArr, 0, bArr.length);
}
public final void writeRawBytes(byte[] bArr, int i, int i2) throws IOException {
write(bArr, i, i2);
}
public final void writeRawBytes(ByteString byteString) throws IOException {
byteString.writeTo(this);
}
public final void writeSInt32NoTag(int i) throws IOException {
writeUInt32NoTag(encodeZigZag32(i));
}
public final void writeSFixed32NoTag(int i) throws IOException {
writeFixed32NoTag(i);
}
public final void writeInt64NoTag(long j) throws IOException {
writeUInt64NoTag(j);
}
public final void writeSInt64NoTag(long j) throws IOException {
writeUInt64NoTag(encodeZigZag64(j));
}
public final void writeSFixed64NoTag(long j) throws IOException {
writeFixed64NoTag(j);
}
public final void writeFloatNoTag(float f) throws IOException {
writeFixed32NoTag(Float.floatToRawIntBits(f));
}
public final void writeDoubleNoTag(double d) throws IOException {
writeFixed64NoTag(Double.doubleToRawLongBits(d));
}
public final void writeBoolNoTag(boolean z) throws IOException {
write(z ? (byte) 1 : (byte) 0);
}
public final void writeEnumNoTag(int i) throws IOException {
writeInt32NoTag(i);
}
public final void writeByteArrayNoTag(byte[] bArr) throws IOException {
writeByteArrayNoTag(bArr, 0, bArr.length);
}
public static int computeInt32Size(int i, int i2) {
return computeTagSize(i) + computeInt32SizeNoTag(i2);
}
public static int computeUInt32Size(int i, int i2) {
return computeTagSize(i) + computeUInt32SizeNoTag(i2);
}
public static int computeSInt32Size(int i, int i2) {
return computeTagSize(i) + computeSInt32SizeNoTag(i2);
}
public static int computeFixed32Size(int i, int i2) {
return computeTagSize(i) + computeFixed32SizeNoTag(i2);
}
public static int computeSFixed32Size(int i, int i2) {
return computeTagSize(i) + computeSFixed32SizeNoTag(i2);
}
public static int computeInt64Size(int i, long j) {
return computeTagSize(i) + computeInt64SizeNoTag(j);
}
public static int computeUInt64Size(int i, long j) {
return computeTagSize(i) + computeUInt64SizeNoTag(j);
}
public static int computeSInt64Size(int i, long j) {
return computeTagSize(i) + computeSInt64SizeNoTag(j);
}
public static int computeFixed64Size(int i, long j) {
return computeTagSize(i) + computeFixed64SizeNoTag(j);
}
public static int computeSFixed64Size(int i, long j) {
return computeTagSize(i) + computeSFixed64SizeNoTag(j);
}
public static int computeFloatSize(int i, float f) {
return computeTagSize(i) + computeFloatSizeNoTag(f);
}
public static int computeDoubleSize(int i, double d) {
return computeTagSize(i) + computeDoubleSizeNoTag(d);
}
public static int computeBoolSize(int i, boolean z) {
return computeTagSize(i) + computeBoolSizeNoTag(z);
}
public static int computeEnumSize(int i, int i2) {
return computeTagSize(i) + computeEnumSizeNoTag(i2);
}
public static int computeStringSize(int i, String str) {
return computeTagSize(i) + computeStringSizeNoTag(str);
}
public static int computeBytesSize(int i, ByteString byteString) {
return computeTagSize(i) + computeBytesSizeNoTag(byteString);
}
public static int computeByteArraySize(int i, byte[] bArr) {
return computeTagSize(i) + computeByteArraySizeNoTag(bArr);
}
public static int computeByteBufferSize(int i, ByteBuffer byteBuffer) {
return computeTagSize(i) + computeByteBufferSizeNoTag(byteBuffer);
}
public static int computeLazyFieldSize(int i, LazyFieldLite lazyFieldLite) {
return computeTagSize(i) + computeLazyFieldSizeNoTag(lazyFieldLite);
}
public static int computeMessageSize(int i, MessageLite messageLite) {
return computeTagSize(i) + computeMessageSizeNoTag(messageLite);
}
public static int computeMessageSize(int i, MessageLite messageLite, Schema schema) {
return computeTagSize(i) + computeMessageSizeNoTag(messageLite, schema);
}
public static int computeMessageSetExtensionSize(int i, MessageLite messageLite) {
return (computeTagSize(1) * 2) + computeUInt32Size(2, i) + computeMessageSize(3, messageLite);
}
public static int computeRawMessageSetExtensionSize(int i, ByteString byteString) {
return (computeTagSize(1) * 2) + computeUInt32Size(2, i) + computeBytesSize(3, byteString);
}
public static int computeLazyFieldMessageSetExtensionSize(int i, LazyFieldLite lazyFieldLite) {
return (computeTagSize(1) * 2) + computeUInt32Size(2, i) + computeLazyFieldSize(3, lazyFieldLite);
}
public static int computeTagSize(int i) {
return computeUInt32SizeNoTag(WireFormat.makeTag(i, 0));
}
public static int computeInt32SizeNoTag(int i) {
if (i >= 0) {
return computeUInt32SizeNoTag(i);
}
return 10;
}
public static int computeSInt32SizeNoTag(int i) {
return computeUInt32SizeNoTag(encodeZigZag32(i));
}
public static int computeInt64SizeNoTag(long j) {
return computeUInt64SizeNoTag(j);
}
public static int computeSInt64SizeNoTag(long j) {
return computeUInt64SizeNoTag(encodeZigZag64(j));
}
public static int computeEnumSizeNoTag(int i) {
return computeInt32SizeNoTag(i);
}
public static int computeStringSizeNoTag(String str) {
int length;
try {
length = Utf8.encodedLength(str);
} catch (Utf8.UnpairedSurrogateException unused) {
length = str.getBytes(Internal.UTF_8).length;
}
return computeLengthDelimitedFieldSize(length);
}
public static int computeLazyFieldSizeNoTag(LazyFieldLite lazyFieldLite) {
return computeLengthDelimitedFieldSize(lazyFieldLite.getSerializedSize());
}
public static int computeBytesSizeNoTag(ByteString byteString) {
return computeLengthDelimitedFieldSize(byteString.size());
}
public static int computeByteArraySizeNoTag(byte[] bArr) {
return computeLengthDelimitedFieldSize(bArr.length);
}
public static int computeByteBufferSizeNoTag(ByteBuffer byteBuffer) {
return computeLengthDelimitedFieldSize(byteBuffer.capacity());
}
public static int computeMessageSizeNoTag(MessageLite messageLite) {
return computeLengthDelimitedFieldSize(messageLite.getSerializedSize());
}
public static int computeMessageSizeNoTag(MessageLite messageLite, Schema schema) {
return computeLengthDelimitedFieldSize(((AbstractMessageLite) messageLite).getSerializedSize(schema));
}
public static int computeLengthDelimitedFieldSize(int i) {
return computeUInt32SizeNoTag(i) + i;
}
public final void checkNoSpaceLeft() {
if (spaceLeft() != 0) {
throw new IllegalStateException("Did not write as much data as expected.");
}
}
public static class OutOfSpaceException extends IOException {
private static final String MESSAGE = "CodedOutputStream was writing to a flat byte array and ran out of space.";
private static final long serialVersionUID = -6947486886997889499L;
public OutOfSpaceException() {
super(MESSAGE);
}
public OutOfSpaceException(String str) {
super("CodedOutputStream was writing to a flat byte array and ran out of space.: " + str);
}
public OutOfSpaceException(Throwable th) {
super(MESSAGE, th);
}
public OutOfSpaceException(String str, Throwable th) {
super("CodedOutputStream was writing to a flat byte array and ran out of space.: " + str, th);
}
}
public final void inefficientWriteStringNoTag(String str, Utf8.UnpairedSurrogateException unpairedSurrogateException) throws IOException {
logger.log(Level.WARNING, "Converting ill-formed UTF-16. Your Protocol Buffer will not round trip correctly!", (Throwable) unpairedSurrogateException);
byte[] bytes = str.getBytes(Internal.UTF_8);
try {
writeUInt32NoTag(bytes.length);
writeLazy(bytes, 0, bytes.length);
} catch (IndexOutOfBoundsException e) {
throw new OutOfSpaceException(e);
}
}
@Deprecated
public final void writeGroup(int i, MessageLite messageLite) throws IOException {
writeTag(i, 3);
writeGroupNoTag(messageLite);
writeTag(i, 4);
}
@Deprecated
public final void writeGroup(int i, MessageLite messageLite, Schema schema) throws IOException {
writeTag(i, 3);
writeGroupNoTag(messageLite, schema);
writeTag(i, 4);
}
@Deprecated
public final void writeGroupNoTag(MessageLite messageLite) throws IOException {
messageLite.writeTo(this);
}
@Deprecated
public final void writeGroupNoTag(MessageLite messageLite, Schema schema) throws IOException {
schema.writeTo(messageLite, this.wrapper);
}
@Deprecated
public static int computeGroupSize(int i, MessageLite messageLite) {
return (computeTagSize(i) * 2) + messageLite.getSerializedSize();
}
@Deprecated
public static int computeGroupSize(int i, MessageLite messageLite, Schema schema) {
return (computeTagSize(i) * 2) + computeGroupSizeNoTag(messageLite, schema);
}
@Deprecated
public static int computeGroupSizeNoTag(MessageLite messageLite) {
return messageLite.getSerializedSize();
}
@Deprecated
public static int computeGroupSizeNoTag(MessageLite messageLite, Schema schema) {
return ((AbstractMessageLite) messageLite).getSerializedSize(schema);
}
@Deprecated
public final void writeRawVarint32(int i) throws IOException {
writeUInt32NoTag(i);
}
@Deprecated
public final void writeRawVarint64(long j) throws IOException {
writeUInt64NoTag(j);
}
@Deprecated
public static int computeRawVarint32Size(int i) {
return computeUInt32SizeNoTag(i);
}
@Deprecated
public static int computeRawVarint64Size(long j) {
return computeUInt64SizeNoTag(j);
}
@Deprecated
public final void writeRawLittleEndian32(int i) throws IOException {
writeFixed32NoTag(i);
}
@Deprecated
public final void writeRawLittleEndian64(long j) throws IOException {
writeFixed64NoTag(j);
}
public static class ArrayEncoder extends CodedOutputStream {
private final byte[] buffer;
private final int limit;
private final int offset;
private int position;
@Override // com.google.protobuf.CodedOutputStream
public void flush() {
}
@Override // com.google.protobuf.CodedOutputStream
public final int getTotalBytesWritten() {
return this.position - this.offset;
}
@Override // com.google.protobuf.CodedOutputStream
public final int spaceLeft() {
return this.limit - this.position;
}
public ArrayEncoder(byte[] bArr, int i, int i2) {
super();
if (bArr == null) {
throw new NullPointerException("buffer");
}
int i3 = i + i2;
if ((i | i2 | (bArr.length - i3)) < 0) {
throw new IllegalArgumentException(String.format("Array range is invalid. Buffer.length=%d, offset=%d, length=%d", Integer.valueOf(bArr.length), Integer.valueOf(i), Integer.valueOf(i2)));
}
this.buffer = bArr;
this.offset = i;
this.position = i;
this.limit = i3;
}
@Override // com.google.protobuf.CodedOutputStream
public final void writeTag(int i, int i2) throws IOException {
writeUInt32NoTag(WireFormat.makeTag(i, i2));
}
@Override // com.google.protobuf.CodedOutputStream
public final void writeInt32(int i, int i2) throws IOException {
writeTag(i, 0);
writeInt32NoTag(i2);
}
@Override // com.google.protobuf.CodedOutputStream
public final void writeUInt32(int i, int i2) throws IOException {
writeTag(i, 0);
writeUInt32NoTag(i2);
}
@Override // com.google.protobuf.CodedOutputStream
public final void writeFixed32(int i, int i2) throws IOException {
writeTag(i, 5);
writeFixed32NoTag(i2);
}
@Override // com.google.protobuf.CodedOutputStream
public final void writeUInt64(int i, long j) throws IOException {
writeTag(i, 0);
writeUInt64NoTag(j);
}
@Override // com.google.protobuf.CodedOutputStream
public final void writeFixed64(int i, long j) throws IOException {
writeTag(i, 1);
writeFixed64NoTag(j);
}
@Override // com.google.protobuf.CodedOutputStream
public final void writeBool(int i, boolean z) throws IOException {
writeTag(i, 0);
write(z ? (byte) 1 : (byte) 0);
}
@Override // com.google.protobuf.CodedOutputStream
public final void writeString(int i, String str) throws IOException {
writeTag(i, 2);
writeStringNoTag(str);
}
@Override // com.google.protobuf.CodedOutputStream
public final void writeBytes(int i, ByteString byteString) throws IOException {
writeTag(i, 2);
writeBytesNoTag(byteString);
}
@Override // com.google.protobuf.CodedOutputStream
public final void writeByteArray(int i, byte[] bArr) throws IOException {
writeByteArray(i, bArr, 0, bArr.length);
}
@Override // com.google.protobuf.CodedOutputStream
public final void writeByteArray(int i, byte[] bArr, int i2, int i3) throws IOException {
writeTag(i, 2);
writeByteArrayNoTag(bArr, i2, i3);
}
@Override // com.google.protobuf.CodedOutputStream
public final void writeByteBuffer(int i, ByteBuffer byteBuffer) throws IOException {
writeTag(i, 2);
writeUInt32NoTag(byteBuffer.capacity());
writeRawBytes(byteBuffer);
}
@Override // com.google.protobuf.CodedOutputStream
public final void writeBytesNoTag(ByteString byteString) throws IOException {
writeUInt32NoTag(byteString.size());
byteString.writeTo(this);
}
@Override // com.google.protobuf.CodedOutputStream
public final void writeByteArrayNoTag(byte[] bArr, int i, int i2) throws IOException {
writeUInt32NoTag(i2);
write(bArr, i, i2);
}
@Override // com.google.protobuf.CodedOutputStream
public final void writeRawBytes(ByteBuffer byteBuffer) throws IOException {
if (byteBuffer.hasArray()) {
write(byteBuffer.array(), byteBuffer.arrayOffset(), byteBuffer.capacity());
return;
}
ByteBuffer duplicate = byteBuffer.duplicate();
write(duplicate);
}
@Override // com.google.protobuf.CodedOutputStream
public final void writeMessage(int i, MessageLite messageLite) throws IOException {
writeTag(i, 2);
writeMessageNoTag(messageLite);
}
@Override // com.google.protobuf.CodedOutputStream
public final void writeMessage(int i, MessageLite messageLite, Schema schema) throws IOException {
writeTag(i, 2);
writeUInt32NoTag(((AbstractMessageLite) messageLite).getSerializedSize(schema));
schema.writeTo(messageLite, this.wrapper);
}
@Override // com.google.protobuf.CodedOutputStream
public final void writeMessageSetExtension(int i, MessageLite messageLite) throws IOException {
writeTag(1, 3);
writeUInt32(2, i);
writeMessage(3, messageLite);
writeTag(1, 4);
}
@Override // com.google.protobuf.CodedOutputStream
public final void writeRawMessageSetExtension(int i, ByteString byteString) throws IOException {
writeTag(1, 3);
writeUInt32(2, i);
writeBytes(3, byteString);
writeTag(1, 4);
}
@Override // com.google.protobuf.CodedOutputStream
public final void writeMessageNoTag(MessageLite messageLite) throws IOException {
writeUInt32NoTag(messageLite.getSerializedSize());
messageLite.writeTo(this);
}
@Override // com.google.protobuf.CodedOutputStream
public final void writeMessageNoTag(MessageLite messageLite, Schema schema) throws IOException {
writeUInt32NoTag(((AbstractMessageLite) messageLite).getSerializedSize(schema));
schema.writeTo(messageLite, this.wrapper);
}
@Override // com.google.protobuf.CodedOutputStream, com.google.protobuf.ByteOutput
public final void write(byte b) throws IOException {
try {
byte[] bArr = this.buffer;
int i = this.position;
this.position = i + 1;
bArr[i] = b;
} catch (IndexOutOfBoundsException e) {
throw new OutOfSpaceException(String.format("Pos: %d, limit: %d, len: %d", Integer.valueOf(this.position), Integer.valueOf(this.limit), 1), e);
}
}
@Override // com.google.protobuf.CodedOutputStream
public final void writeInt32NoTag(int i) throws IOException {
if (i >= 0) {
writeUInt32NoTag(i);
} else {
writeUInt64NoTag(i);
}
}
@Override // com.google.protobuf.CodedOutputStream
public final void writeUInt32NoTag(int i) throws IOException {
while ((i & WorkInfo.STOP_REASON_FOREGROUND_SERVICE_TIMEOUT) != 0) {
try {
byte[] bArr = this.buffer;
int i2 = this.position;
this.position = i2 + 1;
bArr[i2] = (byte) ((i & 127) | 128);
i >>>= 7;
} catch (IndexOutOfBoundsException e) {
throw new OutOfSpaceException(String.format("Pos: %d, limit: %d, len: %d", Integer.valueOf(this.position), Integer.valueOf(this.limit), 1), e);
}
}
byte[] bArr2 = this.buffer;
int i3 = this.position;
this.position = i3 + 1;
bArr2[i3] = (byte) i;
}
@Override // com.google.protobuf.CodedOutputStream
public final void writeFixed32NoTag(int i) throws IOException {
try {
byte[] bArr = this.buffer;
int i2 = this.position;
bArr[i2] = (byte) (i & 255);
bArr[i2 + 1] = (byte) ((i >> 8) & 255);
bArr[i2 + 2] = (byte) ((i >> 16) & 255);
this.position = i2 + 4;
bArr[i2 + 3] = (byte) ((i >> 24) & 255);
} catch (IndexOutOfBoundsException e) {
throw new OutOfSpaceException(String.format("Pos: %d, limit: %d, len: %d", Integer.valueOf(this.position), Integer.valueOf(this.limit), 1), e);
}
}
@Override // com.google.protobuf.CodedOutputStream
public final void writeUInt64NoTag(long j) throws IOException {
if (CodedOutputStream.HAS_UNSAFE_ARRAY_OPERATIONS && spaceLeft() >= 10) {
while ((j & (-128)) != 0) {
byte[] bArr = this.buffer;
int i = this.position;
this.position = i + 1;
UnsafeUtil.putByte(bArr, i, (byte) ((((int) j) & 127) | 128));
j >>>= 7;
}
byte[] bArr2 = this.buffer;
int i2 = this.position;
this.position = i2 + 1;
UnsafeUtil.putByte(bArr2, i2, (byte) j);
return;
}
while ((j & (-128)) != 0) {
try {
byte[] bArr3 = this.buffer;
int i3 = this.position;
this.position = i3 + 1;
bArr3[i3] = (byte) ((((int) j) & 127) | 128);
j >>>= 7;
} catch (IndexOutOfBoundsException e) {
throw new OutOfSpaceException(String.format("Pos: %d, limit: %d, len: %d", Integer.valueOf(this.position), Integer.valueOf(this.limit), 1), e);
}
}
byte[] bArr4 = this.buffer;
int i4 = this.position;
this.position = i4 + 1;
bArr4[i4] = (byte) j;
}
@Override // com.google.protobuf.CodedOutputStream
public final void writeFixed64NoTag(long j) throws IOException {
try {
byte[] bArr = this.buffer;
int i = this.position;
bArr[i] = (byte) (((int) j) & 255);
bArr[i + 1] = (byte) (((int) (j >> 8)) & 255);
bArr[i + 2] = (byte) (((int) (j >> 16)) & 255);
bArr[i + 3] = (byte) (((int) (j >> 24)) & 255);
bArr[i + 4] = (byte) (((int) (j >> 32)) & 255);
bArr[i + 5] = (byte) (((int) (j >> 40)) & 255);
bArr[i + 6] = (byte) (((int) (j >> 48)) & 255);
this.position = i + 8;
bArr[i + 7] = (byte) (((int) (j >> 56)) & 255);
} catch (IndexOutOfBoundsException e) {
throw new OutOfSpaceException(String.format("Pos: %d, limit: %d, len: %d", Integer.valueOf(this.position), Integer.valueOf(this.limit), 1), e);
}
}
@Override // com.google.protobuf.CodedOutputStream, com.google.protobuf.ByteOutput
public final void write(byte[] bArr, int i, int i2) throws IOException {
try {
System.arraycopy(bArr, i, this.buffer, this.position, i2);
this.position += i2;
} catch (IndexOutOfBoundsException e) {
throw new OutOfSpaceException(String.format("Pos: %d, limit: %d, len: %d", Integer.valueOf(this.position), Integer.valueOf(this.limit), Integer.valueOf(i2)), e);
}
}
@Override // com.google.protobuf.CodedOutputStream, com.google.protobuf.ByteOutput
public final void writeLazy(byte[] bArr, int i, int i2) throws IOException {
write(bArr, i, i2);
}
@Override // com.google.protobuf.CodedOutputStream, com.google.protobuf.ByteOutput
public final void write(ByteBuffer byteBuffer) throws IOException {
int remaining = byteBuffer.remaining();
try {
byteBuffer.get(this.buffer, this.position, remaining);
this.position += remaining;
} catch (IndexOutOfBoundsException e) {
throw new OutOfSpaceException(String.format("Pos: %d, limit: %d, len: %d", Integer.valueOf(this.position), Integer.valueOf(this.limit), Integer.valueOf(remaining)), e);
}
}
@Override // com.google.protobuf.CodedOutputStream, com.google.protobuf.ByteOutput
public final void writeLazy(ByteBuffer byteBuffer) throws IOException {
write(byteBuffer);
}
@Override // com.google.protobuf.CodedOutputStream
public final void writeStringNoTag(String str) throws IOException {
int i = this.position;
try {
int computeUInt32SizeNoTag = CodedOutputStream.computeUInt32SizeNoTag(str.length() * 3);
int computeUInt32SizeNoTag2 = CodedOutputStream.computeUInt32SizeNoTag(str.length());
if (computeUInt32SizeNoTag2 == computeUInt32SizeNoTag) {
int i2 = i + computeUInt32SizeNoTag2;
this.position = i2;
int encode = Utf8.encode(str, this.buffer, i2, spaceLeft());
this.position = i;
writeUInt32NoTag((encode - i) - computeUInt32SizeNoTag2);
this.position = encode;
} else {
writeUInt32NoTag(Utf8.encodedLength(str));
this.position = Utf8.encode(str, this.buffer, this.position, spaceLeft());
}
} catch (Utf8.UnpairedSurrogateException e) {
this.position = i;
inefficientWriteStringNoTag(str, e);
} catch (IndexOutOfBoundsException e2) {
throw new OutOfSpaceException(e2);
}
}
}
public static final class HeapNioEncoder extends ArrayEncoder {
private final ByteBuffer byteBuffer;
private int initialPosition;
public HeapNioEncoder(ByteBuffer byteBuffer) {
super(byteBuffer.array(), byteBuffer.arrayOffset() + byteBuffer.position(), byteBuffer.remaining());
this.byteBuffer = byteBuffer;
this.initialPosition = byteBuffer.position();
}
@Override // com.google.protobuf.CodedOutputStream.ArrayEncoder, com.google.protobuf.CodedOutputStream
public void flush() {
}
}
public static final class SafeDirectNioEncoder extends CodedOutputStream {
private final ByteBuffer buffer;
private final int initialPosition;
private final ByteBuffer originalBuffer;
public SafeDirectNioEncoder(ByteBuffer byteBuffer) {
super();
this.originalBuffer = byteBuffer;
this.buffer = byteBuffer.duplicate().order(ByteOrder.LITTLE_ENDIAN);
this.initialPosition = byteBuffer.position();
}
@Override // com.google.protobuf.CodedOutputStream
public void writeTag(int i, int i2) throws IOException {
writeUInt32NoTag(WireFormat.makeTag(i, i2));
}
@Override // com.google.protobuf.CodedOutputStream
public void writeInt32(int i, int i2) throws IOException {
writeTag(i, 0);
writeInt32NoTag(i2);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeUInt32(int i, int i2) throws IOException {
writeTag(i, 0);
writeUInt32NoTag(i2);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeFixed32(int i, int i2) throws IOException {
writeTag(i, 5);
writeFixed32NoTag(i2);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeUInt64(int i, long j) throws IOException {
writeTag(i, 0);
writeUInt64NoTag(j);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeFixed64(int i, long j) throws IOException {
writeTag(i, 1);
writeFixed64NoTag(j);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeBool(int i, boolean z) throws IOException {
writeTag(i, 0);
write(z ? (byte) 1 : (byte) 0);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeString(int i, String str) throws IOException {
writeTag(i, 2);
writeStringNoTag(str);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeBytes(int i, ByteString byteString) throws IOException {
writeTag(i, 2);
writeBytesNoTag(byteString);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeByteArray(int i, byte[] bArr) throws IOException {
writeByteArray(i, bArr, 0, bArr.length);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeByteArray(int i, byte[] bArr, int i2, int i3) throws IOException {
writeTag(i, 2);
writeByteArrayNoTag(bArr, i2, i3);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeByteBuffer(int i, ByteBuffer byteBuffer) throws IOException {
writeTag(i, 2);
writeUInt32NoTag(byteBuffer.capacity());
writeRawBytes(byteBuffer);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeMessage(int i, MessageLite messageLite) throws IOException {
writeTag(i, 2);
writeMessageNoTag(messageLite);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeMessage(int i, MessageLite messageLite, Schema schema) throws IOException {
writeTag(i, 2);
writeMessageNoTag(messageLite, schema);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeMessageSetExtension(int i, MessageLite messageLite) throws IOException {
writeTag(1, 3);
writeUInt32(2, i);
writeMessage(3, messageLite);
writeTag(1, 4);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeRawMessageSetExtension(int i, ByteString byteString) throws IOException {
writeTag(1, 3);
writeUInt32(2, i);
writeBytes(3, byteString);
writeTag(1, 4);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeMessageNoTag(MessageLite messageLite) throws IOException {
writeUInt32NoTag(messageLite.getSerializedSize());
messageLite.writeTo(this);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeMessageNoTag(MessageLite messageLite, Schema schema) throws IOException {
writeUInt32NoTag(((AbstractMessageLite) messageLite).getSerializedSize(schema));
schema.writeTo(messageLite, this.wrapper);
}
@Override // com.google.protobuf.CodedOutputStream, com.google.protobuf.ByteOutput
public void write(byte b) throws IOException {
try {
this.buffer.put(b);
} catch (BufferOverflowException e) {
throw new OutOfSpaceException(e);
}
}
@Override // com.google.protobuf.CodedOutputStream
public void writeBytesNoTag(ByteString byteString) throws IOException {
writeUInt32NoTag(byteString.size());
byteString.writeTo(this);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeByteArrayNoTag(byte[] bArr, int i, int i2) throws IOException {
writeUInt32NoTag(i2);
write(bArr, i, i2);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeRawBytes(ByteBuffer byteBuffer) throws IOException {
if (byteBuffer.hasArray()) {
write(byteBuffer.array(), byteBuffer.arrayOffset(), byteBuffer.capacity());
return;
}
ByteBuffer duplicate = byteBuffer.duplicate();
write(duplicate);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeInt32NoTag(int i) throws IOException {
if (i >= 0) {
writeUInt32NoTag(i);
} else {
writeUInt64NoTag(i);
}
}
@Override // com.google.protobuf.CodedOutputStream
public void writeUInt32NoTag(int i) throws IOException {
while ((i & WorkInfo.STOP_REASON_FOREGROUND_SERVICE_TIMEOUT) != 0) {
try {
this.buffer.put((byte) ((i & 127) | 128));
i >>>= 7;
} catch (BufferOverflowException e) {
throw new OutOfSpaceException(e);
}
}
this.buffer.put((byte) i);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeFixed32NoTag(int i) throws IOException {
try {
this.buffer.putInt(i);
} catch (BufferOverflowException e) {
throw new OutOfSpaceException(e);
}
}
@Override // com.google.protobuf.CodedOutputStream
public void writeUInt64NoTag(long j) throws IOException {
while (((-128) & j) != 0) {
try {
this.buffer.put((byte) ((((int) j) & 127) | 128));
j >>>= 7;
} catch (BufferOverflowException e) {
throw new OutOfSpaceException(e);
}
}
this.buffer.put((byte) j);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeFixed64NoTag(long j) throws IOException {
try {
this.buffer.putLong(j);
} catch (BufferOverflowException e) {
throw new OutOfSpaceException(e);
}
}
@Override // com.google.protobuf.CodedOutputStream, com.google.protobuf.ByteOutput
public void write(byte[] bArr, int i, int i2) throws IOException {
try {
this.buffer.put(bArr, i, i2);
} catch (IndexOutOfBoundsException e) {
throw new OutOfSpaceException(e);
} catch (BufferOverflowException e2) {
throw new OutOfSpaceException(e2);
}
}
@Override // com.google.protobuf.CodedOutputStream, com.google.protobuf.ByteOutput
public void writeLazy(byte[] bArr, int i, int i2) throws IOException {
write(bArr, i, i2);
}
@Override // com.google.protobuf.CodedOutputStream, com.google.protobuf.ByteOutput
public void write(ByteBuffer byteBuffer) throws IOException {
try {
this.buffer.put(byteBuffer);
} catch (BufferOverflowException e) {
throw new OutOfSpaceException(e);
}
}
@Override // com.google.protobuf.CodedOutputStream, com.google.protobuf.ByteOutput
public void writeLazy(ByteBuffer byteBuffer) throws IOException {
write(byteBuffer);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeStringNoTag(String str) throws IOException {
int position = this.buffer.position();
try {
int computeUInt32SizeNoTag = CodedOutputStream.computeUInt32SizeNoTag(str.length() * 3);
int computeUInt32SizeNoTag2 = CodedOutputStream.computeUInt32SizeNoTag(str.length());
if (computeUInt32SizeNoTag2 == computeUInt32SizeNoTag) {
int position2 = this.buffer.position() + computeUInt32SizeNoTag2;
encode(str);
int position3 = this.buffer.position();
writeUInt32NoTag(position3 - position2);
} else {
writeUInt32NoTag(Utf8.encodedLength(str));
encode(str);
}
} catch (Utf8.UnpairedSurrogateException e) {
inefficientWriteStringNoTag(str, e);
} catch (IllegalArgumentException e2) {
throw new OutOfSpaceException(e2);
}
}
@Override // com.google.protobuf.CodedOutputStream
public void flush() {
}
@Override // com.google.protobuf.CodedOutputStream
public int spaceLeft() {
return this.buffer.remaining();
}
@Override // com.google.protobuf.CodedOutputStream
public int getTotalBytesWritten() {
return this.buffer.position() - this.initialPosition;
}
private void encode(String str) throws IOException {
try {
Utf8.encodeUtf8(str, this.buffer);
} catch (IndexOutOfBoundsException e) {
throw new OutOfSpaceException(e);
}
}
}
public static final class UnsafeDirectNioEncoder extends CodedOutputStream {
private final long address;
private final ByteBuffer buffer;
private final long initialPosition;
private final long limit;
private final long oneVarintLimit;
private final ByteBuffer originalBuffer;
private long position;
private int bufferPos(long j) {
return (int) (j - this.address);
}
@Override // com.google.protobuf.CodedOutputStream
public int getTotalBytesWritten() {
return (int) (this.position - this.initialPosition);
}
@Override // com.google.protobuf.CodedOutputStream
public int spaceLeft() {
return (int) (this.limit - this.position);
}
public UnsafeDirectNioEncoder(ByteBuffer byteBuffer) {
super();
this.originalBuffer = byteBuffer;
this.buffer = byteBuffer.duplicate().order(ByteOrder.LITTLE_ENDIAN);
long addressOffset = UnsafeUtil.addressOffset(byteBuffer);
this.address = addressOffset;
long position = byteBuffer.position() + addressOffset;
this.initialPosition = position;
long limit = addressOffset + byteBuffer.limit();
this.limit = limit;
this.oneVarintLimit = limit - 10;
this.position = position;
}
public static boolean isSupported() {
return UnsafeUtil.hasUnsafeByteBufferOperations();
}
@Override // com.google.protobuf.CodedOutputStream
public void writeTag(int i, int i2) throws IOException {
writeUInt32NoTag(WireFormat.makeTag(i, i2));
}
@Override // com.google.protobuf.CodedOutputStream
public void writeInt32(int i, int i2) throws IOException {
writeTag(i, 0);
writeInt32NoTag(i2);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeUInt32(int i, int i2) throws IOException {
writeTag(i, 0);
writeUInt32NoTag(i2);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeFixed32(int i, int i2) throws IOException {
writeTag(i, 5);
writeFixed32NoTag(i2);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeUInt64(int i, long j) throws IOException {
writeTag(i, 0);
writeUInt64NoTag(j);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeFixed64(int i, long j) throws IOException {
writeTag(i, 1);
writeFixed64NoTag(j);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeBool(int i, boolean z) throws IOException {
writeTag(i, 0);
write(z ? (byte) 1 : (byte) 0);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeString(int i, String str) throws IOException {
writeTag(i, 2);
writeStringNoTag(str);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeBytes(int i, ByteString byteString) throws IOException {
writeTag(i, 2);
writeBytesNoTag(byteString);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeByteArray(int i, byte[] bArr) throws IOException {
writeByteArray(i, bArr, 0, bArr.length);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeByteArray(int i, byte[] bArr, int i2, int i3) throws IOException {
writeTag(i, 2);
writeByteArrayNoTag(bArr, i2, i3);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeByteBuffer(int i, ByteBuffer byteBuffer) throws IOException {
writeTag(i, 2);
writeUInt32NoTag(byteBuffer.capacity());
writeRawBytes(byteBuffer);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeMessage(int i, MessageLite messageLite) throws IOException {
writeTag(i, 2);
writeMessageNoTag(messageLite);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeMessage(int i, MessageLite messageLite, Schema schema) throws IOException {
writeTag(i, 2);
writeMessageNoTag(messageLite, schema);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeMessageSetExtension(int i, MessageLite messageLite) throws IOException {
writeTag(1, 3);
writeUInt32(2, i);
writeMessage(3, messageLite);
writeTag(1, 4);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeRawMessageSetExtension(int i, ByteString byteString) throws IOException {
writeTag(1, 3);
writeUInt32(2, i);
writeBytes(3, byteString);
writeTag(1, 4);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeMessageNoTag(MessageLite messageLite) throws IOException {
writeUInt32NoTag(messageLite.getSerializedSize());
messageLite.writeTo(this);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeMessageNoTag(MessageLite messageLite, Schema schema) throws IOException {
writeUInt32NoTag(((AbstractMessageLite) messageLite).getSerializedSize(schema));
schema.writeTo(messageLite, this.wrapper);
}
@Override // com.google.protobuf.CodedOutputStream, com.google.protobuf.ByteOutput
public void write(byte b) throws IOException {
long j = this.position;
if (j >= this.limit) {
throw new OutOfSpaceException(String.format("Pos: %d, limit: %d, len: %d", Long.valueOf(this.position), Long.valueOf(this.limit), 1));
}
this.position = 1 + j;
UnsafeUtil.putByte(j, b);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeBytesNoTag(ByteString byteString) throws IOException {
writeUInt32NoTag(byteString.size());
byteString.writeTo(this);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeByteArrayNoTag(byte[] bArr, int i, int i2) throws IOException {
writeUInt32NoTag(i2);
write(bArr, i, i2);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeRawBytes(ByteBuffer byteBuffer) throws IOException {
if (byteBuffer.hasArray()) {
write(byteBuffer.array(), byteBuffer.arrayOffset(), byteBuffer.capacity());
return;
}
ByteBuffer duplicate = byteBuffer.duplicate();
write(duplicate);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeInt32NoTag(int i) throws IOException {
if (i >= 0) {
writeUInt32NoTag(i);
} else {
writeUInt64NoTag(i);
}
}
@Override // com.google.protobuf.CodedOutputStream
public void writeUInt32NoTag(int i) throws IOException {
if (this.position <= this.oneVarintLimit) {
while ((i & WorkInfo.STOP_REASON_FOREGROUND_SERVICE_TIMEOUT) != 0) {
long j = this.position;
this.position = j + 1;
UnsafeUtil.putByte(j, (byte) ((i & 127) | 128));
i >>>= 7;
}
long j2 = this.position;
this.position = 1 + j2;
UnsafeUtil.putByte(j2, (byte) i);
return;
}
while (true) {
long j3 = this.position;
if (j3 >= this.limit) {
throw new OutOfSpaceException(String.format("Pos: %d, limit: %d, len: %d", Long.valueOf(this.position), Long.valueOf(this.limit), 1));
}
if ((i & WorkInfo.STOP_REASON_FOREGROUND_SERVICE_TIMEOUT) == 0) {
this.position = 1 + j3;
UnsafeUtil.putByte(j3, (byte) i);
return;
} else {
this.position = j3 + 1;
UnsafeUtil.putByte(j3, (byte) ((i & 127) | 128));
i >>>= 7;
}
}
}
@Override // com.google.protobuf.CodedOutputStream
public void writeFixed32NoTag(int i) throws IOException {
this.buffer.putInt(bufferPos(this.position), i);
this.position += 4;
}
@Override // com.google.protobuf.CodedOutputStream
public void writeUInt64NoTag(long j) throws IOException {
if (this.position <= this.oneVarintLimit) {
while ((j & (-128)) != 0) {
long j2 = this.position;
this.position = j2 + 1;
UnsafeUtil.putByte(j2, (byte) ((((int) j) & 127) | 128));
j >>>= 7;
}
long j3 = this.position;
this.position = 1 + j3;
UnsafeUtil.putByte(j3, (byte) j);
return;
}
while (true) {
long j4 = this.position;
if (j4 >= this.limit) {
throw new OutOfSpaceException(String.format("Pos: %d, limit: %d, len: %d", Long.valueOf(this.position), Long.valueOf(this.limit), 1));
}
if ((j & (-128)) == 0) {
this.position = 1 + j4;
UnsafeUtil.putByte(j4, (byte) j);
return;
} else {
this.position = j4 + 1;
UnsafeUtil.putByte(j4, (byte) ((((int) j) & 127) | 128));
j >>>= 7;
}
}
}
@Override // com.google.protobuf.CodedOutputStream
public void writeFixed64NoTag(long j) throws IOException {
this.buffer.putLong(bufferPos(this.position), j);
this.position += 8;
}
@Override // com.google.protobuf.CodedOutputStream, com.google.protobuf.ByteOutput
public void write(byte[] bArr, int i, int i2) throws IOException {
if (bArr != null && i >= 0 && i2 >= 0 && bArr.length - i2 >= i) {
long j = i2;
long j2 = this.limit - j;
long j3 = this.position;
if (j2 >= j3) {
UnsafeUtil.copyMemory(bArr, i, j3, j);
this.position += j;
return;
}
}
if (bArr == null) {
throw new NullPointerException("value");
}
throw new OutOfSpaceException(String.format("Pos: %d, limit: %d, len: %d", Long.valueOf(this.position), Long.valueOf(this.limit), Integer.valueOf(i2)));
}
@Override // com.google.protobuf.CodedOutputStream, com.google.protobuf.ByteOutput
public void writeLazy(byte[] bArr, int i, int i2) throws IOException {
write(bArr, i, i2);
}
@Override // com.google.protobuf.CodedOutputStream, com.google.protobuf.ByteOutput
public void write(ByteBuffer byteBuffer) throws IOException {
try {
int remaining = byteBuffer.remaining();
repositionBuffer(this.position);
this.buffer.put(byteBuffer);
this.position += remaining;
} catch (BufferOverflowException e) {
throw new OutOfSpaceException(e);
}
}
@Override // com.google.protobuf.CodedOutputStream, com.google.protobuf.ByteOutput
public void writeLazy(ByteBuffer byteBuffer) throws IOException {
write(byteBuffer);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeStringNoTag(String str) throws IOException {
long j = this.position;
try {
int computeUInt32SizeNoTag = CodedOutputStream.computeUInt32SizeNoTag(str.length() * 3);
int computeUInt32SizeNoTag2 = CodedOutputStream.computeUInt32SizeNoTag(str.length());
if (computeUInt32SizeNoTag2 == computeUInt32SizeNoTag) {
int bufferPos = bufferPos(this.position) + computeUInt32SizeNoTag2;
Utf8.encodeUtf8(str, this.buffer);
int position = this.buffer.position() - bufferPos;
writeUInt32NoTag(position);
this.position += position;
} else {
int encodedLength = Utf8.encodedLength(str);
writeUInt32NoTag(encodedLength);
repositionBuffer(this.position);
Utf8.encodeUtf8(str, this.buffer);
this.position += encodedLength;
}
} catch (Utf8.UnpairedSurrogateException e) {
this.position = j;
repositionBuffer(j);
inefficientWriteStringNoTag(str, e);
} catch (IllegalArgumentException e2) {
throw new OutOfSpaceException(e2);
} catch (IndexOutOfBoundsException e3) {
throw new OutOfSpaceException(e3);
}
}
@Override // com.google.protobuf.CodedOutputStream
public void flush() {
}
private void repositionBuffer(long j) {
}
}
public static abstract class AbstractBufferedEncoder extends CodedOutputStream {
final byte[] buffer;
final int limit;
int position;
int totalBytesWritten;
@Override // com.google.protobuf.CodedOutputStream
public final int getTotalBytesWritten() {
return this.totalBytesWritten;
}
public AbstractBufferedEncoder(int i) {
super();
if (i < 0) {
throw new IllegalArgumentException("bufferSize must be >= 0");
}
byte[] bArr = new byte[Math.max(i, 20)];
this.buffer = bArr;
this.limit = bArr.length;
}
@Override // com.google.protobuf.CodedOutputStream
public final int spaceLeft() {
throw new UnsupportedOperationException("spaceLeft() can only be called on CodedOutputStreams that are writing to a flat array or ByteBuffer.");
}
public final void buffer(byte b) {
byte[] bArr = this.buffer;
int i = this.position;
this.position = i + 1;
bArr[i] = b;
this.totalBytesWritten++;
}
public final void bufferTag(int i, int i2) {
bufferUInt32NoTag(WireFormat.makeTag(i, i2));
}
public final void bufferInt32NoTag(int i) {
if (i >= 0) {
bufferUInt32NoTag(i);
} else {
bufferUInt64NoTag(i);
}
}
public final void bufferUInt32NoTag(int i) {
if (CodedOutputStream.HAS_UNSAFE_ARRAY_OPERATIONS) {
long j = this.position;
while ((i & WorkInfo.STOP_REASON_FOREGROUND_SERVICE_TIMEOUT) != 0) {
byte[] bArr = this.buffer;
int i2 = this.position;
this.position = i2 + 1;
UnsafeUtil.putByte(bArr, i2, (byte) ((i & 127) | 128));
i >>>= 7;
}
byte[] bArr2 = this.buffer;
int i3 = this.position;
this.position = i3 + 1;
UnsafeUtil.putByte(bArr2, i3, (byte) i);
this.totalBytesWritten += (int) (this.position - j);
return;
}
while ((i & WorkInfo.STOP_REASON_FOREGROUND_SERVICE_TIMEOUT) != 0) {
byte[] bArr3 = this.buffer;
int i4 = this.position;
this.position = i4 + 1;
bArr3[i4] = (byte) ((i & 127) | 128);
this.totalBytesWritten++;
i >>>= 7;
}
byte[] bArr4 = this.buffer;
int i5 = this.position;
this.position = i5 + 1;
bArr4[i5] = (byte) i;
this.totalBytesWritten++;
}
public final void bufferUInt64NoTag(long j) {
if (CodedOutputStream.HAS_UNSAFE_ARRAY_OPERATIONS) {
long j2 = this.position;
while ((j & (-128)) != 0) {
byte[] bArr = this.buffer;
int i = this.position;
this.position = i + 1;
UnsafeUtil.putByte(bArr, i, (byte) ((((int) j) & 127) | 128));
j >>>= 7;
}
byte[] bArr2 = this.buffer;
int i2 = this.position;
this.position = i2 + 1;
UnsafeUtil.putByte(bArr2, i2, (byte) j);
this.totalBytesWritten += (int) (this.position - j2);
return;
}
while ((j & (-128)) != 0) {
byte[] bArr3 = this.buffer;
int i3 = this.position;
this.position = i3 + 1;
bArr3[i3] = (byte) ((((int) j) & 127) | 128);
this.totalBytesWritten++;
j >>>= 7;
}
byte[] bArr4 = this.buffer;
int i4 = this.position;
this.position = i4 + 1;
bArr4[i4] = (byte) j;
this.totalBytesWritten++;
}
public final void bufferFixed32NoTag(int i) {
byte[] bArr = this.buffer;
int i2 = this.position;
bArr[i2] = (byte) (i & 255);
bArr[i2 + 1] = (byte) ((i >> 8) & 255);
bArr[i2 + 2] = (byte) ((i >> 16) & 255);
this.position = i2 + 4;
bArr[i2 + 3] = (byte) ((i >> 24) & 255);
this.totalBytesWritten += 4;
}
public final void bufferFixed64NoTag(long j) {
byte[] bArr = this.buffer;
int i = this.position;
bArr[i] = (byte) (j & 255);
bArr[i + 1] = (byte) ((j >> 8) & 255);
bArr[i + 2] = (byte) ((j >> 16) & 255);
bArr[i + 3] = (byte) (255 & (j >> 24));
bArr[i + 4] = (byte) (((int) (j >> 32)) & 255);
bArr[i + 5] = (byte) (((int) (j >> 40)) & 255);
bArr[i + 6] = (byte) (((int) (j >> 48)) & 255);
this.position = i + 8;
bArr[i + 7] = (byte) (((int) (j >> 56)) & 255);
this.totalBytesWritten += 8;
}
}
public static final class ByteOutputEncoder extends AbstractBufferedEncoder {
private final ByteOutput out;
public ByteOutputEncoder(ByteOutput byteOutput, int i) {
super(i);
if (byteOutput == null) {
throw new NullPointerException("out");
}
this.out = byteOutput;
}
@Override // com.google.protobuf.CodedOutputStream
public void writeTag(int i, int i2) throws IOException {
writeUInt32NoTag(WireFormat.makeTag(i, i2));
}
@Override // com.google.protobuf.CodedOutputStream
public void writeInt32(int i, int i2) throws IOException {
flushIfNotAvailable(20);
bufferTag(i, 0);
bufferInt32NoTag(i2);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeUInt32(int i, int i2) throws IOException {
flushIfNotAvailable(20);
bufferTag(i, 0);
bufferUInt32NoTag(i2);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeFixed32(int i, int i2) throws IOException {
flushIfNotAvailable(14);
bufferTag(i, 5);
bufferFixed32NoTag(i2);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeUInt64(int i, long j) throws IOException {
flushIfNotAvailable(20);
bufferTag(i, 0);
bufferUInt64NoTag(j);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeFixed64(int i, long j) throws IOException {
flushIfNotAvailable(18);
bufferTag(i, 1);
bufferFixed64NoTag(j);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeBool(int i, boolean z) throws IOException {
flushIfNotAvailable(11);
bufferTag(i, 0);
buffer(z ? (byte) 1 : (byte) 0);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeString(int i, String str) throws IOException {
writeTag(i, 2);
writeStringNoTag(str);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeBytes(int i, ByteString byteString) throws IOException {
writeTag(i, 2);
writeBytesNoTag(byteString);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeByteArray(int i, byte[] bArr) throws IOException {
writeByteArray(i, bArr, 0, bArr.length);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeByteArray(int i, byte[] bArr, int i2, int i3) throws IOException {
writeTag(i, 2);
writeByteArrayNoTag(bArr, i2, i3);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeByteBuffer(int i, ByteBuffer byteBuffer) throws IOException {
writeTag(i, 2);
writeUInt32NoTag(byteBuffer.capacity());
writeRawBytes(byteBuffer);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeBytesNoTag(ByteString byteString) throws IOException {
writeUInt32NoTag(byteString.size());
byteString.writeTo(this);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeByteArrayNoTag(byte[] bArr, int i, int i2) throws IOException {
writeUInt32NoTag(i2);
write(bArr, i, i2);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeRawBytes(ByteBuffer byteBuffer) throws IOException {
if (byteBuffer.hasArray()) {
write(byteBuffer.array(), byteBuffer.arrayOffset(), byteBuffer.capacity());
return;
}
ByteBuffer duplicate = byteBuffer.duplicate();
write(duplicate);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeMessage(int i, MessageLite messageLite) throws IOException {
writeTag(i, 2);
writeMessageNoTag(messageLite);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeMessage(int i, MessageLite messageLite, Schema schema) throws IOException {
writeTag(i, 2);
writeMessageNoTag(messageLite, schema);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeMessageSetExtension(int i, MessageLite messageLite) throws IOException {
writeTag(1, 3);
writeUInt32(2, i);
writeMessage(3, messageLite);
writeTag(1, 4);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeRawMessageSetExtension(int i, ByteString byteString) throws IOException {
writeTag(1, 3);
writeUInt32(2, i);
writeBytes(3, byteString);
writeTag(1, 4);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeMessageNoTag(MessageLite messageLite) throws IOException {
writeUInt32NoTag(messageLite.getSerializedSize());
messageLite.writeTo(this);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeMessageNoTag(MessageLite messageLite, Schema schema) throws IOException {
writeUInt32NoTag(((AbstractMessageLite) messageLite).getSerializedSize(schema));
schema.writeTo(messageLite, this.wrapper);
}
@Override // com.google.protobuf.CodedOutputStream, com.google.protobuf.ByteOutput
public void write(byte b) throws IOException {
if (this.position == this.limit) {
doFlush();
}
buffer(b);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeInt32NoTag(int i) throws IOException {
if (i >= 0) {
writeUInt32NoTag(i);
} else {
writeUInt64NoTag(i);
}
}
@Override // com.google.protobuf.CodedOutputStream
public void writeUInt32NoTag(int i) throws IOException {
flushIfNotAvailable(5);
bufferUInt32NoTag(i);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeFixed32NoTag(int i) throws IOException {
flushIfNotAvailable(4);
bufferFixed32NoTag(i);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeUInt64NoTag(long j) throws IOException {
flushIfNotAvailable(10);
bufferUInt64NoTag(j);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeFixed64NoTag(long j) throws IOException {
flushIfNotAvailable(8);
bufferFixed64NoTag(j);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeStringNoTag(String str) throws IOException {
int length = str.length() * 3;
int computeUInt32SizeNoTag = CodedOutputStream.computeUInt32SizeNoTag(length);
int i = computeUInt32SizeNoTag + length;
int i2 = this.limit;
if (i > i2) {
byte[] bArr = new byte[length];
int encode = Utf8.encode(str, bArr, 0, length);
writeUInt32NoTag(encode);
writeLazy(bArr, 0, encode);
return;
}
if (i > i2 - this.position) {
doFlush();
}
int i3 = this.position;
try {
int computeUInt32SizeNoTag2 = CodedOutputStream.computeUInt32SizeNoTag(str.length());
if (computeUInt32SizeNoTag2 == computeUInt32SizeNoTag) {
int i4 = i3 + computeUInt32SizeNoTag2;
this.position = i4;
int encode2 = Utf8.encode(str, this.buffer, i4, this.limit - i4);
this.position = i3;
int i5 = (encode2 - i3) - computeUInt32SizeNoTag2;
bufferUInt32NoTag(i5);
this.position = encode2;
this.totalBytesWritten += i5;
} else {
int encodedLength = Utf8.encodedLength(str);
bufferUInt32NoTag(encodedLength);
this.position = Utf8.encode(str, this.buffer, this.position, encodedLength);
this.totalBytesWritten += encodedLength;
}
} catch (Utf8.UnpairedSurrogateException e) {
this.totalBytesWritten -= this.position - i3;
this.position = i3;
inefficientWriteStringNoTag(str, e);
} catch (IndexOutOfBoundsException e2) {
throw new OutOfSpaceException(e2);
}
}
@Override // com.google.protobuf.CodedOutputStream
public void flush() throws IOException {
if (this.position > 0) {
doFlush();
}
}
@Override // com.google.protobuf.CodedOutputStream, com.google.protobuf.ByteOutput
public void write(byte[] bArr, int i, int i2) throws IOException {
flush();
this.out.write(bArr, i, i2);
this.totalBytesWritten += i2;
}
@Override // com.google.protobuf.CodedOutputStream, com.google.protobuf.ByteOutput
public void writeLazy(byte[] bArr, int i, int i2) throws IOException {
flush();
this.out.writeLazy(bArr, i, i2);
this.totalBytesWritten += i2;
}
@Override // com.google.protobuf.CodedOutputStream, com.google.protobuf.ByteOutput
public void write(ByteBuffer byteBuffer) throws IOException {
flush();
int remaining = byteBuffer.remaining();
this.out.write(byteBuffer);
this.totalBytesWritten += remaining;
}
@Override // com.google.protobuf.CodedOutputStream, com.google.protobuf.ByteOutput
public void writeLazy(ByteBuffer byteBuffer) throws IOException {
flush();
int remaining = byteBuffer.remaining();
this.out.writeLazy(byteBuffer);
this.totalBytesWritten += remaining;
}
private void flushIfNotAvailable(int i) throws IOException {
if (this.limit - this.position < i) {
doFlush();
}
}
private void doFlush() throws IOException {
this.out.write(this.buffer, 0, this.position);
this.position = 0;
}
}
public static final class OutputStreamEncoder extends AbstractBufferedEncoder {
private final OutputStream out;
public OutputStreamEncoder(OutputStream outputStream, int i) {
super(i);
if (outputStream == null) {
throw new NullPointerException("out");
}
this.out = outputStream;
}
@Override // com.google.protobuf.CodedOutputStream
public void writeTag(int i, int i2) throws IOException {
writeUInt32NoTag(WireFormat.makeTag(i, i2));
}
@Override // com.google.protobuf.CodedOutputStream
public void writeInt32(int i, int i2) throws IOException {
flushIfNotAvailable(20);
bufferTag(i, 0);
bufferInt32NoTag(i2);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeUInt32(int i, int i2) throws IOException {
flushIfNotAvailable(20);
bufferTag(i, 0);
bufferUInt32NoTag(i2);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeFixed32(int i, int i2) throws IOException {
flushIfNotAvailable(14);
bufferTag(i, 5);
bufferFixed32NoTag(i2);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeUInt64(int i, long j) throws IOException {
flushIfNotAvailable(20);
bufferTag(i, 0);
bufferUInt64NoTag(j);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeFixed64(int i, long j) throws IOException {
flushIfNotAvailable(18);
bufferTag(i, 1);
bufferFixed64NoTag(j);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeBool(int i, boolean z) throws IOException {
flushIfNotAvailable(11);
bufferTag(i, 0);
buffer(z ? (byte) 1 : (byte) 0);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeString(int i, String str) throws IOException {
writeTag(i, 2);
writeStringNoTag(str);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeBytes(int i, ByteString byteString) throws IOException {
writeTag(i, 2);
writeBytesNoTag(byteString);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeByteArray(int i, byte[] bArr) throws IOException {
writeByteArray(i, bArr, 0, bArr.length);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeByteArray(int i, byte[] bArr, int i2, int i3) throws IOException {
writeTag(i, 2);
writeByteArrayNoTag(bArr, i2, i3);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeByteBuffer(int i, ByteBuffer byteBuffer) throws IOException {
writeTag(i, 2);
writeUInt32NoTag(byteBuffer.capacity());
writeRawBytes(byteBuffer);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeBytesNoTag(ByteString byteString) throws IOException {
writeUInt32NoTag(byteString.size());
byteString.writeTo(this);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeByteArrayNoTag(byte[] bArr, int i, int i2) throws IOException {
writeUInt32NoTag(i2);
write(bArr, i, i2);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeRawBytes(ByteBuffer byteBuffer) throws IOException {
if (byteBuffer.hasArray()) {
write(byteBuffer.array(), byteBuffer.arrayOffset(), byteBuffer.capacity());
return;
}
ByteBuffer duplicate = byteBuffer.duplicate();
write(duplicate);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeMessage(int i, MessageLite messageLite) throws IOException {
writeTag(i, 2);
writeMessageNoTag(messageLite);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeMessage(int i, MessageLite messageLite, Schema schema) throws IOException {
writeTag(i, 2);
writeMessageNoTag(messageLite, schema);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeMessageSetExtension(int i, MessageLite messageLite) throws IOException {
writeTag(1, 3);
writeUInt32(2, i);
writeMessage(3, messageLite);
writeTag(1, 4);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeRawMessageSetExtension(int i, ByteString byteString) throws IOException {
writeTag(1, 3);
writeUInt32(2, i);
writeBytes(3, byteString);
writeTag(1, 4);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeMessageNoTag(MessageLite messageLite) throws IOException {
writeUInt32NoTag(messageLite.getSerializedSize());
messageLite.writeTo(this);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeMessageNoTag(MessageLite messageLite, Schema schema) throws IOException {
writeUInt32NoTag(((AbstractMessageLite) messageLite).getSerializedSize(schema));
schema.writeTo(messageLite, this.wrapper);
}
@Override // com.google.protobuf.CodedOutputStream, com.google.protobuf.ByteOutput
public void write(byte b) throws IOException {
if (this.position == this.limit) {
doFlush();
}
buffer(b);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeInt32NoTag(int i) throws IOException {
if (i >= 0) {
writeUInt32NoTag(i);
} else {
writeUInt64NoTag(i);
}
}
@Override // com.google.protobuf.CodedOutputStream
public void writeUInt32NoTag(int i) throws IOException {
flushIfNotAvailable(5);
bufferUInt32NoTag(i);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeFixed32NoTag(int i) throws IOException {
flushIfNotAvailable(4);
bufferFixed32NoTag(i);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeUInt64NoTag(long j) throws IOException {
flushIfNotAvailable(10);
bufferUInt64NoTag(j);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeFixed64NoTag(long j) throws IOException {
flushIfNotAvailable(8);
bufferFixed64NoTag(j);
}
@Override // com.google.protobuf.CodedOutputStream
public void writeStringNoTag(String str) throws IOException {
int encodedLength;
try {
int length = str.length() * 3;
int computeUInt32SizeNoTag = CodedOutputStream.computeUInt32SizeNoTag(length);
int i = computeUInt32SizeNoTag + length;
int i2 = this.limit;
if (i > i2) {
byte[] bArr = new byte[length];
int encode = Utf8.encode(str, bArr, 0, length);
writeUInt32NoTag(encode);
writeLazy(bArr, 0, encode);
return;
}
if (i > i2 - this.position) {
doFlush();
}
int computeUInt32SizeNoTag2 = CodedOutputStream.computeUInt32SizeNoTag(str.length());
int i3 = this.position;
try {
if (computeUInt32SizeNoTag2 == computeUInt32SizeNoTag) {
int i4 = i3 + computeUInt32SizeNoTag2;
this.position = i4;
int encode2 = Utf8.encode(str, this.buffer, i4, this.limit - i4);
this.position = i3;
encodedLength = (encode2 - i3) - computeUInt32SizeNoTag2;
bufferUInt32NoTag(encodedLength);
this.position = encode2;
} else {
encodedLength = Utf8.encodedLength(str);
bufferUInt32NoTag(encodedLength);
this.position = Utf8.encode(str, this.buffer, this.position, encodedLength);
}
this.totalBytesWritten += encodedLength;
} catch (Utf8.UnpairedSurrogateException e) {
this.totalBytesWritten -= this.position - i3;
this.position = i3;
throw e;
} catch (ArrayIndexOutOfBoundsException e2) {
throw new OutOfSpaceException(e2);
}
} catch (Utf8.UnpairedSurrogateException e3) {
inefficientWriteStringNoTag(str, e3);
}
}
@Override // com.google.protobuf.CodedOutputStream
public void flush() throws IOException {
if (this.position > 0) {
doFlush();
}
}
@Override // com.google.protobuf.CodedOutputStream, com.google.protobuf.ByteOutput
public void write(byte[] bArr, int i, int i2) throws IOException {
int i3 = this.limit;
int i4 = this.position;
if (i3 - i4 >= i2) {
System.arraycopy(bArr, i, this.buffer, i4, i2);
this.position += i2;
this.totalBytesWritten += i2;
return;
}
int i5 = i3 - i4;
System.arraycopy(bArr, i, this.buffer, i4, i5);
int i6 = i + i5;
int i7 = i2 - i5;
this.position = this.limit;
this.totalBytesWritten += i5;
doFlush();
if (i7 <= this.limit) {
System.arraycopy(bArr, i6, this.buffer, 0, i7);
this.position = i7;
} else {
this.out.write(bArr, i6, i7);
}
this.totalBytesWritten += i7;
}
@Override // com.google.protobuf.CodedOutputStream, com.google.protobuf.ByteOutput
public void writeLazy(byte[] bArr, int i, int i2) throws IOException {
write(bArr, i, i2);
}
@Override // com.google.protobuf.CodedOutputStream, com.google.protobuf.ByteOutput
public void write(ByteBuffer byteBuffer) throws IOException {
int remaining = byteBuffer.remaining();
int i = this.limit;
int i2 = this.position;
if (i - i2 >= remaining) {
byteBuffer.get(this.buffer, i2, remaining);
this.position += remaining;
this.totalBytesWritten += remaining;
return;
}
int i3 = i - i2;
byteBuffer.get(this.buffer, i2, i3);
int i4 = remaining - i3;
this.position = this.limit;
this.totalBytesWritten += i3;
doFlush();
while (true) {
int i5 = this.limit;
if (i4 > i5) {
byteBuffer.get(this.buffer, 0, i5);
this.out.write(this.buffer, 0, this.limit);
int i6 = this.limit;
i4 -= i6;
this.totalBytesWritten += i6;
} else {
byteBuffer.get(this.buffer, 0, i4);
this.position = i4;
this.totalBytesWritten += i4;
return;
}
}
}
@Override // com.google.protobuf.CodedOutputStream, com.google.protobuf.ByteOutput
public void writeLazy(ByteBuffer byteBuffer) throws IOException {
write(byteBuffer);
}
private void flushIfNotAvailable(int i) throws IOException {
if (this.limit - this.position < i) {
doFlush();
}
}
private void doFlush() throws IOException {
this.out.write(this.buffer, 0, this.position);
this.position = 0;
}
}
}