package io.netty.handler.codec.xml;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageDecoder;
import io.netty.handler.codec.CorruptedFrameException;
import io.netty.handler.codec.TooLongFrameException;

/* JADX INFO: loaded from: classes.dex */
public class XmlFrameDecoder extends ByteToMessageDecoder {
    private final int maxFrameLength;

    public XmlFrameDecoder(int i2) {
        if (i2 < 1) {
            throw new IllegalArgumentException("maxFrameLength must be a positive int");
        }
        this.maxFrameLength = i2;
    }

    private static ByteBuf extractFrame(ByteBuf byteBuf, int i2, int i3) {
        return byteBuf.copy(i2, i3);
    }

    private void fail(long j2) {
        if (j2 <= 0) {
            throw new TooLongFrameException("frame length exceeds " + this.maxFrameLength + " - discarding");
        }
        throw new TooLongFrameException("frame length exceeds " + this.maxFrameLength + ": " + j2 + " - discarded");
    }

    private static boolean isCDATABlockStart(ByteBuf byteBuf, int i2) {
        return i2 < byteBuf.writerIndex() + (-8) && byteBuf.getByte(i2 + 2) == 91 && byteBuf.getByte(i2 + 3) == 67 && byteBuf.getByte(i2 + 4) == 68 && byteBuf.getByte(i2 + 5) == 65 && byteBuf.getByte(i2 + 6) == 84 && byteBuf.getByte(i2 + 7) == 65 && byteBuf.getByte(i2 + 8) == 91;
    }

    private static boolean isCommentBlockStart(ByteBuf byteBuf, int i2) {
        return i2 < byteBuf.writerIndex() + (-3) && byteBuf.getByte(i2 + 2) == 45 && byteBuf.getByte(i2 + 3) == 45;
    }

    private static boolean isValidStartCharForXmlElement(byte b) {
        return (b >= 97 && b <= 122) || (b >= 65 && b <= 90) || b == 58 || b == 95;
    }

    /* JADX WARN: Removed duplicated region for block: B:43:0x008f  */
    @Override // io.netty.handler.codec.ByteToMessageDecoder
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    protected void decode(io.netty.channel.ChannelHandlerContext r20, io.netty.buffer.ByteBuf r21, java.util.List<java.lang.Object> r22) throws java.lang.Exception {
        /*
            Method dump skipped, instruction units count: 268
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: io.netty.handler.codec.xml.XmlFrameDecoder.decode(io.netty.channel.ChannelHandlerContext, io.netty.buffer.ByteBuf, java.util.List):void");
    }

    private static void fail(ChannelHandlerContext channelHandlerContext) {
        channelHandlerContext.fireExceptionCaught((Throwable) new CorruptedFrameException("frame contains content before the xml starts"));
    }
}
