/
ActiveMQMapMessage.h
349 lines (295 loc) · 12.3 KB
/
ActiveMQMapMessage.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _ACTIVEMQ_CONNECTOR_OPENWIRE_COMMANDS_ACTIVEMQMAPMESSAGE_H_
#define _ACTIVEMQ_CONNECTOR_OPENWIRE_COMMANDS_ACTIVEMQMAPMESSAGE_H_
// Turn off warning message for ignored exception specification
#ifdef _MSC_VER
#pragma warning( disable : 4290 )
#endif
#include <activemq/connector/openwire/commands/ActiveMQMessageBase.h>
#include <activemq/util/PrimitiveMap.h>
#include <decaf/lang/exceptions/NullPointerException.h>
#include <cms/MapMessage.h>
#include <vector>
#include <string>
namespace activemq{
namespace connector{
namespace openwire{
namespace commands{
class ActiveMQMapMessage :
public ActiveMQMessageBase<cms::MapMessage> {
private:
// Map Structure to hold unmarshalled Map Data
mutable util::PrimitiveMap* map;
public:
const static unsigned char ID_ACTIVEMQMAPMESSAGE = 25;
public:
ActiveMQMapMessage();
virtual ~ActiveMQMapMessage();
virtual unsigned char getDataStructureType() const;
/**
* Determine if this object is aware of marshalling and should have
* its before and after marshalling methods called. Defaults to false.
* @returns true if aware of marshalling
*/
virtual bool isMarshalAware() const {
return true;
}
/**
* Clone this object and return a new instance that the
* caller now owns, this will be an exact copy of this one
* @returns new copy of this object.
*/
virtual ActiveMQMapMessage* cloneDataStructure() const {
ActiveMQMapMessage* message = new ActiveMQMapMessage();
message->copyDataStructure( this );
return message;
}
/**
* Copy the contents of the passed object into this objects
* members, overwriting any existing data.
* @return src - Source Object
*/
virtual void copyDataStructure( const DataStructure* src ) {
ActiveMQMessageBase<cms::MapMessage>::copyDataStructure( src );
const ActiveMQMapMessage* srcMap =
dynamic_cast< const ActiveMQMapMessage* >( src );
if( srcMap != NULL && srcMap->map != NULL ) {
this->map = new util::PrimitiveMap( *srcMap->map );
}
}
/**
* Perform any processing needed before an marshal
* @param wireformat - the OpenWireFormat object in use.
*/
virtual void beforeMarshal( OpenWireFormat* wireFormat )
throw ( decaf::io::IOException );
/**
* Returns a string containing the information for this DataStructure
* such as its type and value of its elements.
* @return formatted string useful for debugging.
*/
virtual std::string toString() const{
std::ostringstream stream;
stream << "Begin Class = ActiveMQMapMessage" << std::endl;
stream << ActiveMQMessageBase<cms::MapMessage>::toString();
stream << "Begin Class = ActiveMQMapMessage" << std::endl;
return stream.str();
}
/**
* Compares the DataStructure passed in to this one, and returns if
* they are equivalent. Equivalent here means that they are of the
* same type, and that each element of the objects are the same.
* @returns true if DataStructure's are Equal.
*/
virtual bool equals( const DataStructure* value ) const {
return ActiveMQMessageBase<cms::MapMessage>::equals( value );
}
public: // CMS Message
/**
* Clonse this message exactly, returns a new instance that the
* caller is required to delete.
* @return new copy of this message
*/
virtual cms::MapMessage* clone() const {
return dynamic_cast<cms::MapMessage*>(
this->cloneDataStructure() );
}
public: // CMS MapMessage
/**
* Returns an Enumeration of all the names in the MapMessage
* object.
* @return STL Vector of String values, each of which is the
* name of an item in the MapMessage
* @throws CMSException
*/
virtual std::vector<std::string> getMapNames() const;
/**
* Indicates whether an item exists in this MapMessage object.
* @param name - String name of the Object in question
* @return boolean value indicating if the name is in the map
*/
virtual bool itemExists( const std::string& name ) const;
/**
* Returns the Boolean value of the Specified name
* @param name of the value to fetch from the map
* @throws CMSException
*/
virtual bool getBoolean( const std::string& name ) const
throw( cms::CMSException );
/**
* Sets a boolean value with the specified name into the Map.
* @param name - the name of the boolean
* @param value - the boolean value to set in the Map
* @throws CMSException
*/
virtual void setBoolean( const std::string& name,
bool value ) throw( cms::CMSException );
/**
* Returns the Byte value of the Specified name
* @param name of the value to fetch from the map
* @throws CMSException
*/
virtual unsigned char getByte( const std::string& name ) const
throw( cms::CMSException );
/**
* Sets a Byte value with the specified name into the Map.
* @param name - the name of the Byte
* @param value - the Byte value to set in the Map
* @throws CMSException
*/
virtual void setByte( const std::string& name,
unsigned char value )
throw( cms::CMSException );
/**
* Returns the Bytes value of the Specified name
* @param name of the value to fetch from the map
* @throws CMSException
*/
virtual std::vector<unsigned char> getBytes( const std::string& name ) const
throw( cms::CMSException );
/**
* Sets a Bytes value with the specified name into the Map.
* @param name - the name of the Bytes
* @param value - the Bytes value to set in the Map
* @throws CMSException
*/
virtual void setBytes( const std::string& name,
const std::vector<unsigned char>& value )
throw( cms::CMSException );
/**
* Returns the Char value of the Specified name
* @param name of the value to fetch from the map
* @throws CMSException
*/
virtual char getChar( const std::string& name ) const
throw( cms::CMSException );
/**
* Sets a Char value with the specified name into the Map.
* @param name - the name of the Char
* @param value - the Char value to set in the Map
* @throws CMSException
*/
virtual void setChar( const std::string& name, char value )
throw( cms::CMSException );
/**
* Returns the Double value of the Specified name
* @param name of the value to fetch from the map
* @throws CMSException
*/
virtual double getDouble( const std::string& name ) const
throw( cms::CMSException );
/**
* Sets a Double value with the specified name into the Map.
* @param name - the name of the Double
* @param value - the Double value to set in the Map
* @throws CMSException
*/
virtual void setDouble( const std::string& name,
double value ) throw( cms::CMSException );
/**
* Returns the Float value of the Specified name
* @param name of the value to fetch from the map
* @throws CMSException
*/
virtual float getFloat( const std::string& name ) const
throw( cms::CMSException );
/**
* Sets a Float value with the specified name into the Map.
* @param name - the name of the Float
* @param value - the Float value to set in the Map
* @throws CMSException
*/
virtual void setFloat( const std::string& name, float value )
throw( cms::CMSException );
/**
* Returns the Int value of the Specified name
* @param name of the value to fetch from the map
* @throws CMSException
*/
virtual int getInt( const std::string& name ) const
throw( cms::CMSException );
/**
* Sets a Int value with the specified name into the Map.
* @param name - the name of the Int
* @param value - the Int value to set in the Map
* @throws CMSException
*/
virtual void setInt( const std::string& name, int value )
throw( cms::CMSException );
/**
* Returns the Long value of the Specified name
* @param name of the value to fetch from the map
* @throws CMSException
*/
virtual long long getLong( const std::string& name ) const
throw( cms::CMSException );
/**
* Sets a Long value with the specified name into the Map.
* @param name - the name of the Long
* @param value - the Long value to set in the Map
* @throws CMSException
*/
virtual void setLong( const std::string& name, long long value )
throw( cms::CMSException );
/**
* Returns the Short value of the Specified name
* @param name of the value to fetch from the map
* @throws CMSException
*/
virtual short getShort( const std::string& name ) const
throw( cms::CMSException );
/**
* Sets a Short value with the specified name into the Map.
* @param name - the name of the Short
* @param value - the Short value to set in the Map
* @throws CMSException
*/
virtual void setShort( const std::string& name, short value )
throw( cms::CMSException );
/**
* Returns the String value of the Specified name
* @param name of the value to fetch from the map
* @throws CMSException
*/
virtual std::string getString( const std::string& name ) const
throw( cms::CMSException );
/**
* Sets a String value with the specified name into the Map.
* @param name - the name of the String
* @param value - the String value to set in the Map
* @throws CMSException
*/
virtual void setString( const std::string& name,
const std::string& value )
throw( cms::CMSException );
protected:
/**
* Fetches a reference to this objects PrimitiveMap, if one needs
* to be created or unmarshalled, this will perform the correct steps.
* @returns reference to a PrimtiveMap.
*/
util::PrimitiveMap& getMap() throw ( decaf::lang::exceptions::NullPointerException );
const util::PrimitiveMap& getMap() const throw ( decaf::lang::exceptions::NullPointerException );
/**
* Performs the unmarshal on the Map if needed, otherwise just returns
*/
virtual void checkMapIsUnmarshalled() const
throw ( decaf::lang::exceptions::NullPointerException );
};
}}}}
#endif /*_ACTIVEMQ_CONNECTOR_OPENWIRE_COMMANDS_ACTIVEMQMAPMESSAGE_H_*/