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    
019    package org.apache.activemq.openwire.v10;
020    
021    import java.io.DataInput;
022    import java.io.DataOutput;
023    import java.io.IOException;
024    
025    import org.apache.activemq.openwire.*;
026    import 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     */
041    public 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            info.setJMSXGroupFirstForConsumer(bs.readBoolean());
109    
110            info.afterUnmarshall(wireFormat);
111    
112        }
113    
114    
115        /**
116         * Write the booleans that this object uses to a BooleanStream
117         */
118        public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException {
119    
120            Message info = (Message)o;
121    
122            info.beforeMarshall(wireFormat);
123    
124            int rc = super.tightMarshal1(wireFormat, o, bs);
125            rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getProducerId(), bs);
126            rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getDestination(), bs);
127            rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getTransactionId(), bs);
128            rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getOriginalDestination(), bs);
129            rc += tightMarshalNestedObject1(wireFormat, (DataStructure)info.getMessageId(), bs);
130            rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getOriginalTransactionId(), bs);
131            rc += tightMarshalString1(info.getGroupID(), bs);
132            rc += tightMarshalString1(info.getCorrelationId(), bs);
133            bs.writeBoolean(info.isPersistent());
134            rc+=tightMarshalLong1(wireFormat, info.getExpiration(), bs);
135            rc += tightMarshalNestedObject1(wireFormat, (DataStructure)info.getReplyTo(), bs);
136            rc+=tightMarshalLong1(wireFormat, info.getTimestamp(), bs);
137            rc += tightMarshalString1(info.getType(), bs);
138            rc += tightMarshalByteSequence1(info.getContent(), bs);
139            rc += tightMarshalByteSequence1(info.getMarshalledProperties(), bs);
140            rc += tightMarshalNestedObject1(wireFormat, (DataStructure)info.getDataStructure(), bs);
141            rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getTargetConsumerId(), bs);
142            bs.writeBoolean(info.isCompressed());
143            rc += tightMarshalObjectArray1(wireFormat, info.getBrokerPath(), bs);
144            rc+=tightMarshalLong1(wireFormat, info.getArrival(), bs);
145            rc += tightMarshalString1(info.getUserID(), bs);
146            bs.writeBoolean(info.isRecievedByDFBridge());
147            bs.writeBoolean(info.isDroppable());
148            rc += tightMarshalObjectArray1(wireFormat, info.getCluster(), bs);
149            rc+=tightMarshalLong1(wireFormat, info.getBrokerInTime(), bs);
150            rc+=tightMarshalLong1(wireFormat, info.getBrokerOutTime(), bs);
151            bs.writeBoolean(info.isJMSXGroupFirstForConsumer());
152    
153            return rc + 9;
154        }
155    
156        /**
157         * Write a object instance to data output stream
158         *
159         * @param o the instance to be marshaled
160         * @param dataOut the output stream
161         * @throws IOException thrown if an error occurs
162         */
163        public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException {
164            super.tightMarshal2(wireFormat, o, dataOut, bs);
165    
166            Message info = (Message)o;
167            tightMarshalCachedObject2(wireFormat, (DataStructure)info.getProducerId(), dataOut, bs);
168            tightMarshalCachedObject2(wireFormat, (DataStructure)info.getDestination(), dataOut, bs);
169            tightMarshalCachedObject2(wireFormat, (DataStructure)info.getTransactionId(), dataOut, bs);
170            tightMarshalCachedObject2(wireFormat, (DataStructure)info.getOriginalDestination(), dataOut, bs);
171            tightMarshalNestedObject2(wireFormat, (DataStructure)info.getMessageId(), dataOut, bs);
172            tightMarshalCachedObject2(wireFormat, (DataStructure)info.getOriginalTransactionId(), dataOut, bs);
173            tightMarshalString2(info.getGroupID(), dataOut, bs);
174            dataOut.writeInt(info.getGroupSequence());
175            tightMarshalString2(info.getCorrelationId(), dataOut, bs);
176            bs.readBoolean();
177            tightMarshalLong2(wireFormat, info.getExpiration(), dataOut, bs);
178            dataOut.writeByte(info.getPriority());
179            tightMarshalNestedObject2(wireFormat, (DataStructure)info.getReplyTo(), dataOut, bs);
180            tightMarshalLong2(wireFormat, info.getTimestamp(), dataOut, bs);
181            tightMarshalString2(info.getType(), dataOut, bs);
182            tightMarshalByteSequence2(info.getContent(), dataOut, bs);
183            tightMarshalByteSequence2(info.getMarshalledProperties(), dataOut, bs);
184            tightMarshalNestedObject2(wireFormat, (DataStructure)info.getDataStructure(), dataOut, bs);
185            tightMarshalCachedObject2(wireFormat, (DataStructure)info.getTargetConsumerId(), dataOut, bs);
186            bs.readBoolean();
187            dataOut.writeInt(info.getRedeliveryCounter());
188            tightMarshalObjectArray2(wireFormat, info.getBrokerPath(), dataOut, bs);
189            tightMarshalLong2(wireFormat, info.getArrival(), dataOut, bs);
190            tightMarshalString2(info.getUserID(), dataOut, bs);
191            bs.readBoolean();
192            bs.readBoolean();
193            tightMarshalObjectArray2(wireFormat, info.getCluster(), dataOut, bs);
194            tightMarshalLong2(wireFormat, info.getBrokerInTime(), dataOut, bs);
195            tightMarshalLong2(wireFormat, info.getBrokerOutTime(), dataOut, bs);
196            bs.readBoolean();
197    
198            info.afterMarshall(wireFormat);
199    
200        }
201    
202        /**
203         * Un-marshal an object instance from the data input stream
204         *
205         * @param o the object to un-marshal
206         * @param dataIn the data input stream to build the object from
207         * @throws IOException
208         */
209        public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException {
210            super.looseUnmarshal(wireFormat, o, dataIn);
211    
212            Message info = (Message)o;
213    
214            info.beforeUnmarshall(wireFormat);
215            
216            info.setProducerId((org.apache.activemq.command.ProducerId) looseUnmarsalCachedObject(wireFormat, dataIn));
217            info.setDestination((org.apache.activemq.command.ActiveMQDestination) looseUnmarsalCachedObject(wireFormat, dataIn));
218            info.setTransactionId((org.apache.activemq.command.TransactionId) looseUnmarsalCachedObject(wireFormat, dataIn));
219            info.setOriginalDestination((org.apache.activemq.command.ActiveMQDestination) looseUnmarsalCachedObject(wireFormat, dataIn));
220            info.setMessageId((org.apache.activemq.command.MessageId) looseUnmarsalNestedObject(wireFormat, dataIn));
221            info.setOriginalTransactionId((org.apache.activemq.command.TransactionId) looseUnmarsalCachedObject(wireFormat, dataIn));
222            info.setGroupID(looseUnmarshalString(dataIn));
223            info.setGroupSequence(dataIn.readInt());
224            info.setCorrelationId(looseUnmarshalString(dataIn));
225            info.setPersistent(dataIn.readBoolean());
226            info.setExpiration(looseUnmarshalLong(wireFormat, dataIn));
227            info.setPriority(dataIn.readByte());
228            info.setReplyTo((org.apache.activemq.command.ActiveMQDestination) looseUnmarsalNestedObject(wireFormat, dataIn));
229            info.setTimestamp(looseUnmarshalLong(wireFormat, dataIn));
230            info.setType(looseUnmarshalString(dataIn));
231            info.setContent(looseUnmarshalByteSequence(dataIn));
232            info.setMarshalledProperties(looseUnmarshalByteSequence(dataIn));
233            info.setDataStructure((org.apache.activemq.command.DataStructure) looseUnmarsalNestedObject(wireFormat, dataIn));
234            info.setTargetConsumerId((org.apache.activemq.command.ConsumerId) looseUnmarsalCachedObject(wireFormat, dataIn));
235            info.setCompressed(dataIn.readBoolean());
236            info.setRedeliveryCounter(dataIn.readInt());
237    
238            if (dataIn.readBoolean()) {
239                short size = dataIn.readShort();
240                org.apache.activemq.command.BrokerId value[] = new org.apache.activemq.command.BrokerId[size];
241                for( int i=0; i < size; i++ ) {
242                    value[i] = (org.apache.activemq.command.BrokerId) looseUnmarsalNestedObject(wireFormat,dataIn);
243                }
244                info.setBrokerPath(value);
245            }
246            else {
247                info.setBrokerPath(null);
248            }
249            info.setArrival(looseUnmarshalLong(wireFormat, dataIn));
250            info.setUserID(looseUnmarshalString(dataIn));
251            info.setRecievedByDFBridge(dataIn.readBoolean());
252            info.setDroppable(dataIn.readBoolean());
253    
254            if (dataIn.readBoolean()) {
255                short size = dataIn.readShort();
256                org.apache.activemq.command.BrokerId value[] = new org.apache.activemq.command.BrokerId[size];
257                for( int i=0; i < size; i++ ) {
258                    value[i] = (org.apache.activemq.command.BrokerId) looseUnmarsalNestedObject(wireFormat,dataIn);
259                }
260                info.setCluster(value);
261            }
262            else {
263                info.setCluster(null);
264            }
265            info.setBrokerInTime(looseUnmarshalLong(wireFormat, dataIn));
266            info.setBrokerOutTime(looseUnmarshalLong(wireFormat, dataIn));
267            info.setJMSXGroupFirstForConsumer(dataIn.readBoolean());
268    
269            info.afterUnmarshall(wireFormat);
270    
271        }
272    
273    
274        /**
275         * Write the booleans that this object uses to a BooleanStream
276         */
277        public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException {
278    
279            Message info = (Message)o;
280    
281            info.beforeMarshall(wireFormat);
282    
283            super.looseMarshal(wireFormat, o, dataOut);
284            looseMarshalCachedObject(wireFormat, (DataStructure)info.getProducerId(), dataOut);
285            looseMarshalCachedObject(wireFormat, (DataStructure)info.getDestination(), dataOut);
286            looseMarshalCachedObject(wireFormat, (DataStructure)info.getTransactionId(), dataOut);
287            looseMarshalCachedObject(wireFormat, (DataStructure)info.getOriginalDestination(), dataOut);
288            looseMarshalNestedObject(wireFormat, (DataStructure)info.getMessageId(), dataOut);
289            looseMarshalCachedObject(wireFormat, (DataStructure)info.getOriginalTransactionId(), dataOut);
290            looseMarshalString(info.getGroupID(), dataOut);
291            dataOut.writeInt(info.getGroupSequence());
292            looseMarshalString(info.getCorrelationId(), dataOut);
293            dataOut.writeBoolean(info.isPersistent());
294            looseMarshalLong(wireFormat, info.getExpiration(), dataOut);
295            dataOut.writeByte(info.getPriority());
296            looseMarshalNestedObject(wireFormat, (DataStructure)info.getReplyTo(), dataOut);
297            looseMarshalLong(wireFormat, info.getTimestamp(), dataOut);
298            looseMarshalString(info.getType(), dataOut);
299            looseMarshalByteSequence(wireFormat, info.getContent(), dataOut);
300            looseMarshalByteSequence(wireFormat, info.getMarshalledProperties(), dataOut);
301            looseMarshalNestedObject(wireFormat, (DataStructure)info.getDataStructure(), dataOut);
302            looseMarshalCachedObject(wireFormat, (DataStructure)info.getTargetConsumerId(), dataOut);
303            dataOut.writeBoolean(info.isCompressed());
304            dataOut.writeInt(info.getRedeliveryCounter());
305            looseMarshalObjectArray(wireFormat, info.getBrokerPath(), dataOut);
306            looseMarshalLong(wireFormat, info.getArrival(), dataOut);
307            looseMarshalString(info.getUserID(), dataOut);
308            dataOut.writeBoolean(info.isRecievedByDFBridge());
309            dataOut.writeBoolean(info.isDroppable());
310            looseMarshalObjectArray(wireFormat, info.getCluster(), dataOut);
311            looseMarshalLong(wireFormat, info.getBrokerInTime(), dataOut);
312            looseMarshalLong(wireFormat, info.getBrokerOutTime(), dataOut);
313            dataOut.writeBoolean(info.isJMSXGroupFirstForConsumer());
314    
315        }
316    }