view src/fdl/PSXReply.java @ 17:609b288f47f9

*** empty log message ***
author kono
date Mon, 18 Aug 2008 07:28:29 +0900
parents aced4bfc15af
children 35375016b2f0
line wrap: on
line source


/**
 * PSXReply 
 *
 * @author Shinji Kono
 *

    psx.in(),psxrd.() return this.

    method for check answer is ready or not.

    (call back interface can be used instead of this)

    unique sequence number  */

package fdl;
import java.nio.ByteBuffer;

public class PSXReply {
    public ByteBuffer command;
    public ByteBuffer data;
    public int seq;
    public PSXReply next;
    public int mode;
    public PSXCallback callback;
    static final boolean debug = false;

    public PSXReply(int _mode,PSXCallback _callback) {
	mode = _mode;
	callback = _callback;
    }

    public PSXReply() {
    }

    public void setAnswer(int _mode, ByteBuffer _command,ByteBuffer _data) {
    	mode = _mode;
    	data = _data;
    	command = _command;
    	if (debug) {
    		System.out.print("setAnswer mode:");
    		System.out.println(mode);
    		System.out.print("setAnswer bool:");
    		System.out.println(mode==PSX.PSX_ANSWER);
    	}
    }

    public int getMode() {
	return command.get(PSX.LINDA_MODE_OFFSET);
    }

    public int getId() {
	return command.getShort(PSX.LINDA_ID_OFFSET);
    }

    public int getSeq() {
	return command.getInt(PSX.LINDA_SEQ_OFFSET);
    }

    public int getLength() {
	return command.getInt(PSX.LINDA_DATA_LENGTH_OFFSET);
    }

    public ByteBuffer getData() {
	data.rewind();
	return data;
    }

    public boolean ready() {
	return mode==PSX.PSX_ANSWER;
    }
}


/* end */