package TX_OtherClass;


import java.io.UnsupportedEncodingException;
import java.lang.reflect.Array;
import java.nio.BufferUnderflowException;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;
import java.util.Map;

import okhttp3.internal.http2.ErrorCode;

public final class c {
    protected String a = "GBK";
    private ByteBuffer b;

    public static class a {
        public byte a;
        public int b;
    }

    public c(byte[] bArr) {
        this.b = ByteBuffer.wrap(bArr);
    }

    private static int a(a arg2, ByteBuffer arg3) {
        int v0 = arg3.get();
        arg2.a = ((byte)(v0 & 15));
        arg2.b = (v0 & 240) >> 4;
        if(arg2.b == 15) {
            arg2.b = arg3.get() & 255;
            v0 = 2;
        }
        else {
            v0 = 1;
        }

        return v0;
    }

    private void a(a aVar) {
        a(aVar, this.b);
    }

    private void a(int i) {
        this.b.position(this.b.position() + i);
    }

    private boolean b(int arg6) {
        int v4 = 11;
        boolean v0 = false;
        try {
            a v1_2 = new a();
            while(true) {
                int v2 = c.a(v1_2, this.b.duplicate());
                if(arg6 > v1_2.b && v1_2.a != v4) {
                    this.a(v2);
                    this.a(v1_2.a);
                    continue;
                }

                break;
            }

            if(v1_2.a == v4) {
                return v0;
            }

            if(arg6 != v1_2.b) {
                return v0;
            }

            return true;
        }
        catch(BufferUnderflowException v1) {
            return v0;
        }

    }

    private void a() {
        a aVar = new a();
        do {
            a(aVar);
            a(aVar.a);
        } while (aVar.a != (byte) 11);
    }

    private void b() {
        a aVar = new a();
        a(aVar);
        a(aVar.a);
    }

    private void a(byte b) {
        int i = 0;
        int a;
        switch (b) {
            case (byte) 0:
                a(1);
                return;
            case (byte) 1:
                a(2);
                return;
            case (byte) 2:
                a(4);
                return;
            case (byte) 3:
                a(8);
                return;
            case (byte) 4:
                a(4);
                return;
            case (byte) 5:
                a(8);
                return;
            case (byte) 6:
                i = this.b.get();
                if (i < 0) {
                    i += 256;
                }
                a(i);
                return;
            case (byte) 7:
                a(this.b.getInt());
                return;
            case (byte) 8:
                a = a(0, 0, true);
                while (i < a * 2) {
                    b();
                    i++;
                }
                return;
            case (byte) 9:
                a = a(0, 0, true);
                while (i < a) {
                    b();
                    i++;
                }
                return;
            case (byte) 10:
                a();
                return;
            case (byte) 11:
            case (byte) 12:
                return;
            case (byte) 13:
                a aVar = new a();
                a(aVar);
                if (aVar.a != (byte) 0) {
                    //throw new JceDecodeException("skipField with invalid type, type value: " + b + ", " + aVar.a);
                }
                a(a(0, 0, true));
                return;
            default:
                //throw new JceDecodeException("invalid type.");
        }
    }

    public final boolean a(int i, boolean z) {
        if (a((byte) 0, i, z) != (byte) 0) {
            return true;
        }
        return false;
    }

    public final byte a(byte b, int i, boolean z) {
        if (b(i)) {
            a aVar = new a();
            a(aVar);
            switch (aVar.a) {
                case (byte) 0:
                    return this.b.get();
                case (byte) 12:
                    return (byte) 0;
                default:
                    //throw new JceDecodeException("type mismatch.");
            }
        } else if (!z) {
            return b;
        } else {
            //throw new JceDecodeException("require field not exist.");
        }
        return b;
    }

    public final short a(short s, int i, boolean z) {
        if (b(i)) {
            a aVar = new a();
            a(aVar);
            switch (aVar.a) {
                case (byte) 0:
                    return (short) this.b.get();
                case (byte) 1:
                    return this.b.getShort();
                case (byte) 12:
                    return (short) 0;
                default:
                    //throw new JceDecodeException("type mismatch.");
            }
        } else if (!z) {
            return s;
        } else {
           // throw new JceDecodeException("require field not exist.");
        }
        return s;
    }

    public final int a(int i, int i2, boolean z) {
        if (b(i2)) {
            a aVar = new a();
            a(aVar);
            switch (aVar.a) {
                case (byte) 0:
                    return this.b.get();
                case (byte) 1:
                    return this.b.getShort();
                case (byte) 2:
                    return this.b.getInt();
                case (byte) 12:
                    return 0;
                default:
                    //throw new JceDecodeException("type mismatch.");
            }
        } else if (!z) {
            return i;
        } else {
           // throw new JceDecodeException("require field not exist.");
        }
        return i;
    }

    public final long a(long j, int i, boolean z) {
        if (b(i)) {
            a aVar = new a();
            a(aVar);
            switch (aVar.a) {
                case (byte) 0:
                    return (long) this.b.get();
                case (byte) 1:
                    return (long) this.b.getShort();
                case (byte) 2:
                    return (long) this.b.getInt();
                case (byte) 3:
                    return this.b.getLong();
                case (byte) 12:
                    return 0;
                default:
                    //throw new JceDecodeException("type mismatch.");
            }
        } else if (!z) {
            return j;
        } else {
            //throw new JceDecodeException("require field not exist.");
        }
        return j;
    }

    public final float a(float f, int i, boolean z) {
        if (b(i)) {
            a aVar = new a();
            a(aVar);
            switch (aVar.a) {
                case (byte) 4:
                    return this.b.getFloat();
                case (byte) 12:
                    return 0.0f;
                default:
                    //throw new JceDecodeException("type mismatch.");
            }
        } else if (!z) {
            return f;
        } else {
            //throw new JceDecodeException("require field not exist.");
        }
        return f;
    }

    public final double a(double d, int i, boolean z) {
        if (b(i)) {
            a aVar = new a();
            a(aVar);
            switch (aVar.a) {
                case (byte) 4:
                    return (double) this.b.getFloat();
                case (byte) 5:
                    return this.b.getDouble();
                case (byte) 12:
                    return 0.0d;
                default:
                   // throw new JceDecodeException("type mismatch.");
            }
        } else if (!z) {
            return d;
        } else {
           // throw new JceDecodeException("require field not exist.");
        }
        return d;
    }

    public final String b(int i, boolean z) {
        if (b(i)) {
            a aVar = new a();
            a(aVar);
            int i2;
            byte[] bArr;
            switch (aVar.a) {
                case (byte) 6:
                    i2 = this.b.get();
                    if (i2 < 0) {
                        i2 += 256;
                    }
                    bArr = new byte[i2];
                    this.b.get(bArr);
                    try {
                        return new String(bArr, this.a);
                    } catch (UnsupportedEncodingException e) {
                        return new String(bArr);
                    }
                case (byte) 7:
                    i2 = this.b.getInt();
                    if (i2 > 104857600 || i2 < 0 || i2 > this.b.capacity()) {
                        //throw new JceDecodeException("String too long: " + i2);
                    }
                    bArr = new byte[i2];
                    this.b.get(bArr);
                    try {
                        return new String(bArr, this.a);
                    } catch (UnsupportedEncodingException e2) {
                        return new String(bArr);
                    }
                default:
                   // throw new JceDecodeException("type mismatch.");
            }
        } else if (!z) {
            return null;
        } else {
            //throw new JceDecodeException("require field not exist.");
        }
        return null;
    }

    private <K, V> Map<K, V> a(Map amap, Map<K, V> map2, int i, boolean z) {
        if (map2 == null || map2.isEmpty()) {
            return new HashMap();
        }
        Entry entry = (Entry) map2.entrySet().iterator().next();
        Object key = entry.getKey();
        Object value = entry.getValue();
        Object m_key = "";
        Object m_value = "";
        if (b(i)) {
            a aVar = new a();
            a(aVar);
            switch (aVar.a) {
                case (byte) 8:
                    int ia = a(0, 0, true);
                    if (ia < 0) {
                       // throw new JceDecodeException("size invalid: " + a);
                    }
                    for (int i2 = 0; i2 < ia; i2++) {
                    	m_key = a(key, 0, true);
                    	m_value = a(value, 1, true);
                    	amap.put(m_key, m_value);
                    }
                    return amap;
                default:
                    //throw new JceDecodeException("type mismatch.");
            }
        } else if (!z) {
            return amap;
        } else {
           // throw new JceDecodeException("require field not exist.");
        }
        return amap;
    }
   /* private Map a(Map arg9, Map arg10, int arg11, boolean arg12) {
        HashMap v9 = null;
        if(arg10 == null) {
        	v9 = new HashMap();
        }
        else if(!arg10.isEmpty()) {
            Object v0 = arg10.entrySet().iterator().next();
            Object v2 = ((Map.Entry)v0).getKey();
            Object v3 = ((Map.Entry)v0).getValue();
            if(this.b(arg11)) {
                a v0_1 = new a();
                this.a(v0_1);
                switch(v0_1.a) {
                    case 8: {
                        int v4 = this.a(0, 0, true);
                        if(v4 < 0) {
                        	System.out.println("size invalid: " + v4);
                        }
                        else {
                            int v0_2 = 0;
                            while(true) {
                                if(v0_2 < v4) {
                                    arg9.put(this.a(v2, 0, true), this.a(v3, 1, true));
                                    ++v0_2;
                                    continue;
                                }

                                return ((Map)v9);
                            }
                        }

                        return ((Map)v9);
                    }
                    default: {
                    	System.out.println("type mismatch.");
                    }
                }
            }
            else {
                if(arg12) {
                	System.out.println("require field not exist.");
                label_5:
                    v9 = new HashMap();
                }
            }
        }

    label_7:
        return ((Map)v9);
    }*/

