1 24 package com.scalagent.kjoram.jms; 25 26 import com.scalagent.kjoram.messages.Message; 27 import java.util.Hashtable ; 28 import java.util.Enumeration ; 29 import java.util.Vector ; 30 31 36 public class QBrowseReply extends AbstractJmsReply 37 { 38 39 private Message message = null; 40 41 private Vector messages = null; 42 43 44 49 public QBrowseReply(com.scalagent.kjoram.comm.BrowseReply destReply) 50 { 51 super(destReply.getCorrelationId()); 52 Vector vec = destReply.getMessages(); 53 if (vec != null && vec.size() == 1) 54 message = (Message) vec.elementAt(0); 55 else 56 messages = vec; 57 } 58 59 62 private QBrowseReply(int correlationId) 63 { 64 super(correlationId); 65 } 66 67 70 private QBrowseReply(int correlationId, Message message) 71 { 72 super(correlationId); 73 this.message = message; 74 } 75 76 79 private QBrowseReply(int correlationId, Vector messages) 80 { 81 super(correlationId); 82 this.messages = messages; 83 } 84 85 public QBrowseReply() { 86 messages = new Vector (); 87 } 88 89 90 public Vector getMessages() 91 { 92 if (message != null) { 93 Vector vec = new Vector (); 94 vec.addElement(message); 95 return vec; 96 } 97 return messages; 98 } 99 100 public void addMessage(Message msg) { 101 messages.addElement(msg); 102 } 103 104 public void setMessage(Message msg) { 105 message = msg; 106 } 107 108 public Hashtable soapCode() { 109 Hashtable h = super.soapCode(); 110 int size = messages.size(); 112 if (size > 0) { 113 Vector arrayMsg = new Vector (); 114 for (int i = 0; i<size; i++) { 115 Message msg = (Message) messages.elementAt(0); 116 messages.removeElementAt(0); 117 arrayMsg.insertElementAt(msg.soapCode(),i); 118 } 119 if (arrayMsg != null) 120 h.put("arrayMsg",arrayMsg); 121 } else { 122 if (message != null) { 123 h.put("singleMsg",message.soapCode()); 124 } 125 } 126 return h; 127 } 128 129 133 public static Object soapDecode(Hashtable h) { 134 QBrowseReply req = new QBrowseReply(); 135 req.setCorrelationId(((Integer ) h.get("correlationId")).intValue()); 136 Vector arrayMsg = (Vector ) h.get("arrayMsg"); 137 if (arrayMsg != null) { 138 for (int i = 0; i<arrayMsg.size(); i++) 139 req.addMessage(Message.soapDecode((Hashtable ) arrayMsg.elementAt(i))); 140 } else 141 req.setMessage(Message.soapDecode((Hashtable )h.get("singleMsg"))); 142 return req; 143 } 144 } 145 | Popular Tags |