package com.saki.qq.taf.jce;

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.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

public final class JceInputStream {
    public static class HeadData {
        public int tag;
        public byte type;

        public void clear() {
            this.type = 0;
            this.tag = 0;
        }
    }

    public static int readHead(HeadData paramHeadData,
                               ByteBuffer paramByteBuffer) {
        int i = paramByteBuffer.get();
        paramHeadData.type = ((byte) (i & 0xF));
        paramHeadData.tag = ((i & 0xF0) >> 4);
        if (paramHeadData.tag == 15) {
            paramHeadData.tag = (0xFF & paramByteBuffer.get());
            return 2;
        }
        return 1;
    }

    private ByteBuffer bs;

    protected String sServerEncoding = "UTF-8";

    public JceInputStream() {
    }

    public JceInputStream(byte[] paramArrayOfByte) {
        this.bs = ByteBuffer.wrap(paramArrayOfByte);
    }

    public JceInputStream(byte[] paramArrayOfByte, int paramInt) {
        this.bs = ByteBuffer.wrap(paramArrayOfByte);
        this.bs.position(paramInt);
    }

    public JceInputStream(ByteBuffer paramByteBuffer) {
        this.bs = paramByteBuffer;
    }

    public JceStruct directRead(JceStruct paramJceStruct, int paramInt,
                                boolean paramBoolean) {
        JceStruct localJceStruct1;
        if (skipToTag(paramInt)) {
            try {
                JceStruct localJceStruct2 = paramJceStruct.newInit();
                localJceStruct1 = localJceStruct2;
                HeadData localHeadData = new HeadData();
                readHead(localHeadData);
                if (localHeadData.type != 10) {
                    throw new JceDecodeException("type mismatch.");
                }
            } catch (Exception localException) {
                throw new JceDecodeException(localException.getMessage());
            }
            localJceStruct1.readFrom(this);
            skipToStructEnd();
            return localJceStruct1;
        }
        if (paramBoolean) {
            throw new JceDecodeException("require field not exist.");
        }
        return null;
    }

    public ByteBuffer getBs() {
        return this.bs;
    }

    private int peakHead(HeadData paramHeadData) {
        return readHead(paramHeadData, this.bs.duplicate());
    }

    public boolean read(boolean paramBoolean1, int paramInt,
                        boolean paramBoolean2) {
        int i = read((byte) 0, paramInt, paramBoolean2);
        boolean bool = false;
        if (i != 0) {
            bool = true;
        }
        return bool;
    }

    public boolean[] read(boolean[] paramArrayOfBoolean, int paramInt,
                          boolean paramBoolean) {
        if (skipToTag(paramInt)) {
            HeadData localHeadData = new HeadData();
            readHead(localHeadData);
            if (localHeadData.type != JceStruct.LIST) {
                throw new JceDecodeException("type mismatch.");
            }
            int i = read(0, 0, true);
            if (i < 0) {
                throw new JceDecodeException("size invalid: " + i);
            }
            boolean[] arrayOfBoolean = new boolean[i];
            for (int j = 0; j < i; j++) {
                arrayOfBoolean[j] = read(arrayOfBoolean[0], 0, true);
            }
            return arrayOfBoolean;
        }
        if (paramBoolean) {
            throw new JceDecodeException("require field not exist.");
        }
        return null;
    }

    public byte read(byte paramByte, int paramInt, boolean paramBoolean) {
        if (skipToTag(paramInt)) {
            HeadData localHeadData = new HeadData();
            readHead(localHeadData);
            switch (localHeadData.type) {
                default:
                    throw new JceDecodeException("type mismatch.");
                case 12:
                    return 0;
                case JceStruct.BYTE:
                    return this.bs.get();
            }
        }
        if (paramBoolean) {
            throw new JceDecodeException("require field not exist.");
        }
        return 0;
    }

