com.noodlewiz.xjavab.ext.record.internal.ReplyUnpacker.java Source code

Java tutorial

Introduction

Here is the source code for com.noodlewiz.xjavab.ext.record.internal.ReplyUnpacker.java

Source

//
// DO NOT MODIFY!!! This file was machine generated. DO NOT MODIFY!!!
// 
// Copyright (c) 2014 Vincent W. Chen.
// 
// This file is part of XJavaB.
// 
// XJavaB is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// 
// XJavaB is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Lesser General Public License for more details.
// 
// You should have received a copy of the GNU Lesser General Public License
// along with XJavaB.  If not, see <http://www.gnu.org/licenses/>.
//

package com.noodlewiz.xjavab.ext.record.internal;

import java.nio.ByteBuffer;
import java.util.List;
import com.noodlewiz.xjavab.ext.record.ClientInfo;
import com.noodlewiz.xjavab.ext.record.EnableContextReply;
import com.noodlewiz.xjavab.ext.record.GetContextReply;
import com.noodlewiz.xjavab.ext.record.QueryVersionReply;

public class ReplyUnpacker {

    public static QueryVersionReply unpackQueryVersion(final ByteBuffer __xjb_buf) {
        __xjb_buf.position(4);
        final long length = com.noodlewiz.xjavab.core.internal.Unpacker.unpackUInt(__xjb_buf);
        __xjb_buf.position(1);
        com.noodlewiz.xjavab.core.internal.Unpacker.unpackPad(__xjb_buf, 1);
        __xjb_buf.position(8);
        final int majorVersion = com.noodlewiz.xjavab.core.internal.Unpacker.unpackUShort(__xjb_buf);
        final int minorVersion = com.noodlewiz.xjavab.core.internal.Unpacker.unpackUShort(__xjb_buf);
        return new QueryVersionReply(majorVersion, minorVersion);
    }

    public static GetContextReply unpackGetContext(final ByteBuffer __xjb_buf) {
        __xjb_buf.position(4);
        final long length = com.noodlewiz.xjavab.core.internal.Unpacker.unpackUInt(__xjb_buf);
        __xjb_buf.position(1);
        final boolean enabled = com.noodlewiz.xjavab.core.internal.Unpacker.unpackBool(__xjb_buf);
        __xjb_buf.position(8);
        final short elementHeader = com.noodlewiz.xjavab.core.internal.Unpacker.unpackUByte(__xjb_buf);
        com.noodlewiz.xjavab.core.internal.Unpacker.unpackPad(__xjb_buf, 3);
        final long numInterceptedClients = com.noodlewiz.xjavab.core.internal.Unpacker.unpackUInt(__xjb_buf);
        com.noodlewiz.xjavab.core.internal.Unpacker.unpackPad(__xjb_buf, 16);
        final com.google.common.collect.ImmutableList.Builder<ClientInfo> __xjb_interceptedClientsBuilder = new com.google.common.collect.ImmutableList.Builder<ClientInfo>();
        for (int __xjb_i = 0; (__xjb_i < numInterceptedClients); __xjb_i++) {
            __xjb_interceptedClientsBuilder
                    .add(com.noodlewiz.xjavab.ext.record.internal.Unpacker.unpackClientInfo(__xjb_buf));
        }
        final List<ClientInfo> interceptedClients = __xjb_interceptedClientsBuilder.build();
        return new GetContextReply(enabled, elementHeader, numInterceptedClients, interceptedClients);
    }

    public static EnableContextReply unpackEnableContext(final ByteBuffer __xjb_buf) {
        __xjb_buf.position(4);
        final long length = com.noodlewiz.xjavab.core.internal.Unpacker.unpackUInt(__xjb_buf);
        __xjb_buf.position(1);
        final short category = com.noodlewiz.xjavab.core.internal.Unpacker.unpackUByte(__xjb_buf);
        __xjb_buf.position(8);
        final short elementHeader = com.noodlewiz.xjavab.core.internal.Unpacker.unpackUByte(__xjb_buf);
        final boolean clientSwapped = com.noodlewiz.xjavab.core.internal.Unpacker.unpackBool(__xjb_buf);
        com.noodlewiz.xjavab.core.internal.Unpacker.unpackPad(__xjb_buf, 2);
        final long xidBase = com.noodlewiz.xjavab.core.internal.Unpacker.unpackUInt(__xjb_buf);
        final long serverTime = com.noodlewiz.xjavab.core.internal.Unpacker.unpackUInt(__xjb_buf);
        final long recSequenceNum = com.noodlewiz.xjavab.core.internal.Unpacker.unpackUInt(__xjb_buf);
        com.noodlewiz.xjavab.core.internal.Unpacker.unpackPad(__xjb_buf, 8);
        final com.google.common.collect.ImmutableList.Builder<Byte> __xjb_dataBuilder = new com.google.common.collect.ImmutableList.Builder<Byte>();
        for (int __xjb_i = 0; (__xjb_i < (length * 4)); __xjb_i++) {
            __xjb_dataBuilder.add(com.noodlewiz.xjavab.core.internal.Unpacker.unpackByte(__xjb_buf));
        }
        final List<Byte> data = __xjb_dataBuilder.build();
        return new EnableContextReply(category, elementHeader, clientSwapped, xidBase, serverTime, recSequenceNum,
                data);
    }

}