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 MessageMarshaller
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 abstract class MessageMarshaller extends BaseCommandMarshaller {
042
043    /**
044     * Un-marshal an object instance from the data input stream
045     *
046     * @param o the object to un-marshal
047     * @param dataIn the data input stream to build the object from
048     * @throws IOException
049     */
050    public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException {
051        super.tightUnmarshal(wireFormat, o, dataIn, bs);
052
053        Message info = (Message)o;
054
055        info.beforeUnmarshall(wireFormat);
056        
057        info.setProducerId((org.apache.activemq.command.ProducerId) tightUnmarsalCachedObject(wireFormat, dataIn, bs));
058        info.setDestination((org.apache.activemq.command.ActiveMQDestination) tightUnmarsalCachedObject(wireFormat, dataIn, bs));
059        info.setTransactionId((org.apache.activemq.command.TransactionId) tightUnmarsalCachedObject(wireFormat, dataIn, bs));
060        info.setOriginalDestination((org.apache.activemq.command.ActiveMQDestination) tightUnmarsalCachedObject(wireFormat, dataIn, bs));
061        info.setMessageId((org.apache.activemq.command.MessageId) tightUnmarsalNestedObject(wireFormat, dataIn, bs));
062        info.setOriginalTransactionId((org.apache.activemq.command.TransactionId) tightUnmarsalCachedObject(wireFormat, dataIn, bs));
063        info.setGroupID(tightUnmarshalString(dataIn, bs));
064        info.setGroupSequence(dataIn.readInt());
065        info.setCorrelationId(tightUnmarshalString(dataIn, bs));
066        info.setPersistent(bs.readBoolean());
067        info.setExpiration(tightUnmarshalLong(wireFormat, dataIn, bs));
068        info.setPriority(dataIn.readByte());
069        info.setReplyTo((org.apache.activemq.command.ActiveMQDestination) tightUnmarsalNestedObject(wireFormat, dataIn, bs));
070        info.setTimestamp(tightUnmarshalLong(wireFormat, dataIn, bs));
071        info.setType(tightUnmarshalString(dataIn, bs));
072        info.setContent(tightUnmarshalByteSequence(dataIn, bs));
073        info.setMarshalledProperties(tightUnmarshalByteSequence(dataIn, bs));
074        info.setDataStructure((org.apache.activemq.command.DataStructure) tightUnmarsalNestedObject(wireFormat, dataIn, bs));
075        info.setTargetConsumerId((org.apache.activemq.command.ConsumerId) tightUnmarsalCachedObject(wireFormat, dataIn, bs));
076        info.setCompressed(bs.readBoolean());
077        info.setRedeliveryCounter(dataIn.readInt());
078
079        if (bs.readBoolean()) {
080            short size = dataIn.readShort();
081            org.apache.activemq.command.BrokerId value[] = new org.apache.activemq.command.BrokerId[size];
082            for( int i=0; i < size; i++ ) {
083                value[i] = (org.apache.activemq.command.BrokerId) tightUnmarsalNestedObject(wireFormat,dataIn, bs);
084            }
085            info.setBrokerPath(value);
086        }
087        else {
088            info.setBrokerPath(null);
089        }
090        info.setArrival(tightUnmarshalLong(wireFormat, dataIn, bs));
091        info.setUserID(tightUnmarshalString(dataIn, bs));
092        info.setRecievedByDFBridge(bs.readBoolean());
093        info.setDroppable(bs.readBoolean());
094
095        if (bs.readBoolean()) {
096            short size = dataIn.readShort();
097            org.apache.activemq.command.BrokerId value[] = new org.apache.activemq.command.BrokerId[size];
098            for( int i=0; i < size; i++ ) {
099                value[i] = (org.apache.activemq.command.BrokerId) tightUnmarsalNestedObject(wireFormat,dataIn, bs);
100            }
101            info.setCluster(value);
102        }
103        else {
104            info.setCluster(null);
105        }
106        info.setBrokerInTime(tightUnmarshalLong(wireFormat, dataIn, bs));
107        info.setBrokerOutTime(tightUnmarshalLong(wireFormat, dataIn, bs));
108
109        info.afterUnmarshall(wireFormat);
110
111    }
112
113
114    /**
115     * Write the booleans that this object uses to a BooleanStream
116     */
117    public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException {
118
119        Message info = (Message)o;
120
121        info.beforeMarshall(wireFormat);
122
123        int rc = super.tightMarshal1(wireFormat, o, bs);
124        rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getProducerId(), bs);
125        rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getDestination(), bs);
126        rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getTransactionId(), bs);
127        rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getOriginalDestination(), bs);
128        rc += tightMarshalNestedObject1(wireFormat, (DataStructure)info.getMessageId(), bs);
129        rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getOriginalTransactionId(), bs);
130        rc += tightMarshalString1(info.getGroupID(), bs);
131        rc += tightMarshalString1(info.getCorrelationId(), bs);
132        bs.writeBoolean(info.isPersistent());
133        rc+=tightMarshalLong1(wireFormat, info.getExpiration(), bs);
134        rc += tightMarshalNestedObject1(wireFormat, (DataStructure)info.getReplyTo(), bs);
135        rc+=tightMarshalLong1(wireFormat, info.getTimestamp(), bs);
136        rc += tightMarshalString1(info.getType(), bs);
137        rc += tightMarshalByteSequence1(info.getContent(), bs);
138        rc += tightMarshalByteSequence1(info.getMarshalledProperties(), bs);
139        rc += tightMarshalNestedObject1(wireFormat, (DataStructure)info.getDataStructure(), bs);
140        rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getTargetConsumerId(), bs);
141        bs.writeBoolean(info.isCompressed());
142        rc += tightMarshalObjectArray1(wireFormat, info.getBrokerPath(), bs);
143        rc+=tightMarshalLong1(wireFormat, info.getArrival(), bs);
144        rc += tightMarshalString1(info.getUserID(), bs);
145        bs.writeBoolean(info.isRecievedByDFBridge());
146        bs.writeBoolean(info.isDroppable());
147        rc += tightMarshalObjectArray1(wireFormat, info.getCluster(), bs);
148        rc+=tightMarshalLong1(wireFormat, info.getBrokerInTime(), bs);
149        rc+=tightMarshalLong1(wireFormat, info.getBrokerOutTime(), bs);
150
151        return rc + 9;
152    }
153
154    /**
155     * Write a object instance to data output stream
156     *
157     * @param o the instance to be marshaled
158     * @param dataOut the output stream
159     * @throws IOException thrown if an error occurs
160     */
161    public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException {
162        super.tightMarshal2(wireFormat, o, dataOut, bs);
163
164        Message info = (Message)o;
165        tightMarshalCachedObject2(wireFormat, (DataStructure)info.getProducerId(), dataOut, bs);
166        tightMarshalCachedObject2(wireFormat, (DataStructure)info.getDestination(), dataOut, bs);
167        tightMarshalCachedObject2(wireFormat, (DataStructure)info.getTransactionId(), dataOut, bs);
168        tightMarshalCachedObject2(wireFormat, (DataStructure)info.getOriginalDestination(), dataOut, bs);
169        tightMarshalNestedObject2(wireFormat, (DataStructure)info.getMessageId(), dataOut, bs);
170        tightMarshalCachedObject2(wireFormat, (DataStructure)info.getOriginalTransactionId(), dataOut, bs);
171        tightMarshalString2(info.getGroupID(), dataOut, bs);
172        dataOut.writeInt(info.getGroupSequence());
173        tightMarshalString2(info.getCorrelationId(), dataOut, bs);
174        bs.readBoolean();
175        tightMarshalLong2(wireFormat, info.getExpiration(), dataOut, bs);
176        dataOut.writeByte(info.getPriority());
177        tightMarshalNestedObject2(wireFormat, (DataStructure)info.getReplyTo(), dataOut, bs);
178        tightMarshalLong2(wireFormat, info.getTimestamp(), dataOut, bs);
179        tightMarshalString2(info.getType(), dataOut, bs);
180        tightMarshalByteSequence2(info.getContent(), dataOut, bs);
181        tightMarshalByteSequence2(info.getMarshalledProperties(), dataOut, bs);
182        tightMarshalNestedObject2(wireFormat, (DataStructure)info.getDataStructure(), dataOut, bs);
183        tightMarshalCachedObject2(wireFormat, (DataStructure)info.getTargetConsumerId(), dataOut, bs);
184        bs.readBoolean();
185        dataOut.writeInt(info.getRedeliveryCounter());
186        tightMarshalObjectArray2(wireFormat, info.getBrokerPath(), dataOut, bs);
187        tightMarshalLong2(wireFormat, info.getArrival(), dataOut, bs);
188        tightMarshalString2(info.getUserID(), dataOut, bs);
189        bs.readBoolean();
190        bs.readBoolean();
191        tightMarshalObjectArray2(wireFormat, info.getCluster(), dataOut, bs);
192        tightMarshalLong2(wireFormat, info.getBrokerInTime(), dataOut, bs);
193        tightMarshalLong2(wireFormat, info.getBrokerOutTime(), dataOut, bs);
194
195        info.afterMarshall(wireFormat);
196
197    }
198
199    /**
200     * Un-marshal an object instance from the data input stream
201     *
202     * @param o the object to un-marshal
203     * @param dataIn the data input stream to build the object from
204     * @throws IOException
205     */
206    public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException {
207        super.looseUnmarshal(wireFormat, o, dataIn);
208
209        Message info = (Message)o;
210
211        info.beforeUnmarshall(wireFormat);
212        
213        info.setProducerId((org.apache.activemq.command.ProducerId) looseUnmarsalCachedObject(wireFormat, dataIn));
214        info.setDestination((org.apache.activemq.command.ActiveMQDestination) looseUnmarsalCachedObject(wireFormat, dataIn));
215        info.setTransactionId((org.apache.activemq.command.TransactionId) looseUnmarsalCachedObject(wireFormat, dataIn));
216        info.setOriginalDestination((org.apache.activemq.command.ActiveMQDestination) looseUnmarsalCachedObject(wireFormat, dataIn));
217        info.setMessageId((org.apache.activemq.command.MessageId) looseUnmarsalNestedObject(wireFormat, dataIn));
218        info.setOriginalTransactionId((org.apache.activemq.command.TransactionId) looseUnmarsalCachedObject(wireFormat, dataIn));
219        info.setGroupID(looseUnmarshalString(dataIn));
220        info.setGroupSequence(dataIn.readInt());
221        info.setCorrelationId(looseUnmarshalString(dataIn));
222        info.setPersistent(dataIn.readBoolean());
223        info.setExpiration(looseUnmarshalLong(wireFormat, dataIn));
224        info.setPriority(dataIn.readByte());
225        info.setReplyTo((org.apache.activemq.command.ActiveMQDestination) looseUnmarsalNestedObject(wireFormat, dataIn));
226        info.setTimestamp(looseUnmarshalLong(wireFormat, dataIn));
227        info.setType(looseUnmarshalString(dataIn));
228        info.setContent(looseUnmarshalByteSequence(dataIn));
229        info.setMarshalledProperties(looseUnmarshalByteSequence(dataIn));
230        info.setDataStructure((org.apache.activemq.command.DataStructure) looseUnmarsalNestedObject(wireFormat, dataIn));
231        info.setTargetConsumerId((org.apache.activemq.command.ConsumerId) looseUnmarsalCachedObject(wireFormat, dataIn));
232        info.setCompressed(dataIn.readBoolean());
233        info.setRedeliveryCounter(dataIn.readInt());
234
235        if (dataIn.readBoolean()) {
236            short size = dataIn.readShort();
237            org.apache.activemq.command.BrokerId value[] = new org.apache.activemq.command.BrokerId[size];
238            for( int i=0; i < size; i++ ) {
239                value[i] = (org.apache.activemq.command.BrokerId) looseUnmarsalNestedObject(wireFormat,dataIn);
240            }
241            info.setBrokerPath(value);
242        }
243        else {
244            info.setBrokerPath(null);
245        }
246        info.setArrival(looseUnmarshalLong(wireFormat, dataIn));
247        info.setUserID(looseUnmarshalString(dataIn));
248        info.setRecievedByDFBridge(dataIn.readBoolean());
249        info.setDroppable(dataIn.readBoolean());
250
251        if (dataIn.readBoolean()) {
252            short size = dataIn.readShort();
253            org.apache.activemq.command.BrokerId value[] = new org.apache.activemq.command.BrokerId[size];
254            for( int i=0; i < size; i++ ) {
255                value[i] = (org.apache.activemq.command.BrokerId) looseUnmarsalNestedObject(wireFormat,dataIn);
256            }
257            info.setCluster(value);
258        }
259        else {
260            info.setCluster(null);
261        }
262        info.setBrokerInTime(looseUnmarshalLong(wireFormat, dataIn));
263        info.setBrokerOutTime(looseUnmarshalLong(wireFormat, dataIn));
264
265        info.afterUnmarshall(wireFormat);
266
267    }
268
269
270    /**
271     * Write the booleans that this object uses to a BooleanStream
272     */
273    public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException {
274
275        Message info = (Message)o;
276
277        info.beforeMarshall(wireFormat);
278
279        super.looseMarshal(wireFormat, o, dataOut);
280        looseMarshalCachedObject(wireFormat, (DataStructure)info.getProducerId(), dataOut);
281        looseMarshalCachedObject(wireFormat, (DataStructure)info.getDestination(), dataOut);
282        looseMarshalCachedObject(wireFormat, (DataStructure)info.getTransactionId(), dataOut);
283        looseMarshalCachedObject(wireFormat, (DataStructure)info.getOriginalDestination(), dataOut);
284        looseMarshalNestedObject(wireFormat, (DataStructure)info.getMessageId(), dataOut);
285        looseMarshalCachedObject(wireFormat, (DataStructure)info.getOriginalTransactionId(), dataOut);
286        looseMarshalString(info.getGroupID(), dataOut);
287        dataOut.writeInt(info.getGroupSequence());
288        looseMarshalString(info.getCorrelationId(), dataOut);
289        dataOut.writeBoolean(info.isPersistent());
290        looseMarshalLong(wireFormat, info.getExpiration(), dataOut);
291        dataOut.writeByte(info.getPriority());
292        looseMarshalNestedObject(wireFormat, (DataStructure)info.getReplyTo(), dataOut);
293        looseMarshalLong(wireFormat, info.getTimestamp(), dataOut);
294        looseMarshalString(info.getType(), dataOut);
295        looseMarshalByteSequence(wireFormat, info.getContent(), dataOut);
296        looseMarshalByteSequence(wireFormat, info.getMarshalledProperties(), dataOut);
297        looseMarshalNestedObject(wireFormat, (DataStructure)info.getDataStructure(), dataOut);
298        looseMarshalCachedObject(wireFormat, (DataStructure)info.getTargetConsumerId(), dataOut);
299        dataOut.writeBoolean(info.isCompressed());
300        dataOut.writeInt(info.getRedeliveryCounter());
301        looseMarshalObjectArray(wireFormat, info.getBrokerPath(), dataOut);
302        looseMarshalLong(wireFormat, info.getArrival(), dataOut);
303        looseMarshalString(info.getUserID(), dataOut);
304        dataOut.writeBoolean(info.isRecievedByDFBridge());
305        dataOut.writeBoolean(info.isDroppable());
306        looseMarshalObjectArray(wireFormat, info.getCluster(), dataOut);
307        looseMarshalLong(wireFormat, info.getBrokerInTime(), dataOut);
308        looseMarshalLong(wireFormat, info.getBrokerOutTime(), dataOut);
309
310    }
311}