    public byte[] read(byte[] arrayOfByte, int paramInt, boolean paramBoolean) {
        if (skipToTag(paramInt)) {
            HeadData localHeadData1 = new HeadData();
            readHead(localHeadData1);
            switch (localHeadData1.type) {
                default:
                    throw new JceDecodeException("type mismatch.");
                case 13:
                    HeadData localHeadData2 = new HeadData();
                    readHead(localHeadData2);
                    if (localHeadData2.type != 0) {
                        throw new JceDecodeException("type mismatch, tag: "
                                + paramInt + ", type: " + localHeadData1.type
                                + ", " + localHeadData2.type);
                    }
                    int k = read(0, 0, true);
                    if ((k < 0) || (k > this.bs.capacity())) {
                        throw new JceDecodeException("invalid size, tag: "
                                + paramInt + ", type: " + localHeadData1.type
                                + ", " + localHeadData2.type + ", size: " + k);
                    }
                    arrayOfByte = new byte[k];
                    this.bs.get(arrayOfByte);
                    return arrayOfByte;
            }
        }
        if (!paramBoolean) {

            int i = read(0, 0, true);
            if ((i < 0) || (i > this.bs.capacity())) {
                throw new JceDecodeException("size invalid: " + i);
            }
            arrayOfByte = new byte[i];
            for (int j = 0; j < i; j++) {
                arrayOfByte[j] = read(arrayOfByte[0], 0, true);
            }
            return arrayOfByte;
        }
        throw new JceDecodeException("require field not exist.");
    }

    public double read(double paramDouble, int paramInt, boolean paramBoolean) {
        if (skipToTag(paramInt)) {
            HeadData localHeadData = new HeadData();
            readHead(localHeadData);
            switch (localHeadData.type) {
                default:
                    throw new JceDecodeException("type mismatch.");
                case 12:
                    return 0.0D;
                case JceStruct.FLOAT:
                    return this.bs.getFloat();
                case JceStruct.DOUBLE:
                    return this.bs.getDouble();
            }
        }
        if (paramBoolean) {
            throw new JceDecodeException("require field not exist.");
        }
        return 0.0D;
    }

    public double[] read(double[] paramArrayOfDouble, int paramInt,
                         boolean paramBoolean) {
        if (skipToTag(paramInt)) {
            HeadData localHeadData = new HeadData();
            readHead(localHeadData);
            if (localHeadData.type != JceStruct.LIST) {
                throw new JceDecodeException("type mismatch.");
            }
            int i = read(0, 0, true);
            if (i < 0) {
                throw new JceDecodeException("size invalid: " + i);
            }
            double[] arrayOfDouble = new double[i];
            for (int j = 0; j < i; j++) {
                arrayOfDouble[j] = read(arrayOfDouble[0], 0, true);
            }
            return arrayOfDouble;
        }
        if (paramBoolean) {
            throw new JceDecodeException("require field not exist.");
        }
        return null;
    }

    public float read(float paramFloat, int paramInt, boolean paramBoolean) {
        if (skipToTag(paramInt)) {
            HeadData localHeadData = new HeadData();
            readHead(localHeadData);
            switch (localHeadData.type) {
                default:
                    throw new JceDecodeException("type mismatch.");
                case 12:
                    return 0.0F;
                case JceStruct.FLOAT:
                    return this.bs.getFloat();
            }
        }
        if (paramBoolean) {
            throw new JceDecodeException("require field not exist.");
        }
        return 0.0F;
    }

    public float[] read(float[] paramArrayOfFloat, int paramInt,
                        boolean paramBoolean) {
        if (skipToTag(paramInt)) {
            HeadData localHeadData = new HeadData();
            readHead(localHeadData);
            if (localHeadData.type != JceStruct.LIST) {
                throw new JceDecodeException("type mismatch.");
            }
            int i = read(0, 0, true);
            if (i < 0) {
                throw new JceDecodeException("size invalid: " + i);
            }
            float[] arrayOfFloat = new float[i];
            for (int j = 0; j < i; j++) {
                arrayOfFloat[j] = read(arrayOfFloat[0], 0, true);
            }
            return arrayOfFloat;
        }
        if (paramBoolean) {
            throw new JceDecodeException("require field not exist.");
        }
        return null;
    }

