/** * 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. */ #include "PrimitiveMap.h" #include #include #include #include #include using namespace activemq; using namespace activemq::util; using namespace decaf::lang::exceptions; using namespace decaf::util; using namespace decaf::lang; using namespace std; //////////////////////////////////////////////////////////////////////////////// PrimitiveMap::PrimitiveMap() : decaf::util::StlMap(), converter() { } //////////////////////////////////////////////////////////////////////////////// PrimitiveMap::~PrimitiveMap() { } //////////////////////////////////////////////////////////////////////////////// PrimitiveMap::PrimitiveMap(const decaf::util::Map& src) : decaf::util::StlMap(src), converter() { } //////////////////////////////////////////////////////////////////////////////// PrimitiveMap::PrimitiveMap(const PrimitiveMap& src) : decaf::util::StlMap(src), converter() { } //////////////////////////////////////////////////////////////////////////////// std::string PrimitiveMap::toString() const { ostringstream stream; stream << "Begin Class PrimitiveMap:" << std::endl; Pointer< Iterator > > entries(this->entrySet().iterator()); while (entries->hasNext()) { MapEntry entry = entries->next(); stream << "map[" << entry.getKey() << "] = " << entry.getValue().toString() << std::endl; } stream << "End Class PrimitiveMap:" << std::endl; return stream.str(); } //////////////////////////////////////////////////////////////////////////////// PrimitiveValueNode::PrimitiveType PrimitiveMap::getValueType(const std::string& key) const { PrimitiveValueNode node = this->get(key); return node.getType(); } //////////////////////////////////////////////////////////////////////////////// bool PrimitiveMap::getBool(const string& key) const { PrimitiveValueNode node = this->get(key); return converter.convert (node); } //////////////////////////////////////////////////////////////////////////////// void PrimitiveMap::setBool(const string& key, bool value) { PrimitiveValueNode node; node.setBool(value); this->put(key, node); } //////////////////////////////////////////////////////////////////////////////// unsigned char PrimitiveMap::getByte(const string& key) const { PrimitiveValueNode node = this->get(key); return converter.convert (node); } //////////////////////////////////////////////////////////////////////////////// void PrimitiveMap::setByte(const string& key, unsigned char value) { PrimitiveValueNode node; node.setByte(value); this->put(key, node); } //////////////////////////////////////////////////////////////////////////////// char PrimitiveMap::getChar(const string& key) const { PrimitiveValueNode node = this->get(key); return converter.convert (node); } //////////////////////////////////////////////////////////////////////////////// void PrimitiveMap::setChar(const string& key, char value) { PrimitiveValueNode node; node.setChar(value); this->put(key, node); } //////////////////////////////////////////////////////////////////////////////// short PrimitiveMap::getShort(const string& key) const { PrimitiveValueNode node = this->get(key); return converter.convert (node); } //////////////////////////////////////////////////////////////////////////////// void PrimitiveMap::setShort(const string& key, short value) { PrimitiveValueNode node; node.setShort(value); this->put(key, node); } //////////////////////////////////////////////////////////////////////////////// int PrimitiveMap::getInt(const string& key) const { PrimitiveValueNode node = this->get(key); return converter.convert (node); } //////////////////////////////////////////////////////////////////////////////// void PrimitiveMap::setInt(const string& key, int value) { PrimitiveValueNode node; node.setInt(value); this->put(key, node); } //////////////////////////////////////////////////////////////////////////////// long long PrimitiveMap::getLong(const string& key) const { PrimitiveValueNode node = this->get(key); return converter.convert (node); } //////////////////////////////////////////////////////////////////////////////// void PrimitiveMap::setLong(const string& key, long long value) { PrimitiveValueNode node; node.setLong(value); this->put(key, node); } //////////////////////////////////////////////////////////////////////////////// double PrimitiveMap::getDouble(const string& key) const { PrimitiveValueNode node = this->get(key); return converter.convert (node); } //////////////////////////////////////////////////////////////////////////////// void PrimitiveMap::setDouble(const string& key, double value) { PrimitiveValueNode node; node.setDouble(value); this->put(key, node); } //////////////////////////////////////////////////////////////////////////////// float PrimitiveMap::getFloat(const string& key) const { PrimitiveValueNode node = this->get(key); return converter.convert (node); } //////////////////////////////////////////////////////////////////////////////// void PrimitiveMap::setFloat(const string& key, float value) { PrimitiveValueNode node; node.setFloat(value); this->put(key, node); } //////////////////////////////////////////////////////////////////////////////// string PrimitiveMap::getString(const string& key) const { PrimitiveValueNode node = this->get(key); return converter.convert (node); } //////////////////////////////////////////////////////////////////////////////// void PrimitiveMap::setString(const string& key, const string& value) { PrimitiveValueNode node; node.setString(value); this->put(key, node); } //////////////////////////////////////////////////////////////////////////////// std::vector PrimitiveMap::getByteArray(const std::string& key) const { PrimitiveValueNode node = this->get(key); return converter.convert > (node); } //////////////////////////////////////////////////////////////////////////////// void PrimitiveMap::setByteArray(const std::string& key, const std::vector& value) { PrimitiveValueNode node; node.setByteArray(value); this->put(key, node); }