KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > activemq > openwire > v1 > MessageMarshaller


1 /**
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one or more
4  * contributor license agreements. See the NOTICE file distributed with
5  * this work for additional information regarding copyright ownership.
6  * The ASF licenses this file to You under the Apache License, Version 2.0
7  * (the "License"); you may not use this file except in compliance with
8  * the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18
19 package org.apache.activemq.openwire.v1;
20
21 import java.io.DataInput JavaDoc;
22 import java.io.DataOutput JavaDoc;
23 import java.io.IOException JavaDoc;
24
25 import org.apache.activemq.openwire.*;
26 import org.apache.activemq.command.*;
27
28
29
30 /**
31  * Marshalling code for Open Wire Format for MessageMarshaller
32  *
33  *
34  * NOTE!: This file is auto generated - do not modify!
35  * if you need to make a change, please see the modify the groovy scripts in the
36  * under src/gram/script and then use maven openwire:generate to regenerate
37  * this file.
38  *
39  * @version $Revision$
40  */

41 public abstract class MessageMarshaller extends BaseCommandMarshaller {
42
43     /**
44      * Un-marshal an object instance from the data input stream
45      *
46      * @param o the object to un-marshal
47      * @param dataIn the data input stream to build the object from
48      * @throws IOException
49      */

50     public void tightUnmarshal(OpenWireFormat wireFormat, Object JavaDoc o, DataInput JavaDoc dataIn, BooleanStream bs) throws IOException JavaDoc {
51         super.tightUnmarshal(wireFormat, o, dataIn, bs);
52
53         Message info = (Message)o;
54
55         info.beforeUnmarshall(wireFormat);
56         
57         info.setProducerId((org.apache.activemq.command.ProducerId) tightUnmarsalCachedObject(wireFormat, dataIn, bs));
58         info.setDestination((org.apache.activemq.command.ActiveMQDestination) tightUnmarsalCachedObject(wireFormat, dataIn, bs));
59         info.setTransactionId((org.apache.activemq.command.TransactionId) tightUnmarsalCachedObject(wireFormat, dataIn, bs));
60         info.setOriginalDestination((org.apache.activemq.command.ActiveMQDestination) tightUnmarsalCachedObject(wireFormat, dataIn, bs));
61         info.setMessageId((org.apache.activemq.command.MessageId) tightUnmarsalNestedObject(wireFormat, dataIn, bs));
62         info.setOriginalTransactionId((org.apache.activemq.command.TransactionId) tightUnmarsalCachedObject(wireFormat, dataIn, bs));
63         info.setGroupID(tightUnmarshalString(dataIn, bs));
64         info.setGroupSequence(dataIn.readInt());
65         info.setCorrelationId(tightUnmarshalString(dataIn, bs));
66         info.setPersistent(bs.readBoolean());
67         info.setExpiration(tightUnmarshalLong(wireFormat, dataIn, bs));
68         info.setPriority(dataIn.readByte());
69         info.setReplyTo((org.apache.activemq.command.ActiveMQDestination) tightUnmarsalNestedObject(wireFormat, dataIn, bs));
70         info.setTimestamp(tightUnmarshalLong(wireFormat, dataIn, bs));
71         info.setType(tightUnmarshalString(dataIn, bs));
72         info.setContent(tightUnmarshalByteSequence(dataIn, bs));
73         info.setMarshalledProperties(tightUnmarshalByteSequence(dataIn, bs));
74         info.setDataStructure((org.apache.activemq.command.DataStructure) tightUnmarsalNestedObject(wireFormat, dataIn, bs));
75         info.setTargetConsumerId((org.apache.activemq.command.ConsumerId) tightUnmarsalCachedObject(wireFormat, dataIn, bs));
76         info.setCompressed(bs.readBoolean());
77         info.setRedeliveryCounter(dataIn.readInt());
78
79         if (bs.readBoolean()) {
80             short size = dataIn.readShort();
81             org.apache.activemq.command.BrokerId value[] = new org.apache.activemq.command.BrokerId[size];
82             for( int i=0; i < size; i++ ) {
83                 value[i] = (org.apache.activemq.command.BrokerId) tightUnmarsalNestedObject(wireFormat,dataIn, bs);
84             }
85             info.setBrokerPath(value);
86         }
87         else {
88             info.setBrokerPath(null);
89         }
90         info.setArrival(tightUnmarshalLong(wireFormat, dataIn, bs));
91         info.setUserID(tightUnmarshalString(dataIn, bs));
92         info.setRecievedByDFBridge(bs.readBoolean());
93
94         info.afterUnmarshall(wireFormat);
95
96     }
97
98
99     /**
100      * Write the booleans that this object uses to a BooleanStream
101      */

102     public int tightMarshal1(OpenWireFormat wireFormat, Object JavaDoc o, BooleanStream bs) throws IOException JavaDoc {
103
104         Message info = (Message)o;
105
106         info.beforeMarshall(wireFormat);
107
108         int rc = super.tightMarshal1(wireFormat, o, bs);
109         rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getProducerId(), bs);
110         rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getDestination(), bs);
111         rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getTransactionId(), bs);
112         rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getOriginalDestination(), bs);
113         rc += tightMarshalNestedObject1(wireFormat, (DataStructure)info.getMessageId(), bs);
114         rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getOriginalTransactionId(), bs);
115         rc += tightMarshalString1(info.getGroupID(), bs);
116         rc += tightMarshalString1(info.getCorrelationId(), bs);
117         bs.writeBoolean(info.isPersistent());
118         rc+=tightMarshalLong1(wireFormat, info.getExpiration(), bs);
119         rc += tightMarshalNestedObject1(wireFormat, (DataStructure)info.getReplyTo(), bs);
120         rc+=tightMarshalLong1(wireFormat, info.getTimestamp(), bs);
121         rc += tightMarshalString1(info.getType(), bs);
122         rc += tightMarshalByteSequence1(info.getContent(), bs);
123         rc += tightMarshalByteSequence1(info.getMarshalledProperties(), bs);
124         rc += tightMarshalNestedObject1(wireFormat, (DataStructure)info.getDataStructure(), bs);
125         rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getTargetConsumerId(), bs);
126         bs.writeBoolean(info.isCompressed());
127         rc += tightMarshalObjectArray1(wireFormat, info.getBrokerPath(), bs);
128         rc+=tightMarshalLong1(wireFormat, info.getArrival(), bs);
129         rc += tightMarshalString1(info.getUserID(), bs);
130         bs.writeBoolean(info.isRecievedByDFBridge());
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 JavaDoc o, DataOutput JavaDoc dataOut, BooleanStream bs) throws IOException JavaDoc {
143         super.tightMarshal2(wireFormat, o, dataOut, bs);
144
145         Message info = (Message)o;
146         tightMarshalCachedObject2(wireFormat, (DataStructure)info.getProducerId(), dataOut, bs);
147         tightMarshalCachedObject2(wireFormat, (DataStructure)info.getDestination(), dataOut, bs);
148         tightMarshalCachedObject2(wireFormat, (DataStructure)info.getTransactionId(), dataOut, bs);
149         tightMarshalCachedObject2(wireFormat, (DataStructure)info.getOriginalDestination(), dataOut, bs);
150         tightMarshalNestedObject2(wireFormat, (DataStructure)info.getMessageId(), dataOut, bs);
151         tightMarshalCachedObject2(wireFormat, (DataStructure)info.getOriginalTransactionId(), dataOut, bs);
152         tightMarshalString2(info.getGroupID(), dataOut, bs);
153         dataOut.writeInt(info.getGroupSequence());
154         tightMarshalString2(info.getCorrelationId(), dataOut, bs);
155         bs.readBoolean();
156         tightMarshalLong2(wireFormat, info.getExpiration(), dataOut, bs);
157         dataOut.writeByte(info.getPriority());
158         tightMarshalNestedObject2(wireFormat, (DataStructure)info.getReplyTo(), dataOut, bs);
159         tightMarshalLong2(wireFormat, info.getTimestamp(), dataOut, bs);
160         tightMarshalString2(info.getType(), dataOut, bs);
161         tightMarshalByteSequence2(info.getContent(), dataOut, bs);
162         tightMarshalByteSequence2(info.getMarshalledProperties(), dataOut, bs);
163         tightMarshalNestedObject2(wireFormat, (DataStructure)info.getDataStructure(), dataOut, bs);
164         tightMarshalCachedObject2(wireFormat, (DataStructure)info.getTargetConsumerId(), dataOut, bs);
165         bs.readBoolean();
166         dataOut.writeInt(info.getRedeliveryCounter());
167         tightMarshalObjectArray2(wireFormat, info.getBrokerPath(), dataOut, bs);
168         tightMarshalLong2(wireFormat, info.getArrival(), dataOut, bs);
169         tightMarshalString2(info.getUserID(), dataOut, bs);
170         bs.readBoolean();
171
172         info.afterMarshall(wireFormat);
173
174     }
175
176     /**
177      * Un-marshal an object instance from the data input stream
178      *
179      * @param o the object to un-marshal
180      * @param dataIn the data input stream to build the object from
181      * @throws IOException
182      */

