00001
00018 #ifndef _ACTIVEMQ_UTIL_PRIMITIVEVALUENODE_H_
00019 #define _ACTIVEMQ_UTIL_PRIMITIVEVALUENODE_H_
00020
00021 #include <activemq/util/Config.h>
00022 #include <decaf/util/NoSuchElementException.h>
00023 #include <decaf/util/Map.h>
00024 #include <decaf/util/List.h>
00025
00026 namespace activemq {
00027 namespace util {
00028
00038 class AMQCPP_API PrimitiveValueNode {
00039 public:
00040
00044 enum PrimitiveType{
00045 NULL_TYPE = 0,
00046 BOOLEAN_TYPE = 1,
00047 BYTE_TYPE = 2,
00048 CHAR_TYPE = 3,
00049 SHORT_TYPE = 4,
00050 INTEGER_TYPE = 5,
00051 LONG_TYPE = 6,
00052 DOUBLE_TYPE = 7,
00053 FLOAT_TYPE = 8,
00054 STRING_TYPE = 9,
00055 BYTE_ARRAY_TYPE = 10,
00056 MAP_TYPE = 11,
00057 LIST_TYPE = 12,
00058 BIG_STRING_TYPE = 13
00059 };
00060
00064 union PrimitiveValue {
00065
00066 bool boolValue;
00067 unsigned char byteValue;
00068 char charValue;
00069 short shortValue;
00070 int intValue;
00071 long long longValue;
00072 double doubleValue;
00073 float floatValue;
00074 std::string* stringValue;
00075 std::vector<unsigned char>* byteArrayValue;
00076 decaf::util::List<PrimitiveValueNode>* listValue;
00077 decaf::util::Map<std::string, PrimitiveValueNode>* mapValue;
00078
00079 };
00080
00081 private:
00082
00083 PrimitiveType valueType;
00084 PrimitiveValue value;
00085
00086 public:
00087
00091 PrimitiveValueNode();
00092
00097 PrimitiveValueNode(bool value);
00098
00103 PrimitiveValueNode(unsigned char value);
00104
00109 PrimitiveValueNode(char value);
00110
00115 PrimitiveValueNode(short value);
00116
00121 PrimitiveValueNode(int value);
00122
00127 PrimitiveValueNode(long long value);
00128
00133 PrimitiveValueNode(float value);
00134
00139 PrimitiveValueNode(double value);
00140
00145 PrimitiveValueNode(const char* value);
00146
00151 PrimitiveValueNode(const std::string& value);
00152
00157 PrimitiveValueNode(const std::vector<unsigned char>& value);
00158
00163 PrimitiveValueNode(const decaf::util::List<PrimitiveValueNode>& value);
00164
00169 PrimitiveValueNode(const decaf::util::Map<std::string, PrimitiveValueNode>& value);
00170
00176 PrimitiveValueNode(const PrimitiveValueNode& node);
00177
00178 ~PrimitiveValueNode() {
00179 clear();
00180 }
00181
00188 PrimitiveValueNode& operator =(const PrimitiveValueNode& node);
00189
00194 bool operator==(const PrimitiveValueNode& node) const;
00195
00200 PrimitiveType getType() const {
00201 return valueType;
00202 }
00203
00208 PrimitiveValue getValue() const {
00209 return this->value;
00210 }
00211
00221 void setValue(const PrimitiveValue& value, PrimitiveType valueType);
00222
00227 void clear();
00228
00235 void setBool(bool value);
00236
00243 bool getBool() const;
00244
00251 void setByte(unsigned char value);
00252
00259 unsigned char getByte() const;
00260
00267 void setChar(char value);
00268
00275 char getChar() const;
00276
00283 void setShort(short value);
00284
00291 short getShort() const;
00292
00299 void setInt(int value);
00300
00307 int getInt() const;
00308
00315 void setLong(long long value);
00316
00323 long long getLong() const;
00324
00331 void setFloat(float value);
00332
00339 float getFloat() const;
00340
00347 void setDouble(double value);
00348
00355 double getDouble() const;
00356
00363 void setString(const std::string& value);
00364
00371 std::string getString() const;
00372
00379 void setByteArray(const std::vector<unsigned char>& value);
00380
00387 std::vector<unsigned char> getByteArray() const;
00388
00395 void setList(const decaf::util::List<PrimitiveValueNode>& value);
00396
00403 const decaf::util::List<PrimitiveValueNode>& getList() const;
00404
00411 void setMap(const decaf::util::Map<std::string, PrimitiveValueNode>& value);
00412
00419 const decaf::util::Map<std::string, PrimitiveValueNode>& getMap() const;
00420
00425 std::string toString() const;
00426
00427 };
00428
00429 }}
00430
00431 #endif