    public int read(int paramInt1, int paramInt2, boolean paramBoolean) {
        if (skipToTag(paramInt2)) {
            HeadData localHeadData = new HeadData();
            readHead(localHeadData);
            switch (localHeadData.type) {
                default:
                    throw new JceDecodeException("type mismatch.");
                case 12:
                    return 0;
                case JceStruct.BYTE:
                    return this.bs.get();
                case JceStruct.SHORT:
                    return this.bs.getShort();
                case JceStruct.INT:
                    return this.bs.getInt();
            }
        }
        if (paramBoolean) {
            throw new JceDecodeException("require field not exist.");
        }
        return 0;
    }

    public int[] read(int[] paramArrayOfInt, int paramInt, boolean paramBoolean) {
        if (skipToTag(paramInt)) {
            HeadData localHeadData = new HeadData();
            readHead(localHeadData);
            if (localHeadData.type != JceStruct.LIST) {
                throw new JceDecodeException("type mismatch.");
            }
            int i = read(0, 0, true);
            if (i < 0) {
                throw new JceDecodeException("size invalid: " + i);
            }
            int[] arrayOfInt = new int[i];
            for (int j = 0; j < i; j++) {
                arrayOfInt[j] = read(arrayOfInt[0], 0, true);
            }
            return arrayOfInt;
        }
        if (paramBoolean) {
            throw new JceDecodeException("require field not exist.");
        }
        return null;
    }

    public JceStruct read(JceStruct paramJceStruct, int paramInt,
                          boolean paramBoolean) {
        if (skipToTag(paramInt)) {
            try {
                JceStruct localJceStruct = paramJceStruct.getClass()
                        .newInstance();
                HeadData localHeadData = new HeadData();
                readHead(localHeadData);
                if (localHeadData.type != JceStruct.STRUCT_BEGIN) {
                    throw new JceDecodeException("type mismatch.");
                }
                localJceStruct.readFrom(this);
                skipToStructEnd();
                return localJceStruct;
            } catch (Exception localException) {
                localException.printStackTrace();
                throw new JceDecodeException(localException.getMessage());
            }
        }
        if (paramBoolean) {
            throw new JceDecodeException("require field not exist.");
        }
        return null;
    }

    public JceStruct[] read(JceStruct[] paramArrayOfJceStruct, int paramInt,
                            boolean paramBoolean) {
        return readArray(paramArrayOfJceStruct, paramInt, paramBoolean);
    }

    public long read(long paramLong, int paramInt, boolean paramBoolean) {
        if (skipToTag(paramInt)) {
            HeadData localHeadData = new HeadData();
            readHead(localHeadData);
            switch (localHeadData.type) {
                default:
                    throw new JceDecodeException("type mismatch.");
                case 12:
                    return 0L;
                case JceStruct.BYTE:
                    return this.bs.get();
                case JceStruct.SHORT:
                    return this.bs.getShort();
                case JceStruct.INT:
                    return this.bs.getInt();
                case JceStruct.LONG:
                    return this.bs.getLong();
            }
        }
        if (paramBoolean) {
            throw new JceDecodeException("require field not exist.");
        }
        return 0L;
    }

    public long[] read(long[] paramArrayOfLong, int paramInt,
                       boolean paramBoolean) {
        if (skipToTag(paramInt)) {
            HeadData localHeadData = new HeadData();
            readHead(localHeadData);
            if (localHeadData.type != JceStruct.LIST) {
                throw new JceDecodeException("type mismatch.");
            }
            int i = read(0, 0, true);
            if (i < 0) {
                throw new JceDecodeException("size invalid: " + i);
            }
            long[] arrayOfLong = new long[i];
            for (int j = 0; j < i; j++) {
                arrayOfLong[j] = read(arrayOfLong[0], 0, true);
            }
            return arrayOfLong;
        }
        if (paramBoolean) {
            throw new JceDecodeException("require field not exist.");
        }
        return null;
    }