    private boolean[] d(int i, boolean z) {
        boolean[] zArr = null;
        if (b(i)) {
            a aVar = new a();
            a(aVar);
            switch (aVar.a) {
                case (byte) 9:
                    int a = a(0, 0, true);
                    if (a >= 0) {
                        zArr = new boolean[a];
                        for (int i2 = 0; i2 < a; i2++) {
                            zArr[i2] = a(0, true);
                        }
                        break;
                    }
                   // throw new JceDecodeException("size invalid: " + a);
                default:
                   // throw new JceDecodeException("type mismatch.");
            }
        } else if (z) {
            //throw new JceDecodeException("require field not exist.");
        }
        return zArr;
    }

    public final byte[] c(int i, boolean z) {
        if (b(i)) {
            a aVar = new a();
            a(aVar);
            byte[] bArr;
            switch (aVar.a) {
                case (byte) 9:
                    int a = a(0, 0, true);
                    if (a < 0 || a > this.b.capacity()) {
                       // throw new JceDecodeException("size invalid: " + a);
                    }
                    bArr = new byte[a];
                    for (int i2 = 0; i2 < a; i2++) {
                        bArr[i2] = a(bArr[0], 0, true);
                    }
                    return bArr;
                case (byte) 13:
                    a aVar2 = new a();
                    a(aVar2);
                    if (aVar2.a != (byte) 0) {
                        //throw new JceDecodeException("type mismatch, tag: " + i + ", type: " + aVar.a + ", " + aVar2.a);
                    }
                    int a2 = a(0, 0, true);
                    if (a2 < 0 || a2 > this.b.capacity()) {
                       // throw new JceDecodeException("invalid size, tag: " + i + ", type: " + aVar.a + ", " + aVar2.a + ", size: " + a2);
                    }
                    bArr = new byte[a2];
                    this.b.get(bArr);
                    return bArr;
                default:
                   // throw new JceDecodeException("type mismatch.");
            }
        } else if (!z) {
            return null;
        } else {
           // throw new JceDecodeException("require field not exist.");
        }
        return null;
    }

    private short[] e(int i, boolean z) {
        short[] sArr = null;
        if (b(i)) {
            a aVar = new a();
            a(aVar);
            switch (aVar.a) {
                case (byte) 9:
                    int a = a(0, 0, true);
                    if (a >= 0) {
                        sArr = new short[a];
                        for (int i2 = 0; i2 < a; i2++) {
                            sArr[i2] = a(sArr[0], 0, true);
                        }
                        break;
                    }
                    //throw new JceDecodeException("size invalid: " + a);
                default:
                    //throw new JceDecodeException("type mismatch.");
            }
        } else if (z) {
            //throw new JceDecodeException("require field not exist.");
        }
        return sArr;
    }

    private int[] f(int i, boolean z) {
        int[] iArr = null;
        if (b(i)) {
            a aVar = new a();
            a(aVar);
            switch (aVar.a) {
                case (byte) 9:
                    int a = a(0, 0, true);
                    if (a >= 0) {
                        iArr = new int[a];
                        for (int i2 = 0; i2 < a; i2++) {
                            iArr[i2] = a(iArr[0], 0, true);
                        }
                        break;
                    }
                   // throw new JceDecodeException("size invalid: " + a);
                default:
                   // throw new JceDecodeException("type mismatch.");
            }
        } else if (z) {
           // throw new JceDecodeException("require field not exist.");
        }
        return iArr;
    }