183     public void looseUnmarshal(OpenWireFormat wireFormat, Object JavaDoc o, DataInput JavaDoc dataIn) throws IOException JavaDoc {
184         super.looseUnmarshal(wireFormat, o, dataIn);
185
186         Message info = (Message)o;
187
188         info.beforeUnmarshall(wireFormat);
189         
190         info.setProducerId((org.apache.activemq.command.ProducerId) looseUnmarsalCachedObject(wireFormat, dataIn));
191         info.setDestination((org.apache.activemq.command.ActiveMQDestination) looseUnmarsalCachedObject(wireFormat, dataIn));
192         info.setTransactionId((org.apache.activemq.command.TransactionId) looseUnmarsalCachedObject(wireFormat, dataIn));
193         info.setOriginalDestination((org.apache.activemq.command.ActiveMQDestination) looseUnmarsalCachedObject(wireFormat, dataIn));
194         info.setMessageId((org.apache.activemq.command.MessageId) looseUnmarsalNestedObject(wireFormat, dataIn));
195         info.setOriginalTransactionId((org.apache.activemq.command.TransactionId) looseUnmarsalCachedObject(wireFormat, dataIn));
196         info.setGroupID(looseUnmarshalString(dataIn));
197         info.setGroupSequence(dataIn.readInt());
198         info.setCorrelationId(looseUnmarshalString(dataIn));
199         info.setPersistent(dataIn.readBoolean());
200         info.setExpiration(looseUnmarshalLong(wireFormat, dataIn));
201         info.setPriority(dataIn.readByte());
202         info.setReplyTo((org.apache.activemq.command.ActiveMQDestination) looseUnmarsalNestedObject(wireFormat, dataIn));
203         info.setTimestamp(looseUnmarshalLong(wireFormat, dataIn));
204         info.setType(looseUnmarshalString(dataIn));
205         info.setContent(looseUnmarshalByteSequence(dataIn));
206         info.setMarshalledProperties(looseUnmarshalByteSequence(dataIn));
207         info.setDataStructure((org.apache.activemq.command.DataStructure) looseUnmarsalNestedObject(wireFormat, dataIn));
208         info.setTargetConsumerId((org.apache.activemq.command.ConsumerId) looseUnmarsalCachedObject(wireFormat, dataIn));
209         info.setCompressed(dataIn.readBoolean());
210         info.setRedeliveryCounter(dataIn.readInt());
211
212         if (dataIn.readBoolean()) {
213             short size = dataIn.readShort();
214             org.apache.activemq.command.BrokerId value[] = new org.apache.activemq.command.BrokerId[size];
215             for( int i=0; i < size; i++ ) {
216                 value[i] = (org.apache.activemq.command.BrokerId) looseUnmarsalNestedObject(wireFormat,dataIn);
217             }
218             info.setBrokerPath(value);
219         }
220         else {
221             info.setBrokerPath(null);
222         }
223         info.setArrival(looseUnmarshalLong(wireFormat, dataIn));
224         info.setUserID(looseUnmarshalString(dataIn));
225         info.setRecievedByDFBridge(dataIn.readBoolean());
226
227         info.afterUnmarshall(wireFormat);
228
229     }
230
231
232     /**
233      * Write the booleans that this object uses to a BooleanStream
234      */