    public short read(short paramShort, int paramInt, boolean paramBoolean) {
        if (skipToTag(paramInt)) {
            HeadData localHeadData = new HeadData();
            readHead(localHeadData);
            switch (localHeadData.type) {
                default:
                    throw new JceDecodeException("type mismatch.");
                case 12:
                    return 0;
                case JceStruct.BYTE:
                    return this.bs.get();
                case JceStruct.SHORT:
                    return this.bs.getShort();
            }
        }
        if (paramBoolean) {
            throw new JceDecodeException("require field not exist.");
        }
        return 0;
    }

    public short[] read(short[] paramArrayOfShort, int paramInt,
                        boolean paramBoolean) {
        if (skipToTag(paramInt)) {
            HeadData localHeadData = new HeadData();
            readHead(localHeadData);
            if (localHeadData.type != JceStruct.LIST) {
                throw new JceDecodeException("type mismatch.");
            }
            int i = read(0, 0, true);
            if (i < 0) {
                throw new JceDecodeException("size invalid: " + i);
            }
            short[] arrayOfShort = new short[i];
            for (int j = 0; j < i; j++) {
                arrayOfShort[j] = read(arrayOfShort[0], 0, true);
            }
            return arrayOfShort;
        }
        if (paramBoolean) {
            throw new JceDecodeException("require field not exist.");
        }
        return null;
    }

    public String read(String paramString, int paramInt, boolean paramBoolean) {
        byte[] arrayOfByte2;
        if (skipToTag(paramInt)) {
            HeadData localHeadData = new HeadData();
            readHead(localHeadData);

            switch (localHeadData.type) {
                default:
                    throw new JceDecodeException("type mismatch.");
                case 6:
                    int j = this.bs.get();
                    if (j < 0) {
                        j += 256;
                    }
                    arrayOfByte2 = new byte[j];
                    this.bs.get(arrayOfByte2);
                    try {
                        return new String(arrayOfByte2, this.sServerEncoding);
                    } catch (UnsupportedEncodingException localUnsupportedEncodingException2) {
                        return new String(arrayOfByte2);
                    }
            }
        }
        if (!paramBoolean) {

            int i = this.bs.getInt();
            if ((i > 104857600) || (i < 0) || (i > this.bs.capacity())) {
                throw new JceDecodeException("String too long: " + i);
            }
            byte[] arrayOfByte1 = new byte[i];
            this.bs.get(arrayOfByte1);
            try {
                return new String(arrayOfByte1, this.sServerEncoding);
            } catch (UnsupportedEncodingException localUnsupportedEncodingException1) {
                return new String(arrayOfByte1);
            }
        }
        throw new JceDecodeException("require field not exist.");
    }

    public String[] read(String[] paramArrayOfString, int paramInt,
                         boolean paramBoolean) {
        return readArray(paramArrayOfString, paramInt, paramBoolean);
    }

    public <T> Object read(T paramT, int paramInt, boolean paramBoolean) {
        if ((paramT instanceof Byte)) {
            return Byte.valueOf(read((byte) 0, paramInt, paramBoolean));
        }
        if ((paramT instanceof Boolean)) {
            return Boolean.valueOf(read(false, paramInt, paramBoolean));
        }
        if ((paramT instanceof Short)) {
            return Short.valueOf(read((short) 0, paramInt, paramBoolean));
        }
        if ((paramT instanceof Integer)) {
            return Integer.valueOf(read(0, paramInt, paramBoolean));
        }
        if ((paramT instanceof Long)) {
            return Long.valueOf(read(0L, paramInt, paramBoolean));
        }
        if ((paramT instanceof Float)) {
            return Float.valueOf(read(0.0F, paramInt, paramBoolean));
        }
        if ((paramT instanceof Double)) {
            return Double.valueOf(read(0.0D, paramInt, paramBoolean));
        }
        if ((paramT instanceof String)) {
            return readString(paramInt, paramBoolean);
        }
        if ((paramT instanceof Map)) {
            return readMap((Map) paramT, paramInt, paramBoolean);
        }
        if ((paramT instanceof List)) {
            return readArray((List) paramT, paramInt, paramBoolean);
        }
        if ((paramT instanceof JceStruct)) {
            return read((JceStruct) paramT, paramInt, paramBoolean);
        }
        if (paramT.getClass().isArray()) {
            if (((paramT instanceof byte[])) || ((paramT instanceof Byte[]))) {
                return read((byte[]) null, paramInt, paramBoolean);
            }
            if ((paramT instanceof boolean[])) {
                return read((boolean[]) null, paramInt, paramBoolean);
            }
            if ((paramT instanceof short[])) {
                return read((short[]) null, paramInt, paramBoolean);
            }
            if ((paramT instanceof int[])) {
                return read((int[]) null, paramInt, paramBoolean);
            }
            if ((paramT instanceof long[])) {
                return read((long[]) null, paramInt, paramBoolean);
            }
            if ((paramT instanceof float[])) {
                return read((float[]) null, paramInt, paramBoolean);
            }
            if ((paramT instanceof double[])) {
                return read((double[]) null, paramInt, paramBoolean);
            }
            return readArray((Object[]) paramT, paramInt, paramBoolean);
        }
        throw new JceDecodeException("read object error: unsupport type.");
    }