    private long[] g(int i, boolean z) {
        long[] jArr = null;
        if (b(i)) {
            a aVar = new a();
            a(aVar);
            switch (aVar.a) {
                case (byte) 9:
                    int a = a(0, 0, true);
                    if (a >= 0) {
                        jArr = new long[a];
                        for (int i2 = 0; i2 < a; i2++) {
                            jArr[i2] = a(jArr[0], 0, true);
                        }
                        break;
                    }
                    //throw new JceDecodeException("size invalid: " + a);
                default:
                    //throw new JceDecodeException("type mismatch.");
            }
        } else if (z) {
            //throw new JceDecodeException("require field not exist.");
        }
        return jArr;
    }

    private float[] h(int i, boolean z) {
        float[] fArr = null;
        if (b(i)) {
            a aVar = new a();
            a(aVar);
            switch (aVar.a) {
                case (byte) 9:
                    int a = a(0, 0, true);
                    if (a >= 0) {
                        fArr = new float[a];
                        for (int i2 = 0; i2 < a; i2++) {
                            fArr[i2] = a(fArr[0], 0, true);
                        }
                        break;
                    }
                   // throw new JceDecodeException("size invalid: " + a);
                default:
                    //throw new JceDecodeException("type mismatch.");
            }
        } else if (z) {
           // throw new JceDecodeException("require field not exist.");
        }
        return fArr;
    }

    private double[] i(int i, boolean z) {
        double[] dArr = null;
        if (b(i)) {
            a aVar = new a();
            a(aVar);
            switch (aVar.a) {
                case (byte) 9:
                    int a = a(0, 0, true);
                    if (a >= 0) {
                        dArr = new double[a];
                        for (int i2 = 0; i2 < a; i2++) {
                            dArr[i2] = a(dArr[0], 0, true);
                        }
                        break;
                    }
                    //throw new JceDecodeException("size invalid: " + a);
                default:
                   // throw new JceDecodeException("type mismatch.");
            }
        } else if (z) {
           // throw new JceDecodeException("require field not exist.");
        }
        return dArr;
    }

    private <T> T[] a(T[] tArr, int i, boolean z) {
        if (tArr != null && tArr.length != 0) {
            return b(tArr[0], i, z);
        }
        return b(tArr[0], i, z);
       // throw new JceDecodeException("unable to get type of key and value.");
    }

    private <T> ArrayList a(List list, int i, boolean z) {
        int i2 = 0;
        if (list == null ||  list.isEmpty()) {
            return new ArrayList();
        }
        Object[] b = b((list).get(0), i, z);
        if (b == null) {
            return null;
        }
        ArrayList arrayList = new ArrayList();
        while (i2 < b.length) {
            arrayList.add(b[i2]);
            i2++;
        }
        return arrayList;
    }

    private <T> T[] b(T t, int i, boolean z) {
        if (b(i)) {
            a aVar = new a();
            a(aVar);
            switch (aVar.a) {
                case (byte) 9:
                    int a = a(0, 0, true);
                    if (a < 0) {
                        //throw new JceDecodeException("size invalid: " + a);
                    }
                    Object[] objArr = (Object[]) Array.newInstance(t.getClass(), a);
                    for (int i2 = 0; i2 < a; i2++) {
                        objArr[i2] = a((Object) t, 0, true);
                    }
                    return (T[]) objArr;
                default:
                    //throw new JceDecodeException("type mismatch.");
            }
        } else if (!z) {
            return null;
        } else {
           // throw new JceDecodeException("require field not exist.");
        }
        return null;
    }

    public final JceStruct a(JceStruct jceStruct, int i, boolean z) {
        JceStruct jceStruct2 = null;
        if (b(i)) {
            try {
                jceStruct2 = (JceStruct) jceStruct.getClass().newInstance();
                a aVar = new a();
                a(aVar);
                if (aVar.a != (byte) 10) {
                    //throw new JceDecodeException("type mismatch.");
                }
                jceStruct2.readFrom(this);
                a();
            } catch (Exception e) {
                //throw new JceDecodeException(e.getMessage());
            }
        } else if (z) {
            //throw new JceDecodeException("require field not exist.");
        }
        return jceStruct2;
    }

