com.noodlewiz.xjavab.core.xcmisc.internal.ReplyUnpacker.java Source code

Java tutorial

Introduction

Here is the source code for com.noodlewiz.xjavab.core.xcmisc.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.core.xcmisc.internal;

import java.nio.ByteBuffer;
import java.util.List;
import com.noodlewiz.xjavab.core.internal.Unpacker;
import com.noodlewiz.xjavab.core.xcmisc.GetVersionReply;
import com.noodlewiz.xjavab.core.xcmisc.GetXIDListReply;
import com.noodlewiz.xjavab.core.xcmisc.GetXIDRangeReply;

public class ReplyUnpacker {

    public static GetVersionReply unpackGetVersion(final ByteBuffer __xjb_buf) {
        __xjb_buf.position(4);
        final long length = Unpacker.unpackUInt(__xjb_buf);
        __xjb_buf.position(1);
        Unpacker.unpackPad(__xjb_buf, 1);
        __xjb_buf.position(8);
        final int serverMajorVersion = Unpacker.unpackUShort(__xjb_buf);
        final int serverMinorVersion = Unpacker.unpackUShort(__xjb_buf);
        return new GetVersionReply(serverMajorVersion, serverMinorVersion);
    }

    public static GetXIDRangeReply unpackGetXIDRange(final ByteBuffer __xjb_buf) {
        __xjb_buf.position(4);
        final long length = Unpacker.unpackUInt(__xjb_buf);
        __xjb_buf.position(1);
        Unpacker.unpackPad(__xjb_buf, 1);
        __xjb_buf.position(8);
        final long startId = Unpacker.unpackUInt(__xjb_buf);
        final long count = Unpacker.unpackUInt(__xjb_buf);
        return new GetXIDRangeReply(startId, count);
    }

    public static GetXIDListReply unpackGetXIDList(final ByteBuffer __xjb_buf) {
        __xjb_buf.position(4);
        final long length = Unpacker.unpackUInt(__xjb_buf);
        __xjb_buf.position(1);
        Unpacker.unpackPad(__xjb_buf, 1);
        __xjb_buf.position(8);
        final long idsLen = Unpacker.unpackUInt(__xjb_buf);
        Unpacker.unpackPad(__xjb_buf, 20);
        final com.google.common.collect.ImmutableList.Builder<Long> __xjb_idsBuilder = new com.google.common.collect.ImmutableList.Builder<Long>();
        for (int __xjb_i = 0; (__xjb_i < idsLen); __xjb_i++) {
            __xjb_idsBuilder.add(Unpacker.unpackUInt(__xjb_buf));
        }
        final List<Long> ids = __xjb_idsBuilder.build();
        return new GetXIDListReply(idsLen, ids);
    }

}