/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  org.apache.tomcat.util.net.NioChannel
 *  org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper
 *  org.apache.tomcat.util.net.SocketBufferHandler
 */
package com.l7tech.server.tomcat.nio;

import com.l7tech.server.tomcat.TraceChannel;
import com.l7tech.server.tomcat.nio.SsgNioEndpoint;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.SocketChannel;
import org.apache.tomcat.util.net.NioChannel;
import org.apache.tomcat.util.net.NioEndpoint;
import org.apache.tomcat.util.net.SocketBufferHandler;

class a
extends NioChannel {
    private TraceChannel a;
    private TraceChannel b;
    private static final String[] c;

    a(SsgNioEndpoint ssgNioEndpoint, SocketBufferHandler socketBufferHandler) {
        super(socketBufferHandler);
    }

    public void reset(SocketChannel socketChannel, NioEndpoint.NioSocketWrapper nioSocketWrapper) throws IOException {
        super.reset(socketChannel, nioSocketWrapper);
        String[] stringArray = c;
        this.a = new TraceChannel(stringArray[0], false);
        this.b = new TraceChannel(stringArray[1], false);
    }

    public void close() throws IOException {
        this.a.close();
        this.b.close();
        super.close();
    }

    public int read(ByteBuffer byteBuffer) throws IOException {
        return this.a.trace(byteBuffer, byteBuffer.position(), super.read(byteBuffer));
    }

    public long read(ByteBuffer[] byteBufferArray) throws IOException {
        return this.read(byteBufferArray, 0, byteBufferArray.length);
    }

    public long read(ByteBuffer[] byteBufferArray, int n2, int n3) throws IOException {
        try {
            if (this.a.traceEnabled()) {
                return this.a.trace(byteBufferArray, n2, n3, this.a.positions(byteBufferArray), super.read(byteBufferArray, n2, n3));
            }
        }
        catch (IOException iOException) {
            throw com.l7tech.server.tomcat.nio.a.a(iOException);
        }
        return super.read(byteBufferArray, n2, n3);
    }

    public int write(ByteBuffer byteBuffer) throws IOException {
        return this.b.trace(byteBuffer, byteBuffer.position(), super.write(byteBuffer));
    }

    public long write(ByteBuffer[] byteBufferArray) throws IOException {
        return this.write(byteBufferArray, 0, byteBufferArray.length);
    }

    public long write(ByteBuffer[] byteBufferArray, int n2, int n3) throws IOException {
        try {
            if (this.b.traceEnabled()) {
                return this.b.trace(byteBufferArray, n2, n3, this.b.positions(byteBufferArray), super.write(byteBufferArray, n2, n3));
            }
        }
        catch (IOException iOException) {
            throw com.l7tech.server.tomcat.nio.a.a(iOException);
        }
        return super.write(byteBufferArray, n2, n3);
    }

    private static IOException a(IOException iOException) {
        return iOException;
    }

    /*
     * Enabled aggressive block sorting
     */
    static {
        String[] stringArray = new String[2];
        int n2 = 0;
        String string = "4\u0003^ o\u0004\u000eV\t4\u0003^ o\u0002\u0015(}";
        int n3 = "4\u0003^ o\u0004\u000eV\t4\u0003^ o\u0002\u0015(}".length();
        int n4 = 8;
        int n5 = -1;
        while (true) {
            int n6 = ++n5;
            stringArray[n2++] = com.l7tech.server.tomcat.nio.a.a(57, com.l7tech.server.tomcat.nio.a.a(string.substring(n6, n6 + n4)));
            if ((n5 += n4) >= n3) {
                c = stringArray;
                return;
            }
            n4 = string.charAt(n5);
        }
    }

    private static char[] a(String string) {
        char[] cArray = string.toCharArray();
        if (cArray.length < 2) {
            cArray = cArray;
            cArray[0] = (char)(cArray[0] ^ 0x59);
        }
        return cArray;
    }

    /*
     * Handled impossible loop by duplicating code
     * Enabled aggressive block sorting
     */
    private static String a(int n2, char[] cArray) {
        char[] cArray2;
        block11: {
            int n3;
            int n4;
            int n5;
            block10: {
                n5 = n2;
                cArray2 = cArray;
                n4 = cArray.length;
                n3 = 0;
                if (!true) break block10;
                n4 = n4;
                if (n4 <= n3) break block11;
            }
            do {
                n5 = n5;
                cArray2 = cArray2;
                int n6 = n3;
                cArray2[n6] = (char)(cArray2[n6] ^ (n5 ^ (switch (n3 % 7) {
                    case 0 -> 101;
                    case 1 -> 78;
                    case 2 -> 19;
                    case 3 -> 105;
                    case 4 -> 123;
                    case 5 -> 84;
                    default -> 89;
                })));
                ++n3;
                n4 = n4;
            } while (n4 > n3);
        }
        return new String(cArray2).intern();
    }
}

