1 24 package org.objectweb.joram.shared.client; 25 26 import java.io.InputStream ; 27 import java.io.OutputStream ; 28 import java.io.IOException ; 29 30 import org.objectweb.joram.shared.stream.Streamable; 31 import org.objectweb.joram.shared.stream.StreamUtil; 32 33 import fr.dyade.aaa.util.Strings; 34 35 39 public final class ConsumerSetListRequest extends AbstractJmsRequest { 40 41 private String selector; 42 43 44 public void setSelector(String selector) { 45 this.selector = selector; 46 } 47 48 49 public String getSelector() { 50 return selector; 51 } 52 53 54 private boolean queueMode; 55 56 57 public void setQueueMode(boolean queueMode) { 58 this.queueMode = queueMode; 59 } 60 61 62 public boolean getQueueMode() { 63 return queueMode; 64 } 65 66 private String [] msgIdsToAck; 67 68 public final String [] getMessageIdsToAck() { 69 return msgIdsToAck; 70 } 71 72 private int msgCount; 73 74 public final int getMessageCount() { 75 return msgCount; 76 } 77 78 protected int getClassId() { 79 return CONSUMER_SET_LIST_REQUEST; 80 } 81 82 90 public ConsumerSetListRequest(String targetName, 91 String selector, 92 boolean queueMode, 93 String [] msgIdsToAck, 94 int msgCount) { 95 super(targetName); 96 this.selector = selector; 97 this.queueMode = queueMode; 98 this.msgIdsToAck = msgIdsToAck; 99 this.msgCount = msgCount; 100 } 101 102 105 public ConsumerSetListRequest() { 106 } 107 108 public void toString(StringBuffer strbuf) { 109 super.toString(strbuf); 110 strbuf.append(",selector=").append(selector); 111 strbuf.append(",queueMode=").append(queueMode); 112 strbuf.append(",msgIdsToAck="); 113 Strings.toString(strbuf, msgIdsToAck); 114 strbuf.append(",msgCount=").append(msgCount); 115 strbuf.append(')'); 116 } 117 118 124 public void writeTo(OutputStream os) throws IOException { 125 super.writeTo(os); 126 StreamUtil.writeTo(selector, os); 127 StreamUtil.writeTo(queueMode, os); 128 if (msgIdsToAck == null) { 129 StreamUtil.writeTo(-1, os); 130 } else { 131 int size = msgIdsToAck.length; 132 StreamUtil.writeTo(size, os); 133 for (int i=0; i<size; i++) { 134 StreamUtil.writeTo(msgIdsToAck[i], os); 135 } 136 } 137 StreamUtil.writeTo(msgCount, os); 138 } 139 140 146 public void readFrom(InputStream is) throws IOException { 147 super.readFrom(is); 148 selector = StreamUtil.readStringFrom(is); 149 queueMode = StreamUtil.readBooleanFrom(is); 150 int size = StreamUtil.readIntFrom(is); 151 if (size == -1) { 152 msgIdsToAck = null; 153 } else { 154 msgIdsToAck = new String [size]; 155 for (int i=0; i<size; i++) { 156 msgIdsToAck[i] = StreamUtil.readStringFrom(is); 157 } 158 } 159 msgCount = StreamUtil.readIntFrom(is); 160 } 161 } 162 | Popular Tags |