KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > activemq > openwire > v3 > BrokerInfoMarshaller


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.v3;
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 BrokerInfoMarshaller
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 class BrokerInfoMarshaller extends BaseCommandMarshaller {
42
43     /**
44      * Return the type of Data Structure we marshal
45      * @return short representation of the type data structure
46      */

47     public byte getDataStructureType() {
48         return BrokerInfo.DATA_STRUCTURE_TYPE;
49     }
50     
51     /**
52      * @return a new object instance
53      */

54     public DataStructure createObject() {
55         return new BrokerInfo();
56     }
57
58     /**
59      * Un-marshal an object instance from the data input stream
60      *
61      * @param o the object to un-marshal
62      * @param dataIn the data input stream to build the object from
63      * @throws IOException
64      */

65     public void tightUnmarshal(OpenWireFormat wireFormat, Object JavaDoc o, DataInput JavaDoc dataIn, BooleanStream bs) throws IOException JavaDoc {
66         super.tightUnmarshal(wireFormat, o, dataIn, bs);
67
68         BrokerInfo info = (BrokerInfo)o;
69         info.setBrokerId((org.apache.activemq.command.BrokerId) tightUnmarsalCachedObject(wireFormat, dataIn, bs));
70         info.setBrokerURL(tightUnmarshalString(dataIn, bs));
71
72         if (bs.readBoolean()) {
73             short size = dataIn.readShort();
74             org.apache.activemq.command.BrokerInfo value[] = new org.apache.activemq.command.BrokerInfo[size];
75             for( int i=0; i < size; i++ ) {
76                 value[i] = (org.apache.activemq.command.BrokerInfo) tightUnmarsalNestedObject(wireFormat,dataIn, bs);
77             }
78             info.setPeerBrokerInfos(value);
79         }
80         else {
81             info.setPeerBrokerInfos(null);
82         }
83         info.setBrokerName(tightUnmarshalString(dataIn, bs));
84         info.setSlaveBroker(bs.readBoolean());
85         info.setMasterBroker(bs.readBoolean());
86         info.setFaultTolerantConfiguration(bs.readBoolean());
87         info.setDuplexConnection(bs.readBoolean());
88         info.setNetworkConnection(bs.readBoolean());
89         info.setConnectionId(tightUnmarshalLong(wireFormat, dataIn, bs));
90         info.setBrokerUploadUrl(tightUnmarshalString(dataIn, bs));
91         info.setNetworkProperties(tightUnmarshalString(dataIn, bs));
92
93     }
94
95
96     /**
97      * Write the booleans that this object uses to a BooleanStream
98      */

99     public int tightMarshal1(OpenWireFormat wireFormat, Object JavaDoc o, BooleanStream bs) throws IOException JavaDoc {
100
101         BrokerInfo info = (BrokerInfo)o;
102
103         int rc = super.tightMarshal1(wireFormat, o, bs);
104         rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getBrokerId(), bs);
105         rc += tightMarshalString1(info.getBrokerURL(), bs);
106         rc += tightMarshalObjectArray1(wireFormat, info.getPeerBrokerInfos(), bs);
107         rc += tightMarshalString1(info.getBrokerName(), bs);
108         bs.writeBoolean(info.isSlaveBroker());
109         bs.writeBoolean(info.isMasterBroker());
110         bs.writeBoolean(info.isFaultTolerantConfiguration());
111         bs.writeBoolean(info.isDuplexConnection());
112         bs.writeBoolean(info.isNetworkConnection());
113         rc+=tightMarshalLong1(wireFormat, info.getConnectionId(), bs);
114         rc += tightMarshalString1(info.getBrokerUploadUrl(), bs);
115         rc += tightMarshalString1(info.getNetworkProperties(), bs);
116
117         return rc + 0;
118     }
119
120     /**
121      * Write a object instance to data output stream
122      *
123      * @param o the instance to be marshaled
124      * @param dataOut the output stream
125      * @throws IOException thrown if an error occurs
126      */

