All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.taobao.tair.packet.ResponseGetPacket Maven / Gradle / Ivy

/**
 * (C) 2007-2010 Taobao Inc.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 *
 */
package com.taobao.tair.packet;

import java.util.ArrayList;
import java.util.List;

import com.taobao.tair.DataEntry;
import com.taobao.tair.ResultCode;
import com.taobao.tair.comm.Transcoder;
import com.taobao.tair.etc.TairConstant;

public class ResponseGetPacket extends BasePacket {
	protected int             configVersion;
    protected List entryList;
    protected int resultCode;
    protected List proxiedKeyList;

    public ResponseGetPacket(Transcoder transcoder) {
        super(transcoder);
        this.pcode = TairConstant.TAIR_RESP_GET_PACKET;
    }

    /**
     * encode
     */
    public int encode() {
    	throw new UnsupportedOperationException();
    }

    /**
     * decode
     */
    public boolean decode() {
        this.configVersion = byteBuffer.getInt();
        resultCode = byteBuffer.getInt();
        

        int    count   = byteBuffer.getInt();
        int    size    = 0;

        this.entryList = new ArrayList(count);

		for (int i = 0; i < count; i++) {
			DataEntry de = new DataEntry();
			de.decodeKeyValue(byteBuffer, transcoder);
			this.entryList.add(de);
		}
		
		if (count > 1) {
			
			int pc = byteBuffer.getInt();
			if (pc > 0) {
				proxiedKeyList = new ArrayList(pc);
				for (int i=0; i 0)
						proxiedKeyList.indexOf(transcoder.decode(byteBuffer.array(), byteBuffer
						.position(), size));
					byteBuffer.position(byteBuffer.position() + size);
				}
			}
		}

        return true;
    }

    public List getEntryList() {
        return entryList;
    }

    public void setEntryList(List entryList) {
        this.entryList = entryList;
    }

    /**
     * 
     * @return the configVersion
     */
    public int getConfigVersion() {
        return configVersion;
    }

    /**
     * 
     * @param configVersion the configVersion to set
     */
    public void setConfigVersion(int configVersion) {
        this.configVersion = configVersion;
    }

	public int getResultCode() {
		return resultCode;
	}
    
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy