1 22 package org.jboss.mq; 23 24 import java.io.Externalizable ; 25 import java.io.IOException ; 26 import java.io.ObjectInput ; 27 import java.io.ObjectOutput ; 28 29 37 public class ReceiveRequest implements Externalizable 38 { 39 41 42 private static final long serialVersionUID = 8632752498878645170L; 43 44 45 protected final static byte NULL = 0; 46 47 48 protected final static byte NON_NULL = 1; 49 50 52 54 55 public SpyMessage message; 56 57 public Integer subscriptionId; 58 59 61 63 public void readExternal(ObjectInput in) throws IOException 64 { 65 message = SpyMessage.readMessage(in); 66 byte b = in.readByte(); 67 if (b == NON_NULL) 68 { 69 subscriptionId = new Integer (in.readInt()); 70 } 71 else 72 { 73 subscriptionId = null; 74 } 75 } 76 77 79 public String toString() 80 { 81 StringBuffer buffer = new StringBuffer (); 82 buffer.append("ReceiveRequest["); 83 buffer.append("message=").append(message.header.jmsMessageID); 84 buffer.append(" subscription=").append(subscriptionId); 85 return buffer.toString(); 86 } 87 88 90 public void writeExternal(ObjectOutput out) throws IOException 91 { 92 SpyMessage.writeMessage(message, out); 93 if (subscriptionId == null) 94 { 95 out.writeByte(NULL); 96 } 97 else 98 { 99 out.writeByte(NON_NULL); 100 out.writeInt(subscriptionId.intValue()); 101 } 102 } 103 104 106 108 110 } | Popular Tags |