    public final <T> Object a(T t, int i, boolean z) {
        if (t instanceof Byte) {
            return Byte.valueOf(a((byte) 0, i, z));
        }
        if (t instanceof Boolean) {
            return Boolean.valueOf(a(i, z));
        }
        if (t instanceof Short) {
            return Short.valueOf(a((short) 0, i, z));
        }
        if (t instanceof Integer) {
            return Integer.valueOf(a(0, i, z));
        }
        if (t instanceof Long) {
            return Long.valueOf(a(0, i, z));
        }
        if (t instanceof Float) {
            return Float.valueOf(a(0.0f, i, z));
        }
        if (t instanceof Double) {
            return Double.valueOf(a(0.0d, i, z));
        }
        if (t instanceof String) {
            return b(i, z);
        }
        if (t instanceof Map) {
            return (Map) a(new HashMap(), (Map) t, i, z);
        } else if (t instanceof List) {
            return a((List) t, i, z);
        } else {
            if (t instanceof JceStruct) {
                return a((JceStruct) t, i, z);
            }
            if (!t.getClass().isArray()) {
                //throw new JceDecodeException("read object error: unsupport type.");
            } else if ((t instanceof byte[]) || (t instanceof Byte[])) {
                return c(i, z);
            } else {
                if (t instanceof boolean[]) {
                    return d(i, z);
                }
                if (t instanceof short[]) {
                    return e(i, z);
                }
                if (t instanceof int[]) {
                    return f(i, z);
                }
                if (t instanceof long[]) {
                    return g(i, z);
                }
                if (t instanceof float[]) {
                    return h(i, z);
                }
                if (t instanceof double[]) {
                    return i(i, z);
                }
                return a((Object[]) t, i, z);
            }
        }
        return null;
    }
    
  /*  public Object a(Object arg3, int arg4, boolean arg5) {
        Double v0_6 = null;

        if((arg3 instanceof Byte)) {
            Byte v0 = Byte.valueOf((byte) this.a(0, arg4, arg5));
        }
        else if((arg3 instanceof Boolean)) {
            Boolean v0_1 = Boolean.valueOf(this.a(arg4, arg5));
        }
        else if((arg3 instanceof Short)) {
            Short v0_2 = Short.valueOf(this.a((short)0, arg4, arg5));
        }
        else if((arg3 instanceof Integer)) {
            Integer v0_3 = Integer.valueOf(this.a(0, arg4, arg5));
        }
        else if((arg3 instanceof Long)) {
            Long v0_4 = Long.valueOf(this.a(0, arg4, arg5));
        }
        else if((arg3 instanceof Float)) {
            Float v0_5 = Float.valueOf(this.a(0f, arg4, arg5));
        }
        else if((arg3 instanceof Double)) {
            v0_6 = Double.valueOf(this.a(0, arg4, arg5));
        }
        else if((arg3 instanceof String)) {
            String v0_7 = this.b(arg4, arg5);
        }
        else if((arg3 instanceof Map)) {
            Map v0_8 = this.a(new HashMap(), ((Map)arg3), arg4, arg5);
        }
        else if((arg3 instanceof List)) {
            ArrayList v0_9 = this.a(((List)arg3), arg4, arg5);
        }
        else if((arg3 instanceof JceStruct)) {
            JceStruct v0_10 = this.a(((JceStruct)arg3), arg4, arg5);
        }
        else if(arg3.getClass().isArray()) {
            if(!(arg3 instanceof byte[]) && !(arg3 instanceof Byte[])) {
                if((arg3 instanceof boolean[])) {
                    boolean[] v0_11 = this.d(arg4, arg5);
                }
                else if((arg3 instanceof short[])) {
                    short[] v0_12 = this.e(arg4, arg5);
                }
                else if((arg3 instanceof int[])) {
                    int[] v0_13 = this.f(arg4, arg5);
                }
                else if((arg3 instanceof long[])) {
                    long[] v0_14 = this.g(arg4, arg5);
                }
                else if((arg3 instanceof float[])) {
                    float[] v0_15 = this.h(arg4, arg5);
                }
                else if((arg3 instanceof double[])) {
                    double[] v0_16 = this.i(arg4, arg5);
                }
                else {
                    Object[] v0_17 = this.a(((Object[])arg3), arg4, arg5);
                }

                return v0_6;
            }

            byte[] v0_18 = this.c(arg4, arg5);
        }
        else {
            //goto label_92;
        }

        return v0_6;
    }*/

    public final int a(String str) {
        this.a = str;
        return 0;
    }
}
