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.v9;
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 BrokerInfoMarshaller
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 class BrokerInfoMarshaller extends BaseCommandMarshaller {
042
043 /**
044 * Return the type of Data Structure we marshal
045 * @return short representation of the type data structure
046 */
047 public byte getDataStructureType() {
048 return BrokerInfo.DATA_STRUCTURE_TYPE;
049 }
050
051 /**
052 * @return a new object instance
053 */
054 public DataStructure createObject() {
055 return new BrokerInfo();
056 }
057
058 /**
059 * Un-marshal an object instance from the data input stream
060 *
061 * @param o the object to un-marshal
062 * @param dataIn the data input stream to build the object from
063 * @throws IOException
064 */
065 public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException {
066 super.tightUnmarshal(wireFormat, o, dataIn, bs);
067
068 BrokerInfo info = (BrokerInfo)o;
069 info.setBrokerId((org.apache.activemq.command.BrokerId) tightUnmarsalCachedObject(wireFormat, dataIn, bs));
070 info.setBrokerURL(tightUnmarshalString(dataIn, bs));
071
072 if (bs.readBoolean()) {
073 short size = dataIn.readShort();
074 org.apache.activemq.command.BrokerInfo value[] = new org.apache.activemq.command.BrokerInfo[size];
075 for( int i=0; i < size; i++ ) {
076 value[i] = (org.apache.activemq.command.BrokerInfo) tightUnmarsalNestedObject(wireFormat,dataIn, bs);
077 }
078 info.setPeerBrokerInfos(value);
079 }
080 else {
081 info.setPeerBrokerInfos(null);
082 }
083 info.setBrokerName(tightUnmarshalString(dataIn, bs));
084 info.setSlaveBroker(bs.readBoolean());
085 info.setMasterBroker(bs.readBoolean());
086 info.setFaultTolerantConfiguration(bs.readBoolean());
087 info.setDuplexConnection(bs.readBoolean());
088 info.setNetworkConnection(bs.readBoolean());
089 info.setConnectionId(tightUnmarshalLong(wireFormat, dataIn, bs));
090 info.setBrokerUploadUrl(tightUnmarshalString(dataIn, bs));
091 info.setNetworkProperties(tightUnmarshalString(dataIn, bs));
092
093 }
094
095
096 /**
097 * Write the booleans that this object uses to a BooleanStream
098 */
099 public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException {
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 o, DataOutput dataOut, BooleanStream bs) throws IOException {
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 o, DataInput dataIn) throws IOException {
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 o, DataOutput dataOut) throws IOException {
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 }