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.DataStructure;
025    import org.apache.activemq.command.Message;
026    import org.apache.activemq.openwire.BooleanStream;
027    import org.apache.activemq.openwire.OpenWireFormat;
028    
029    /**
030     * Marshalling code for Open Wire Format for MessageMarshaller NOTE!: This file
031     * is auto generated - do not modify! if you need to make a change, please see
032     * the modify the groovy scripts in the under src/gram/script and then use maven
033     * openwire:generate to regenerate this file.
034     * 
035     * 
036     */
037    public abstract class MessageMarshaller extends BaseCommandMarshaller {
038    
039        /**
040         * Un-marshal an object instance from the data input stream
041         * 
042         * @param o the object to un-marshal
043         * @param dataIn the data input stream to build the object from
044         * @throws IOException
045         */
046        public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException {
047            super.tightUnmarshal(wireFormat, o, dataIn, bs);
048    
049            Message info = (Message)o;
050    
051            info.beforeUnmarshall(wireFormat);
052    
053            info.setProducerId((org.apache.activemq.command.ProducerId)tightUnmarsalCachedObject(wireFormat, dataIn, bs));
054            info.setDestination((org.apache.activemq.command.ActiveMQDestination)tightUnmarsalCachedObject(wireFormat, dataIn, bs));
055            info.setTransactionId((org.apache.activemq.command.TransactionId)tightUnmarsalCachedObject(wireFormat, dataIn, bs));
056            info.setOriginalDestination((org.apache.activemq.command.ActiveMQDestination)tightUnmarsalCachedObject(wireFormat, dataIn, bs));
057            info.setMessageId((org.apache.activemq.command.MessageId)tightUnmarsalNestedObject(wireFormat, dataIn, bs));
058            info.setOriginalTransactionId((org.apache.activemq.command.TransactionId)tightUnmarsalCachedObject(wireFormat, dataIn, bs));
059            info.setGroupID(tightUnmarshalString(dataIn, bs));
060            info.setGroupSequence(dataIn.readInt());
061            info.setCorrelationId(tightUnmarshalString(dataIn, bs));
062            info.setPersistent(bs.readBoolean());
063            info.setExpiration(tightUnmarshalLong(wireFormat, dataIn, bs));
064            info.setPriority(dataIn.readByte());
065            info.setReplyTo((org.apache.activemq.command.ActiveMQDestination)tightUnmarsalNestedObject(wireFormat, dataIn, bs));
066            info.setTimestamp(tightUnmarshalLong(wireFormat, dataIn, bs));
067            info.setType(tightUnmarshalString(dataIn, bs));
068            info.setContent(tightUnmarshalByteSequence(dataIn, bs));
069            info.setMarshalledProperties(tightUnmarshalByteSequence(dataIn, bs));
070            info.setDataStructure((org.apache.activemq.command.DataStructure)tightUnmarsalNestedObject(wireFormat, dataIn, bs));
071            info.setTargetConsumerId((org.apache.activemq.command.ConsumerId)tightUnmarsalCachedObject(wireFormat, dataIn, bs));
072            info.setCompressed(bs.readBoolean());
073            info.setRedeliveryCounter(dataIn.readInt());
074    
075            if (bs.readBoolean()) {
076                short size = dataIn.readShort();
077                org.apache.activemq.command.BrokerId value[] = new org.apache.activemq.command.BrokerId[size];
078                for (int i = 0; i < size; i++) {
079                    value[i] = (org.apache.activemq.command.BrokerId)tightUnmarsalNestedObject(wireFormat, dataIn, bs);
080                }
081                info.setBrokerPath(value);
082            } else {
083                info.setBrokerPath(null);
084            }
085            info.setArrival(tightUnmarshalLong(wireFormat, dataIn, bs));
086            info.setUserID(tightUnmarshalString(dataIn, bs));
087            info.setRecievedByDFBridge(bs.readBoolean());
088    
089            info.afterUnmarshall(wireFormat);
090    
091        }
092    
093        /**
094         * Write the booleans that this object uses to a BooleanStream
095         */
096        public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException {
097    
098            Message info = (Message)o;
099    
100            info.beforeMarshall(wireFormat);
101    
102            int rc = super.tightMarshal1(wireFormat, o, bs);
103            rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getProducerId(), bs);
104            rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getDestination(), bs);
105            rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getTransactionId(), bs);
106            rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getOriginalDestination(), bs);
107            rc += tightMarshalNestedObject1(wireFormat, (DataStructure)info.getMessageId(), bs);
108            rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getOriginalTransactionId(), bs);
109            rc += tightMarshalString1(info.getGroupID(), bs);
110            rc += tightMarshalString1(info.getCorrelationId(), bs);
111            bs.writeBoolean(info.isPersistent());
112            rc += tightMarshalLong1(wireFormat, info.getExpiration(), bs);
113            rc += tightMarshalNestedObject1(wireFormat, (DataStructure)info.getReplyTo(), bs);
114            rc += tightMarshalLong1(wireFormat, info.getTimestamp(), bs);
115            rc += tightMarshalString1(info.getType(), bs);
116            rc += tightMarshalByteSequence1(info.getContent(), bs);
117            rc += tightMarshalByteSequence1(info.getMarshalledProperties(), bs);
118            rc += tightMarshalNestedObject1(wireFormat, (DataStructure)info.getDataStructure(), bs);
119            rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getTargetConsumerId(), bs);
120            bs.writeBoolean(info.isCompressed());
121            rc += tightMarshalObjectArray1(wireFormat, info.getBrokerPath(), bs);
122            rc += tightMarshalLong1(wireFormat, info.getArrival(), bs);
123            rc += tightMarshalString1(info.getUserID(), bs);
124            bs.writeBoolean(info.isRecievedByDFBridge());
125    
126            return rc + 9;
127        }
128    
129        /**
130         * Write a object instance to data output stream
131         * 
132         * @param o the instance to be marshaled
133         * @param dataOut the output stream
134         * @throws IOException thrown if an error occurs
135         */
136        public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException {
137            super.tightMarshal2(wireFormat, o, dataOut, bs);
138    
139            Message info = (Message)o;
140            tightMarshalCachedObject2(wireFormat, (DataStructure)info.getProducerId(), dataOut, bs);
141            tightMarshalCachedObject2(wireFormat, (DataStructure)info.getDestination(), dataOut, bs);
142            tightMarshalCachedObject2(wireFormat, (DataStructure)info.getTransactionId(), dataOut, bs);
143            tightMarshalCachedObject2(wireFormat, (DataStructure)info.getOriginalDestination(), dataOut, bs);
144            tightMarshalNestedObject2(wireFormat, (DataStructure)info.getMessageId(), dataOut, bs);
145            tightMarshalCachedObject2(wireFormat, (DataStructure)info.getOriginalTransactionId(), dataOut, bs);
146            tightMarshalString2(info.getGroupID(), dataOut, bs);
147            dataOut.writeInt(info.getGroupSequence());
148            tightMarshalString2(info.getCorrelationId(), dataOut, bs);
149            bs.readBoolean();
150            tightMarshalLong2(wireFormat, info.getExpiration(), dataOut, bs);
151            dataOut.writeByte(info.getPriority());
152            tightMarshalNestedObject2(wireFormat, (DataStructure)info.getReplyTo(), dataOut, bs);
153            tightMarshalLong2(wireFormat, info.getTimestamp(), dataOut, bs);
154            tightMarshalString2(info.getType(), dataOut, bs);
155            tightMarshalByteSequence2(info.getContent(), dataOut, bs);
156            tightMarshalByteSequence2(info.getMarshalledProperties(), dataOut, bs);
157            tightMarshalNestedObject2(wireFormat, (DataStructure)info.getDataStructure(), dataOut, bs);
158            tightMarshalCachedObject2(wireFormat, (DataStructure)info.getTargetConsumerId(), dataOut, bs);
159            bs.readBoolean();
160            dataOut.writeInt(info.getRedeliveryCounter());
161            tightMarshalObjectArray2(wireFormat, info.getBrokerPath(), dataOut, bs);
162            tightMarshalLong2(wireFormat, info.getArrival(), dataOut, bs);
163            tightMarshalString2(info.getUserID(), dataOut, bs);
164            bs.readBoolean();
165    
166            info.afterMarshall(wireFormat);
167    
168        }
169    
170        /**
171         * Un-marshal an object instance from the data input stream
172         * 
173         * @param o the object to un-marshal
174         * @param dataIn the data input stream to build the object from
175         * @throws IOException
176         */
177        public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException {
178            super.looseUnmarshal(wireFormat, o, dataIn);
179    
180            Message info = (Message)o;
181    
182            info.beforeUnmarshall(wireFormat);
183    
184            info.setProducerId((org.apache.activemq.command.ProducerId)looseUnmarsalCachedObject(wireFormat, dataIn));
185            info.setDestination((org.apache.activemq.command.ActiveMQDestination)looseUnmarsalCachedObject(wireFormat, dataIn));
186            info.setTransactionId((org.apache.activemq.command.TransactionId)looseUnmarsalCachedObject(wireFormat, dataIn));
187            info.setOriginalDestination((org.apache.activemq.command.ActiveMQDestination)looseUnmarsalCachedObject(wireFormat, dataIn));
188            info.setMessageId((org.apache.activemq.command.MessageId)looseUnmarsalNestedObject(wireFormat, dataIn));
189            info.setOriginalTransactionId((org.apache.activemq.command.TransactionId)looseUnmarsalCachedObject(wireFormat, dataIn));
190            info.setGroupID(looseUnmarshalString(dataIn));
191            info.setGroupSequence(dataIn.readInt());
192            info.setCorrelationId(looseUnmarshalString(dataIn));
193            info.setPersistent(dataIn.readBoolean());
194            info.setExpiration(looseUnmarshalLong(wireFormat, dataIn));
195            info.setPriority(dataIn.readByte());
196            info.setReplyTo((org.apache.activemq.command.ActiveMQDestination)looseUnmarsalNestedObject(wireFormat, dataIn));
197            info.setTimestamp(looseUnmarshalLong(wireFormat, dataIn));
198            info.setType(looseUnmarshalString(dataIn));
199            info.setContent(looseUnmarshalByteSequence(dataIn));
200            info.setMarshalledProperties(looseUnmarshalByteSequence(dataIn));
201            info.setDataStructure((org.apache.activemq.command.DataStructure)looseUnmarsalNestedObject(wireFormat, dataIn));
202            info.setTargetConsumerId((org.apache.activemq.command.ConsumerId)looseUnmarsalCachedObject(wireFormat, dataIn));
203            info.setCompressed(dataIn.readBoolean());
204            info.setRedeliveryCounter(dataIn.readInt());
205    
206            if (dataIn.readBoolean()) {
207                short size = dataIn.readShort();
208                org.apache.activemq.command.BrokerId value[] = new org.apache.activemq.command.BrokerId[size];
209                for (int i = 0; i < size; i++) {
210                    value[i] = (org.apache.activemq.command.BrokerId)looseUnmarsalNestedObject(wireFormat, dataIn);
211                }
212                info.setBrokerPath(value);
213            } else {
214                info.setBrokerPath(null);
215            }
216            info.setArrival(looseUnmarshalLong(wireFormat, dataIn));
217            info.setUserID(looseUnmarshalString(dataIn));
218            info.setRecievedByDFBridge(dataIn.readBoolean());
219    
220            info.afterUnmarshall(wireFormat);
221    
222        }
223    
224        /**
225         * Write the booleans that this object uses to a BooleanStream
226         */
227        public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException {
228    
229            Message info = (Message)o;
230    
231            info.beforeMarshall(wireFormat);
232    
233            super.looseMarshal(wireFormat, o, dataOut);
234            looseMarshalCachedObject(wireFormat, (DataStructure)info.getProducerId(), dataOut);
235            looseMarshalCachedObject(wireFormat, (DataStructure)info.getDestination(), dataOut);
236            looseMarshalCachedObject(wireFormat, (DataStructure)info.getTransactionId(), dataOut);
237            looseMarshalCachedObject(wireFormat, (DataStructure)info.getOriginalDestination(), dataOut);
238            looseMarshalNestedObject(wireFormat, (DataStructure)info.getMessageId(), dataOut);
239            looseMarshalCachedObject(wireFormat, (DataStructure)info.getOriginalTransactionId(), dataOut);
240            looseMarshalString(info.getGroupID(), dataOut);
241            dataOut.writeInt(info.getGroupSequence());
242            looseMarshalString(info.getCorrelationId(), dataOut);
243            dataOut.writeBoolean(info.isPersistent());
244            looseMarshalLong(wireFormat, info.getExpiration(), dataOut);
245            dataOut.writeByte(info.getPriority());
246            looseMarshalNestedObject(wireFormat, (DataStructure)info.getReplyTo(), dataOut);
247            looseMarshalLong(wireFormat, info.getTimestamp(), dataOut);
248            looseMarshalString(info.getType(), dataOut);
249            looseMarshalByteSequence(wireFormat, info.getContent(), dataOut);
250            looseMarshalByteSequence(wireFormat, info.getMarshalledProperties(), dataOut);
251            looseMarshalNestedObject(wireFormat, (DataStructure)info.getDataStructure(), dataOut);
252            looseMarshalCachedObject(wireFormat, (DataStructure)info.getTargetConsumerId(), dataOut);
253            dataOut.writeBoolean(info.isCompressed());
254            dataOut.writeInt(info.getRedeliveryCounter());
255            looseMarshalObjectArray(wireFormat, info.getBrokerPath(), dataOut);
256            looseMarshalLong(wireFormat, info.getArrival(), dataOut);
257            looseMarshalString(info.getUserID(), dataOut);
258            dataOut.writeBoolean(info.isRecievedByDFBridge());
259    
260        }
261    }