001 /**
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements. See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License. You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017
018 package org.apache.activemq.openwire.v1;
019
020 import java.io.DataInput;
021 import java.io.DataOutput;
022 import java.io.IOException;
023
024 import org.apache.activemq.command.ConsumerInfo;
025 import org.apache.activemq.command.DataStructure;
026 import org.apache.activemq.openwire.BooleanStream;
027 import org.apache.activemq.openwire.OpenWireFormat;
028
029 /**
030 * Marshalling code for Open Wire Format for ConsumerInfoMarshaller
031 *
032 *
033 * NOTE!: This file is auto generated - do not modify! if you need to make a
034 * change, please see the modify the groovy scripts in the under src/gram/script
035 * and then use maven openwire:generate to regenerate this file.
036 *
037 *
038 */
039 public class ConsumerInfoMarshaller extends BaseCommandMarshaller {
040
041 /**
042 * Return the type of Data Structure we marshal
043 *
044 * @return short representation of the type data structure
045 */
046 public byte getDataStructureType() {
047 return ConsumerInfo.DATA_STRUCTURE_TYPE;
048 }
049
050 /**
051 * @return a new object instance
052 */
053 public DataStructure createObject() {
054 return new ConsumerInfo();
055 }
056
057 /**
058 * Un-marshal an object instance from the data input stream
059 *
060 * @param o the object to un-marshal
061 * @param dataIn the data input stream to build the object from
062 * @throws IOException
063 */
064 public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs)
065 throws IOException {
066 super.tightUnmarshal(wireFormat, o, dataIn, bs);
067
068 ConsumerInfo info = (ConsumerInfo)o;
069 info.setConsumerId((org.apache.activemq.command.ConsumerId)tightUnmarsalCachedObject(wireFormat,
070 dataIn, bs));
071 info.setBrowser(bs.readBoolean());
072 info
073 .setDestination((org.apache.activemq.command.ActiveMQDestination)tightUnmarsalCachedObject(
074 wireFormat,
075 dataIn,
076 bs));
077 info.setPrefetchSize(dataIn.readInt());
078 info.setMaximumPendingMessageLimit(dataIn.readInt());
079 info.setDispatchAsync(bs.readBoolean());
080 info.setSelector(tightUnmarshalString(dataIn, bs));
081 info.setSubscriptionName(tightUnmarshalString(dataIn, bs));
082 info.setNoLocal(bs.readBoolean());
083 info.setExclusive(bs.readBoolean());
084 info.setRetroactive(bs.readBoolean());
085 info.setPriority(dataIn.readByte());
086
087 if (bs.readBoolean()) {
088 short size = dataIn.readShort();
089 org.apache.activemq.command.BrokerId value[] = new org.apache.activemq.command.BrokerId[size];
090 for (int i = 0; i < size; i++) {
091 value[i] = (org.apache.activemq.command.BrokerId)tightUnmarsalNestedObject(wireFormat,
092 dataIn, bs);
093 }
094 info.setBrokerPath(value);
095 } else {
096 info.setBrokerPath(null);
097 }
098 info
099 .setAdditionalPredicate((org.apache.activemq.filter.BooleanExpression)tightUnmarsalNestedObject(
100 wireFormat,
101 dataIn,
102 bs));
103 info.setNetworkSubscription(bs.readBoolean());
104 info.setOptimizedAcknowledge(bs.readBoolean());
105 info.setNoRangeAcks(bs.readBoolean());
106
107 }
108
109 /**
110 * Write the booleans that this object uses to a BooleanStream
111 */
112 public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException {
113
114 ConsumerInfo info = (ConsumerInfo)o;
115
116 int rc = super.tightMarshal1(wireFormat, o, bs);
117 rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getConsumerId(), bs);
118 bs.writeBoolean(info.isBrowser());
119 rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getDestination(), bs);
120 bs.writeBoolean(info.isDispatchAsync());
121 rc += tightMarshalString1(info.getSelector(), bs);
122 rc += tightMarshalString1(info.getSubscriptionName(), bs);
123 bs.writeBoolean(info.isNoLocal());
124 bs.writeBoolean(info.isExclusive());
125 bs.writeBoolean(info.isRetroactive());
126 rc += tightMarshalObjectArray1(wireFormat, info.getBrokerPath(), bs);
127 rc += tightMarshalNestedObject1(wireFormat, (DataStructure)info.getAdditionalPredicate(), bs);
128 bs.writeBoolean(info.isNetworkSubscription());
129 bs.writeBoolean(info.isOptimizedAcknowledge());
130 bs.writeBoolean(info.isNoRangeAcks());
131
132 return rc + 9;
133 }
134
135 /**
136 * Write a object instance to data output stream
137 *
138 * @param o the instance to be marshaled
139 * @param dataOut the output stream
140 * @throws IOException thrown if an error occurs
141 */
142 public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs)
143 throws IOException {
144 super.tightMarshal2(wireFormat, o, dataOut, bs);
145
146 ConsumerInfo info = (ConsumerInfo)o;
147 tightMarshalCachedObject2(wireFormat, (DataStructure)info.getConsumerId(), dataOut, bs);
148 bs.readBoolean();
149 tightMarshalCachedObject2(wireFormat, (DataStructure)info.getDestination(), dataOut, bs);
150 dataOut.writeInt(info.getPrefetchSize());
151 dataOut.writeInt(info.getMaximumPendingMessageLimit());
152 bs.readBoolean();
153 tightMarshalString2(info.getSelector(), dataOut, bs);
154 tightMarshalString2(info.getSubscriptionName(), dataOut, bs);
155 bs.readBoolean();
156 bs.readBoolean();
157 bs.readBoolean();
158 dataOut.writeByte(info.getPriority());
159 tightMarshalObjectArray2(wireFormat, info.getBrokerPath(), dataOut, bs);
160 tightMarshalNestedObject2(wireFormat, (DataStructure)info.getAdditionalPredicate(), dataOut, bs);
161 bs.readBoolean();
162 bs.readBoolean();
163 bs.readBoolean();
164
165 }
166
167 /**
168 * Un-marshal an object instance from the data input stream
169 *
170 * @param o the object to un-marshal
171 * @param dataIn the data input stream to build the object from
172 * @throws IOException
173 */
174 public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException {
175 super.looseUnmarshal(wireFormat, o, dataIn);
176
177 ConsumerInfo info = (ConsumerInfo)o;
178 info.setConsumerId((org.apache.activemq.command.ConsumerId)looseUnmarsalCachedObject(wireFormat,
179 dataIn));
180 info.setBrowser(dataIn.readBoolean());
181 info
182 .setDestination((org.apache.activemq.command.ActiveMQDestination)looseUnmarsalCachedObject(
183 wireFormat,
184 dataIn));
185 info.setPrefetchSize(dataIn.readInt());
186 info.setMaximumPendingMessageLimit(dataIn.readInt());
187 info.setDispatchAsync(dataIn.readBoolean());
188 info.setSelector(looseUnmarshalString(dataIn));
189 info.setSubscriptionName(looseUnmarshalString(dataIn));
190 info.setNoLocal(dataIn.readBoolean());
191 info.setExclusive(dataIn.readBoolean());
192 info.setRetroactive(dataIn.readBoolean());
193 info.setPriority(dataIn.readByte());
194
195 if (dataIn.readBoolean()) {
196 short size = dataIn.readShort();
197 org.apache.activemq.command.BrokerId value[] = new org.apache.activemq.command.BrokerId[size];
198 for (int i = 0; i < size; i++) {
199 value[i] = (org.apache.activemq.command.BrokerId)looseUnmarsalNestedObject(wireFormat, dataIn);
200 }
201 info.setBrokerPath(value);
202 } else {
203 info.setBrokerPath(null);
204 }
205 info
206 .setAdditionalPredicate((org.apache.activemq.filter.BooleanExpression)looseUnmarsalNestedObject(
207 wireFormat,
208 dataIn));
209 info.setNetworkSubscription(dataIn.readBoolean());
210 info.setOptimizedAcknowledge(dataIn.readBoolean());
211 info.setNoRangeAcks(dataIn.readBoolean());
212
213 }
214
215 /**
216 * Write the booleans that this object uses to a BooleanStream
217 */
218 public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException {
219
220 ConsumerInfo info = (ConsumerInfo)o;
221
222 super.looseMarshal(wireFormat, o, dataOut);
223 looseMarshalCachedObject(wireFormat, (DataStructure)info.getConsumerId(), dataOut);
224 dataOut.writeBoolean(info.isBrowser());
225 looseMarshalCachedObject(wireFormat, (DataStructure)info.getDestination(), dataOut);
226 dataOut.writeInt(info.getPrefetchSize());
227 dataOut.writeInt(info.getMaximumPendingMessageLimit());
228 dataOut.writeBoolean(info.isDispatchAsync());
229 looseMarshalString(info.getSelector(), dataOut);
230 looseMarshalString(info.getSubscriptionName(), dataOut);
231 dataOut.writeBoolean(info.isNoLocal());
232 dataOut.writeBoolean(info.isExclusive());
233 dataOut.writeBoolean(info.isRetroactive());
234 dataOut.writeByte(info.getPriority());
235 looseMarshalObjectArray(wireFormat, info.getBrokerPath(), dataOut);
236 looseMarshalNestedObject(wireFormat, (DataStructure)info.getAdditionalPredicate(), dataOut);
237 dataOut.writeBoolean(info.isNetworkSubscription());
238 dataOut.writeBoolean(info.isOptimizedAcknowledge());
239 dataOut.writeBoolean(info.isNoRangeAcks());
240
241 }
242 }