    public <T> List<T> readArray(List<T> paramList, int paramInt,
                                 boolean paramBoolean) {
        if ((paramList == null) || (paramList.isEmpty())) {
            return new ArrayList();
        }

        Object[] arrayOfObject = readArrayImpl(paramList.get(0), paramInt,
                paramBoolean);
        if (arrayOfObject == null) {
            return null;
        }
        ArrayList localArrayList = new ArrayList();
        for (int i = 0; i < arrayOfObject.length; i++) {
            localArrayList.add(arrayOfObject[i]);
        }
        return localArrayList;
    }

    public <T> T[] readArray(T[] paramArrayOfT, int paramInt,
                             boolean paramBoolean) {
        if ((paramArrayOfT == null) || (paramArrayOfT.length == 0)) {
            throw new JceDecodeException("unable to get type of key and value.");
        }
        return readArrayImpl(paramArrayOfT[0], paramInt, paramBoolean);
    }

    private <T> T[] readArrayImpl(T paramT, int paramInt, boolean paramBoolean) {
        if (skipToTag(paramInt)) {
            HeadData localHeadData = new HeadData();
            readHead(localHeadData);
            if (localHeadData.type != JceStruct.LIST) {
                throw new JceDecodeException("type mismatch.");
            }
            int i = read(0, 0, true);
            if (i < 0) {
                throw new JceDecodeException("size invalid: " + i);
            }
            Object[] arrayOfObject = (Object[]) Array.newInstance(
                    paramT.getClass(), i);
            for (int j = 0; j < i; j++) {
                arrayOfObject[j] = read(paramT, 0, true);
            }
            return (T[]) arrayOfObject;
        }
        if (paramBoolean) {
            throw new JceDecodeException("require field not exist.");
        }
        return null;
    }

    public String readByteString(String paramString, int paramInt,
                                 boolean paramBoolean) {
        if (skipToTag(paramInt)) {
            HeadData localHeadData = new HeadData();
            readHead(localHeadData);
            if (localHeadData.type != JceStruct.STRING1)
                throw new JceDecodeException("type mismatch.");
            int j = this.bs.get();
            if (j < 0) {
                j += 256;
            }
            byte[] arrayOfByte2 = new byte[j];
            this.bs.get(arrayOfByte2);
            return HexUtil.bytes2HexStr(arrayOfByte2);
        }
        if (!paramBoolean) {
            int i = this.bs.getInt();
            if ((i > 104857600) || (i < 0) || (i > this.bs.capacity())) {
                throw new JceDecodeException("String too long: " + i);
            }
            byte[] arrayOfByte1 = new byte[i];
            this.bs.get(arrayOfByte1);
            return HexUtil.bytes2HexStr(arrayOfByte1);
        }
        throw new JceDecodeException("require field not exist.");
    }

    public void readHead(HeadData paramHeadData) {
        readHead(paramHeadData, this.bs);
    }

    public List readList(int paramInt, boolean paramBoolean) {
        ArrayList localArrayList = new ArrayList();
        if (skipToTag(paramInt)) {
            HeadData localHeadData1 = new HeadData();
            readHead(localHeadData1);
            if (localHeadData1.type != JceStruct.LIST)
                throw new JceDecodeException("type mismatch.");
            int i = read(0, 0, true);
            if (i < 0) {
                throw new JceDecodeException("size invalid: " + i);
            }
            for (int j = 0; j < i; j++) {
                HeadData localHeadData2 = new HeadData();
                readHead(localHeadData2);
                switch (localHeadData2.type) {
                    case JceStruct.BYTE:
                        skip(1);
                        break;
                    case JceStruct.SHORT:
                        skip(2);
                        break;
                    case JceStruct.INT:
                        skip(4);
                        break;
                    case JceStruct.FLOAT:
                        skip(4);
                        break;
                    case JceStruct.LONG:
                        skip(8);
                        break;
                    case JceStruct.DOUBLE:
                        skip(8);
                        break;
                    case JceStruct.STRING1:
                        int k = this.bs.get();
                        if (k < 0) {
                            k += 256;
                        }
                        skip(k);
                        break;
                    case JceStruct.STRING4:
                        skip(this.bs.getInt());
                        break;
                    case JceStruct.STRUCT_BEGIN:
                        try {
                            JceStruct localJceStruct = (JceStruct) Class
                                    .forName(JceStruct.class.getName())
                                    .getConstructor(new Class[0])
                                    .newInstance(new Object[0]);
                            localJceStruct.readFrom(this);
                            skipToStructEnd();
                            localArrayList.add(localJceStruct);
                        } catch (Exception localException) {
                            localException.printStackTrace();
                            throw new JceDecodeException("type mismatch."
                                    + localException);
                        }
                        localArrayList.add(new Integer(0));
                        break;
                    default:
                        throw new JceDecodeException("type mismatch.");
                }
            }
            if (paramBoolean)
                throw new JceDecodeException("require field not exist.");
        }
        return localArrayList;
    }

    public <K, V> HashMap<K, V> readMap(Map<K, V> paramMap, int paramInt,
                                        boolean paramBoolean) {
        return (HashMap) readMap(new HashMap(), paramMap, paramInt,
                paramBoolean);
    }

    private <K, V> Map<K, V> readMap(Map<K, V> paramMap1, Map<K, V> paramMap2,
                                     int paramInt, boolean paramBoolean) {
        if ((paramMap2 == null) || (paramMap2.isEmpty())) {
            return new HashMap();
        }
        if (!skipToTag(paramInt)) {
            return null;
        }
        Iterator it = paramMap2.entrySet().iterator();
        Entry localEntry = null;
        while (it.hasNext()) {
            localEntry = (Entry) it.next();
            Object localObject1 = localEntry.getKey();
            Object localObject2 = localEntry.getValue();
            HeadData localHeadData = new HeadData();
            readHead(localHeadData);
            if (localHeadData.type != JceStruct.MAP) {
                throw new JceDecodeException("type mismatch.");
            }
            int i = read(0, 0, true);
            if (i < 0) {
                throw new JceDecodeException("size invalid: " + i);
            }
            for (int j = 0; j < i; j++) {
                paramMap1.put((K) read(localObject1, 0, true),
                        (V) read(localObject2, 1, true));
            }
            return paramMap1;
        }
        if (paramBoolean) {
            throw new JceDecodeException("require field not exist.");
        }
        return null;
    }

