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.v3;
019    
020    import java.io.DataInput;
021    import java.io.DataOutput;
022    import java.io.IOException;
023    
024    import org.apache.activemq.command.BrokerInfo;
025    import org.apache.activemq.command.DataStructure;
026    import org.apache.activemq.openwire.BooleanStream;
027    import org.apache.activemq.openwire.OpenWireFormat;
028    
029    /**
030     * Marshalling code for Open Wire Format for BrokerInfoMarshaller
031     * 
032     * 
033     * NOTE!: This file is auto generated - do not modify! if you need to make a
034     * change, please see the modify the groovy scripts in the under src/gram/script
035     * and then use maven openwire:generate to regenerate this file.
036     * 
037     * 
038     */
039    public class BrokerInfoMarshaller extends BaseCommandMarshaller {
040    
041        /**
042         * Return the type of Data Structure we marshal
043         * 
044         * @return short representation of the type data structure
045         */
046        public byte getDataStructureType() {
047            return BrokerInfo.DATA_STRUCTURE_TYPE;
048        }
049    
050        /**
051         * @return a new object instance
052         */
053        public DataStructure createObject() {
054            return new BrokerInfo();
055        }
056    
057        /**
058         * Un-marshal an object instance from the data input stream
059         * 
060         * @param o the object to un-marshal
061         * @param dataIn the data input stream to build the object from
062         * @throws IOException
063         */
064        public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs)
065            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,
070                                                                                             bs));
071            info.setBrokerURL(tightUnmarshalString(dataIn, bs));
072    
073            if (bs.readBoolean()) {
074                short size = dataIn.readShort();
075                org.apache.activemq.command.BrokerInfo value[] = new org.apache.activemq.command.BrokerInfo[size];
076                for (int i = 0; i < size; i++) {
077                    value[i] = (org.apache.activemq.command.BrokerInfo)tightUnmarsalNestedObject(wireFormat,
078                                                                                                 dataIn, bs);
079                }
080                info.setPeerBrokerInfos(value);
081            } else {
082                info.setPeerBrokerInfos(null);
083            }
084            info.setBrokerName(tightUnmarshalString(dataIn, bs));
085            info.setSlaveBroker(bs.readBoolean());
086            info.setMasterBroker(bs.readBoolean());
087            info.setFaultTolerantConfiguration(bs.readBoolean());
088            info.setDuplexConnection(bs.readBoolean());
089            info.setNetworkConnection(bs.readBoolean());
090            info.setConnectionId(tightUnmarshalLong(wireFormat, dataIn, bs));
091            info.setBrokerUploadUrl(tightUnmarshalString(dataIn, bs));
092            info.setNetworkProperties(tightUnmarshalString(dataIn, bs));
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)
128            throws IOException {
129            super.tightMarshal2(wireFormat, o, dataOut, bs);
130    
131            BrokerInfo info = (BrokerInfo)o;
132            tightMarshalCachedObject2(wireFormat, (DataStructure)info.getBrokerId(), dataOut, bs);
133            tightMarshalString2(info.getBrokerURL(), dataOut, bs);
134            tightMarshalObjectArray2(wireFormat, info.getPeerBrokerInfos(), dataOut, bs);
135            tightMarshalString2(info.getBrokerName(), dataOut, bs);
136            bs.readBoolean();
137            bs.readBoolean();
138            bs.readBoolean();
139            bs.readBoolean();
140            bs.readBoolean();
141            tightMarshalLong2(wireFormat, info.getConnectionId(), dataOut, bs);
142            tightMarshalString2(info.getBrokerUploadUrl(), dataOut, bs);
143            tightMarshalString2(info.getNetworkProperties(), dataOut, bs);
144    
145        }
146    
147        /**
148         * Un-marshal an object instance from the data input stream
149         * 
150         * @param o the object to un-marshal
151         * @param dataIn the data input stream to build the object from
152         * @throws IOException
153         */
154        public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException {
155            super.looseUnmarshal(wireFormat, o, dataIn);
156    
157            BrokerInfo info = (BrokerInfo)o;
158            info.setBrokerId((org.apache.activemq.command.BrokerId)looseUnmarsalCachedObject(wireFormat, dataIn));
159            info.setBrokerURL(looseUnmarshalString(dataIn));
160    
161            if (dataIn.readBoolean()) {
162                short size = dataIn.readShort();
163                org.apache.activemq.command.BrokerInfo value[] = new org.apache.activemq.command.BrokerInfo[size];
164                for (int i = 0; i < size; i++) {
165                    value[i] = (org.apache.activemq.command.BrokerInfo)looseUnmarsalNestedObject(wireFormat,
166                                                                                                 dataIn);
167                }
168                info.setPeerBrokerInfos(value);
169            } else {
170                info.setPeerBrokerInfos(null);
171            }
172            info.setBrokerName(looseUnmarshalString(dataIn));
173            info.setSlaveBroker(dataIn.readBoolean());
174            info.setMasterBroker(dataIn.readBoolean());
175            info.setFaultTolerantConfiguration(dataIn.readBoolean());
176            info.setDuplexConnection(dataIn.readBoolean());
177            info.setNetworkConnection(dataIn.readBoolean());
178            info.setConnectionId(looseUnmarshalLong(wireFormat, dataIn));
179            info.setBrokerUploadUrl(looseUnmarshalString(dataIn));
180            info.setNetworkProperties(looseUnmarshalString(dataIn));
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    }