www.pudn.com > cmppNeu.rar > SubmitResp.java


package cmpp.v2_0; 
 
import java.util.Arrays; 
 
public class SubmitResp extends CMPP 
{ 
    private  final int commandId 		= CMPP.ID_CMPP_SUBMIT_RESP; 
    private	 final int commandLength 	= 9; 
     
    private long MsgId		= 0; 
    private	int	 Result		= 0; 
     
    public SubmitResp() { 
    	super(CMPP.ID_CMPP_SUBMIT_RESP); 
    } 
    public SubmitResp(CMPP cmpp) 
    { 
        super(cmpp); 
    } 
	public int getCommandId() { 
		return commandId; 
	} 
	public int getCommandLength() { 
		return commandLength; 
	} 
 
    public long getMsgId() { 
		return MsgId; 
	} 
	public void setMsgId(long msgId) { 
		MsgId = msgId; 
	} 
	 
	public int getResult() { 
        return Result; 
    } 
	public void setResult(int result) { 
		Result = result; 
	} 
 
	protected int parseBody() 
    { 
    	if( super.bodyLength < commandLength ) { 
    		return -1; 
    	} 
         
    	byte[] abyte0 = new byte[21]; 
    	int off = 0; 
    	 
    	Arrays.fill(abyte0,(byte)0); 
    	CMPP.BytesCopy(super.bodybytes, abyte0, off, off+7, 0); 
    	MsgId = CMPP.Bytes8ToLong(abyte0); 
    	off += 8; 
    	 
    	Arrays.fill(abyte0,(byte)0); 
    	CMPP.BytesCopy(super.bodybytes, abyte0, off, off, 0); 
    	Result = CMPP.ByteToInt(abyte0[0]); 
    	off += 1; 
    	 
        return 0; 
    } 
 
    protected int makeBody() 
    { 
    	super.bodyLength = commandLength; 
    	super.bodybytes  = new byte[super.bodyLength]; 
    	Arrays.fill(super.bodybytes,(byte)0); 
    	 
    	// make paremeter 
    	if(MsgId == 0) {  // Auto gen 
    		MsgId = 123456; 
    	} 
    	// make body 
    	int off = 0; 
    	CMPP.BytesCopy(CMPP.LongToBytes8(MsgId), super.bodybytes, 0, 7, off ); 
    	off += 8; 
    	super.bodybytes[off] = CMPP.IntToByte(Result); 
    	off += 1; 
    	 
        return 0; 
    } 
 
    public String toString() { 
    	StringBuffer sb = new StringBuffer(); 
    	 
    	sb.append("MsgId=" + new Long(MsgId).toString() + "\n"); 
    	sb.append("Result=" + Result + "\n"); 
    	 
    	return sb.toString(); 
    } 
}