    public String readString(int paramInt, boolean paramBoolean) {
        if (skipToTag(paramInt)) {
            HeadData localHeadData = new HeadData();
            readHead(localHeadData);
            if (localHeadData.type != JceStruct.STRING1)
                throw new JceDecodeException("type mismatch.");
            if (paramBoolean) {
                int j = this.bs.get();
                if (j < 0) {
                    j += 256;
                }
                byte[] arrayOfByte2 = new byte[j];
                this.bs.get(arrayOfByte2);
                try {
                    return new String(arrayOfByte2, this.sServerEncoding);
                } catch (UnsupportedEncodingException localUnsupportedEncodingException2) {
                    return new String(arrayOfByte2);
                }
            } else {
                int i = this.bs.getInt();
                if ((i > 104857600) || (i < 0) || (i > this.bs.capacity())) {
                    throw new JceDecodeException("String too long: " + i);
                }
                byte[] arrayOfByte1 = new byte[i];
                this.bs.get(arrayOfByte1);
                try {
                    return new String(arrayOfByte1, this.sServerEncoding);
                } catch (UnsupportedEncodingException localUnsupportedEncodingException1) {
                    return new String(arrayOfByte1);
                }
            }
        }
        throw new JceDecodeException("require field not exist.");
    }

    public Map<String, String> readStringMap(int paramInt, boolean paramBoolean) {
        HashMap localHashMap = new HashMap();
        if (skipToTag(paramInt)) {
            HeadData localHeadData = new HeadData();
            readHead(localHeadData);
            if (localHeadData.type != JceStruct.MAP)
                throw new JceDecodeException("type mismatch.");
            int i = read(0, 0, true);
            if (i < 0) {
                throw new JceDecodeException("size invalid: " + i);
            }
            for (int j = 0; j < i; j++) {
                localHashMap.put(readString(0, true), readString(1, true));
            }
        }
        if (paramBoolean) {
            throw new JceDecodeException("require field not exist.");
        }
        return localHashMap;
    }

    public int setServerEncoding(String paramString) {
        this.sServerEncoding = paramString;
        return 0;
    }

    private void skip(int paramInt) {
        this.bs.position(paramInt + this.bs.position());
    }

    private void skipField() {
        HeadData localHeadData = new HeadData();
        readHead(localHeadData);
        skipField(localHeadData.type);
    }

    private void skipField(byte paramByte) {
        switch (paramByte) {
            default:
                throw new JceDecodeException("invalid type.");
            case 0:
                skip(1);
            case 11:
            case 12:
                return;
            case 1:
                skip(2);
                return;
            case 2:
                skip(4);
                return;
            case 3:
                skip(8);
                return;
            case 4:
                skip(4);
                return;
            case 5:
                skip(8);
                return;
            case 6:
                int n = this.bs.get();
                if (n < 0) {
                    n += 256;
                }
                skip(n);
                return;
            case 7:
                skip(this.bs.getInt());
                return;
            case 8:
                int k = read(0, 0, true);
                for (int m = 0; m < k * 2; m++) {
                    skipField();
                }
                return;
            case 9:
                int i = read(0, 0, true);
                for (int j = 0; j < i; j++) {
                    skipField();
                }
                return;
            case 13:
                HeadData localHeadData = new HeadData();
                readHead(localHeadData);
                if (localHeadData.type != 0) {
                    throw new JceDecodeException(
                            "skipField with invalid type, type value: " + paramByte
                                    + ", " + localHeadData.type);
                }
                skip(read(0, 0, true));
                return;
            case 10:
                skipToStructEnd();
                return;
        }

    }

    public void skipToStructEnd() {
        HeadData localHeadData = new HeadData();
        do {
            readHead(localHeadData);
            skipField(localHeadData.type);
        } while (localHeadData.type != 11);
    }

    public boolean skipToTag(int paramInt) {
        try {
            HeadData paramHeadData = new HeadData();
            int i = peakHead(paramHeadData);
            while (paramHeadData.tag != paramInt) {
                if (paramHeadData.type == 11)
                    return false;
                skip(i);
                skipField(paramHeadData.type);
                i = peakHead(paramHeadData);
            }
            return true;
        } catch (BufferUnderflowException | JceDecodeException localJceDecodeException) {
            return false;
        }
    }

    public void warp(byte[] paramArrayOfByte) {
        wrap(paramArrayOfByte);
    }

    public void wrap(byte[] paramArrayOfByte) {
        this.bs = ByteBuffer.wrap(paramArrayOfByte);
    }
}
