public static HashMap unpack(ByteBuffer buf)
    {
        HashMap data = new HashMap();
        int index = 0;
        while (buf.hasRemaining())
        {
            switch (buf.getInt())
            {
                case 0:
                    int valui = buf.getInt();
                    data.put(index, valui);
                    System.out.println(valui);
                break;
                case 1:
                    double valud = buf.getDouble();
                    System.out.println(valud);
                    data.put(index, valud);
                break;
                case 2:
                    int size = buf.getInt();
                    byte[] string = new byte[size];
                    buf.get(string);
                    String valus = new String(string);
                    System.out.println(valus);
                    data.put(index, valus);
                break;
            }
            index++;
        }
        buf.rewind();
        return data;
    }