235     public void looseMarshal(OpenWireFormat wireFormat, Object JavaDoc o, DataOutput JavaDoc dataOut) throws IOException JavaDoc {
236
237         Message info = (Message)o;
238
239         info.beforeMarshall(wireFormat);
240
241         super.looseMarshal(wireFormat, o, dataOut);
242         looseMarshalCachedObject(wireFormat, (DataStructure)info.getProducerId(), dataOut);
243         looseMarshalCachedObject(wireFormat, (DataStructure)info.getDestination(), dataOut);
244         looseMarshalCachedObject(wireFormat, (DataStructure)info.getTransactionId(), dataOut);
245         looseMarshalCachedObject(wireFormat, (DataStructure)info.getOriginalDestination(), dataOut);
246         looseMarshalNestedObject(wireFormat, (DataStructure)info.getMessageId(), dataOut);
247         looseMarshalCachedObject(wireFormat, (DataStructure)info.getOriginalTransactionId(), dataOut);
248         looseMarshalString(info.getGroupID(), dataOut);
249         dataOut.writeInt(info.getGroupSequence());
250         looseMarshalString(info.getCorrelationId(), dataOut);
251         dataOut.writeBoolean(info.isPersistent());
252         looseMarshalLong(wireFormat, info.getExpiration(), dataOut);
253         dataOut.writeByte(info.getPriority());
254         looseMarshalNestedObject(wireFormat, (DataStructure)info.getReplyTo(), dataOut);
255         looseMarshalLong(wireFormat, info.getTimestamp(), dataOut);
256         looseMarshalString(info.getType(), dataOut);
257         looseMarshalByteSequence(wireFormat, info.getContent(), dataOut);
258         looseMarshalByteSequence(wireFormat, info.getMarshalledProperties(), dataOut);
259         looseMarshalNestedObject(wireFormat, (DataStructure)info.getDataStructure(), dataOut);
260         looseMarshalCachedObject(wireFormat, (DataStructure)info.getTargetConsumerId(), dataOut);
261         dataOut.writeBoolean(info.isCompressed());
262         dataOut.writeInt(info.getRedeliveryCounter());
263         looseMarshalObjectArray(wireFormat, info.getBrokerPath(), dataOut);
264         looseMarshalLong(wireFormat, info.getArrival(), dataOut);
265         looseMarshalString(info.getUserID(), dataOut);
266         dataOut.writeBoolean(info.isRecievedByDFBridge());
267
268     }
269 }
270
Popular Tags