 1Content-type: application/x-Unknown; charset=UTF8package nmc.common;


import java.io.DataOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.IOException;

public class ConfigurationCmd extends Command {
    public int channelNumber;
    public int destination;    // one of ConfigurationType
    public byte[] data;

    public ConfigurationCmd(DataInputStream dis) throws IOException {
	this.decerealize(dis);
    }

    public ConfigurationCmd(int channelNumber, int destination, byte[] data) {
	this.seqNo = getNextCmdSeqNo();
	this.len = 4+4+data.length; // for the channelNumber
        this.channelNumber = channelNumber;
        this.destination = destination;
        this.data = data;
    }
    
    public int getMessageType(){
	return CONFIGURATION_CMD;
    }
    
    public void cerealize(DataOutputStream s) throws IOException {
    	super.cerealize(s);
	s.writeInt(channelNumber);
        s.writeInt(destination);
        s.write(data, 0, data.length);
    }

    public void decerealize(DataInputStream s) throws IOException {
        System.out.println("Rockin and rollin");
    	super.decerealize(s);
    	channelNumber = s.readInt();
    	destination = s.readInt();
        data = new byte[this.len-4-4];
        s.read(data, 0, data.length);
    }

    public String toString() {
	return "%<%msgType=ConfigurationCmd%seqNo="
            + this.seqNo
            + "%len="
            + this.len
            + "%channelNumber="
            + this.channelNumber
            + "%destination="
            + ConfigurationType.toString(this.destination)
            + "%data="
            + (new String(data))
            + "%>%";
    }

}