127     public void tightMarshal2(OpenWireFormat wireFormat, Object JavaDoc o, DataOutput JavaDoc dataOut, BooleanStream bs) throws IOException JavaDoc {
128         super.tightMarshal2(wireFormat, o, dataOut, bs);
129
130         BrokerInfo info = (BrokerInfo)o;
131         tightMarshalCachedObject2(wireFormat, (DataStructure)info.getBrokerId(), dataOut, bs);
132         tightMarshalString2(info.getBrokerURL(), dataOut, bs);
133         tightMarshalObjectArray2(wireFormat, info.getPeerBrokerInfos(), dataOut, bs);
134         tightMarshalString2(info.getBrokerName(), dataOut, bs);
135         bs.readBoolean();
136         bs.readBoolean();
137         bs.readBoolean();
138         bs.readBoolean();
139         bs.readBoolean();
140         tightMarshalLong2(wireFormat, info.getConnectionId(), dataOut, bs);
141         tightMarshalString2(info.getBrokerUploadUrl(), dataOut, bs);
142         tightMarshalString2(info.getNetworkProperties(), dataOut, bs);
143
144     }
145
146     /**
147      * Un-marshal an object instance from the data input stream
148      *
149      * @param o the object to un-marshal
150      * @param dataIn the data input stream to build the object from
151      * @throws IOException
152      */

153     public void looseUnmarshal(OpenWireFormat wireFormat, Object JavaDoc o, DataInput JavaDoc dataIn) throws IOException JavaDoc {
154         super.looseUnmarshal(wireFormat, o, dataIn);
155
156         BrokerInfo info = (BrokerInfo)o;
157         info.setBrokerId((org.apache.activemq.command.BrokerId) looseUnmarsalCachedObject(wireFormat, dataIn));
158         info.setBrokerURL(looseUnmarshalString(dataIn));
159
160         if (dataIn.readBoolean()) {
161             short size = dataIn.readShort();
162             org.apache.activemq.command.BrokerInfo value[] = new org.apache.activemq.command.BrokerInfo[size];
163             for( int i=0; i < size; i++ ) {
164                 value[i] = (org.apache.activemq.command.BrokerInfo) looseUnmarsalNestedObject(wireFormat,dataIn);
165             }
166             info.setPeerBrokerInfos(value);
167         }
168         else {
169             info.setPeerBrokerInfos(null);
170         }
171         info.setBrokerName(looseUnmarshalString(dataIn));
172         info.setSlaveBroker(dataIn.readBoolean());
173         info.setMasterBroker(dataIn.readBoolean());
174         info.setFaultTolerantConfiguration(dataIn.readBoolean());
175         info.setDuplexConnection(dataIn.readBoolean());
176         info.setNetworkConnection(dataIn.readBoolean());
177         info.setConnectionId(looseUnmarshalLong(wireFormat, dataIn));
178         info.setBrokerUploadUrl(looseUnmarshalString(dataIn));
179         info.setNetworkProperties(looseUnmarshalString(dataIn));
180
181     }
182
183
184     /**
185      * Write the booleans that this object uses to a BooleanStream
186      */

187     public void looseMarshal(OpenWireFormat wireFormat, Object JavaDoc o, DataOutput JavaDoc dataOut) throws IOException JavaDoc {
188
189         BrokerInfo info = (BrokerInfo)o;
190
191         super.looseMarshal(wireFormat, o, dataOut);
192         looseMarshalCachedObject(wireFormat, (DataStructure)info.getBrokerId(), dataOut);
193         looseMarshalString(info.getBrokerURL(), dataOut);
194         looseMarshalObjectArray(wireFormat, info.getPeerBrokerInfos(), dataOut);
195         looseMarshalString(info.getBrokerName(), dataOut);
196         dataOut.writeBoolean(info.isSlaveBroker());
197         dataOut.writeBoolean(info.isMasterBroker());
198         dataOut.writeBoolean(info.isFaultTolerantConfiguration());
199         dataOut.writeBoolean(info.isDuplexConnection());
200         dataOut.writeBoolean(info.isNetworkConnection());
201         looseMarshalLong(wireFormat, info.getConnectionId(), dataOut);
202         looseMarshalString(info.getBrokerUploadUrl(), dataOut);
203         looseMarshalString(info.getNetworkProperties(), dataOut);
204
205     }
206 }
207
Popular Tags