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