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