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.ConnectionInfo;
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 ConnectionInfoMarshaller
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 ConnectionInfoMarshaller 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 ConnectionInfo.DATA_STRUCTURE_TYPE;
048        }
049    
050        /**
051         * @return a new object instance
052         */
053        public DataStructure createObject() {
054            return new ConnectionInfo();
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            ConnectionInfo info = (ConnectionInfo)o;
069            info.setConnectionId((org.apache.activemq.command.ConnectionId)tightUnmarsalCachedObject(wireFormat,
070                                                                                                     dataIn, bs));
071            info.setClientId(tightUnmarshalString(dataIn, bs));
072            info.setPassword(tightUnmarshalString(dataIn, bs));
073            info.setUserName(tightUnmarshalString(dataIn, bs));
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,
080                                                                                               dataIn, bs);
081                }
082                info.setBrokerPath(value);
083            } else {
084                info.setBrokerPath(null);
085            }
086            info.setBrokerMasterConnector(bs.readBoolean());
087            info.setManageable(bs.readBoolean());
088    
089        }
090    
091        /**
092         * Write the booleans that this object uses to a BooleanStream
093         */
094        public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException {
095    
096            ConnectionInfo info = (ConnectionInfo)o;
097    
098            int rc = super.tightMarshal1(wireFormat, o, bs);
099            rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getConnectionId(), bs);
100            rc += tightMarshalString1(info.getClientId(), bs);
101            rc += tightMarshalString1(info.getPassword(), bs);
102            rc += tightMarshalString1(info.getUserName(), bs);
103            rc += tightMarshalObjectArray1(wireFormat, info.getBrokerPath(), bs);
104            bs.writeBoolean(info.isBrokerMasterConnector());
105            bs.writeBoolean(info.isManageable());
106    
107            return rc + 0;
108        }
109    
110        /**
111         * Write a object instance to data output stream
112         * 
113         * @param o the instance to be marshaled
114         * @param dataOut the output stream
115         * @throws IOException thrown if an error occurs
116         */
117        public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs)
118            throws IOException {
119            super.tightMarshal2(wireFormat, o, dataOut, bs);
120    
121            ConnectionInfo info = (ConnectionInfo)o;
122            tightMarshalCachedObject2(wireFormat, (DataStructure)info.getConnectionId(), dataOut, bs);
123            tightMarshalString2(info.getClientId(), dataOut, bs);
124            tightMarshalString2(info.getPassword(), dataOut, bs);
125            tightMarshalString2(info.getUserName(), dataOut, bs);
126            tightMarshalObjectArray2(wireFormat, info.getBrokerPath(), dataOut, bs);
127            bs.readBoolean();
128            bs.readBoolean();
129    
130        }
131    
132        /**
133         * Un-marshal an object instance from the data input stream
134         * 
135         * @param o the object to un-marshal
136         * @param dataIn the data input stream to build the object from
137         * @throws IOException
138         */
139        public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException {
140            super.looseUnmarshal(wireFormat, o, dataIn);
141    
142            ConnectionInfo info = (ConnectionInfo)o;
143            info.setConnectionId((org.apache.activemq.command.ConnectionId)looseUnmarsalCachedObject(wireFormat,
144                                                                                                     dataIn));
145            info.setClientId(looseUnmarshalString(dataIn));
146            info.setPassword(looseUnmarshalString(dataIn));
147            info.setUserName(looseUnmarshalString(dataIn));
148    
149            if (dataIn.readBoolean()) {
150                short size = dataIn.readShort();
151                org.apache.activemq.command.BrokerId value[] = new org.apache.activemq.command.BrokerId[size];
152                for (int i = 0; i < size; i++) {
153                    value[i] = (org.apache.activemq.command.BrokerId)looseUnmarsalNestedObject(wireFormat, dataIn);
154                }
155                info.setBrokerPath(value);
156            } else {
157                info.setBrokerPath(null);
158            }
159            info.setBrokerMasterConnector(dataIn.readBoolean());
160            info.setManageable(dataIn.readBoolean());
161    
162        }
163    
164        /**
165         * Write the booleans that this object uses to a BooleanStream
166         */
167        public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException {
168    
169            ConnectionInfo info = (ConnectionInfo)o;
170    
171            super.looseMarshal(wireFormat, o, dataOut);
172            looseMarshalCachedObject(wireFormat, (DataStructure)info.getConnectionId(), dataOut);
173            looseMarshalString(info.getClientId(), dataOut);
174            looseMarshalString(info.getPassword(), dataOut);
175            looseMarshalString(info.getUserName(), dataOut);
176            looseMarshalObjectArray(wireFormat, info.getBrokerPath(), dataOut);
177            dataOut.writeBoolean(info.isBrokerMasterConnector());
178            dataOut.writeBoolean(info.isManageable());
179    
180        }
181    }