activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r774396 - in /activemq/activemq-cpp/trunk/activemq-cpp/src: main/activemq/util/ test/activemq/util/
Date Wed, 13 May 2009 15:14:36 GMT
Author: tabish
Date: Wed May 13 15:14:35 2009
New Revision: 774396

URL: http://svn.apache.org/viewvc?rev=774396&view=rev
Log:
Adding in the skeleton implementation of StreamMessage, fixing some issues with the Primitive
Collections and the exceptions that are thrown on conversion errors.

Modified:
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/PrimitiveList.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/PrimitiveList.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/PrimitiveMap.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/PrimitiveMap.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/PrimitiveValueConverter.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/PrimitiveValueConverter.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/util/PrimitiveListTest.cpp

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/PrimitiveList.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/PrimitiveList.cpp?rev=774396&r1=774395&r2=774396&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/PrimitiveList.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/PrimitiveList.cpp Wed
May 13 15:14:35 2009
@@ -41,6 +41,11 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
+PrimitiveList::~PrimitiveList() {
+    clear();
+}
+
+////////////////////////////////////////////////////////////////////////////////
 std::string PrimitiveList::toString() const {
 
     ostringstream stream;
@@ -59,10 +64,10 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 bool PrimitiveList::getBool( std::size_t index ) const
-    throw( IndexOutOfBoundsException, NoSuchElementException ){
+    throw( IndexOutOfBoundsException, UnsupportedOperationException ){
 
     PrimitiveValueNode node = this->get( index );
-    return node.getBool();
+    return converter.convert<bool>( node );
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -77,10 +82,10 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 unsigned char PrimitiveList::getByte( std::size_t index ) const
-    throw( IndexOutOfBoundsException, NoSuchElementException ){
+    throw( IndexOutOfBoundsException, UnsupportedOperationException ){
 
     PrimitiveValueNode node = this->get( index );
-    return node.getByte();
+    return converter.convert<unsigned char>( node );
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -95,10 +100,10 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 char PrimitiveList::getChar( std::size_t index ) const
-    throw( IndexOutOfBoundsException, NoSuchElementException ){
+    throw( IndexOutOfBoundsException, UnsupportedOperationException ){
 
     PrimitiveValueNode node = this->get( index );
-    return node.getChar();
+    return converter.convert<char>( node );
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -113,10 +118,10 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 short PrimitiveList::getShort( std::size_t index ) const
-    throw( IndexOutOfBoundsException, NoSuchElementException ){
+    throw( IndexOutOfBoundsException, UnsupportedOperationException ){
 
     PrimitiveValueNode node = this->get( index );
-    return node.getShort();
+    return converter.convert<short>( node );
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -131,10 +136,10 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 int PrimitiveList::getInt( std::size_t index ) const
-    throw( IndexOutOfBoundsException, NoSuchElementException ){
+    throw( IndexOutOfBoundsException, UnsupportedOperationException ){
 
     PrimitiveValueNode node = this->get( index );
-    return node.getInt();
+    return converter.convert<int>( node );
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -149,10 +154,10 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 long long PrimitiveList::getLong( std::size_t index ) const
-    throw( IndexOutOfBoundsException, NoSuchElementException ){
+    throw( IndexOutOfBoundsException, UnsupportedOperationException ){
 
     PrimitiveValueNode node = this->get( index );
-    return node.getLong();
+    return converter.convert<long long>( node );
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -167,10 +172,10 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 double PrimitiveList::getDouble( std::size_t index ) const
-    throw( IndexOutOfBoundsException, NoSuchElementException ){
+    throw( IndexOutOfBoundsException, UnsupportedOperationException ){
 
     PrimitiveValueNode node = this->get( index );
-    return node.getDouble();
+    return converter.convert<double>( node );
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -185,10 +190,10 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 float PrimitiveList::getFloat( std::size_t index ) const
-    throw( IndexOutOfBoundsException, NoSuchElementException ){
+    throw( IndexOutOfBoundsException, UnsupportedOperationException ){
 
     PrimitiveValueNode node = this->get( index );
-    return node.getFloat();
+    return converter.convert<float>( node );
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -203,10 +208,10 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 string PrimitiveList::getString( std::size_t index ) const
-    throw( IndexOutOfBoundsException, NoSuchElementException ){
+    throw( IndexOutOfBoundsException, UnsupportedOperationException ){
 
     PrimitiveValueNode node = this->get( index );
-    return node.getString();
+    return converter.convert<std::string>( node );
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -221,10 +226,10 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 std::vector<unsigned char> PrimitiveList::getByteArray( std::size_t index ) const
-    throw( IndexOutOfBoundsException, NoSuchElementException ) {
+    throw( IndexOutOfBoundsException, UnsupportedOperationException ) {
 
     PrimitiveValueNode node = this->get( index );
-    return node.getByteArray();
+    return converter.convert< std::vector<unsigned char> >( node );
 }
 
 ////////////////////////////////////////////////////////////////////////////////

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/PrimitiveList.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/PrimitiveList.h?rev=774396&r1=774395&r2=774396&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/PrimitiveList.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/PrimitiveList.h Wed May
13 15:14:35 2009
@@ -21,9 +21,11 @@
 #include <string>
 #include <vector>
 #include <decaf/util/StlList.h>
-#include <decaf/lang/exceptions/NoSuchElementException.h>
+#include <decaf/lang/exceptions/UnsupportedOperationException.h>
+#include <decaf/lang/exceptions/IndexOutOfBoundsException.h>
 #include <stdio.h>
 #include <activemq/util/PrimitiveValueNode.h>
+#include <activemq/util/PrimitiveValueConverter.h>
 
 namespace activemq{
 namespace util{
@@ -32,16 +34,18 @@
      * List of primitives.
      */
     class AMQCPP_API PrimitiveList : public decaf::util::StlList<PrimitiveValueNode>
{
+    private:
+
+        PrimitiveValueConverter converter;
+
     public:
 
         /**
-         * Default Constructor, creates an Empry list.
+         * Default Constructor, creates an Empty list.
          */
         PrimitiveList();
 
-        virtual ~PrimitiveList() {
-            clear();
-        }
+        virtual ~PrimitiveList();
 
         /**
          * Copy Constructor
@@ -67,12 +71,12 @@
          * @param index - index to get value from
          * @return value contained at the given index
          * @throw IndexOutOfBoundsException if index is > size()
-         * @throw NoSuchElementException if the type at index is not of the
-         * type that this method is to return.
+         * @throw UnsupportedOperationException if the type at index is not of the
+         * type that this method is to return or can convert to.
          */
         virtual bool getBool( std::size_t index ) const
             throw( decaf::lang::exceptions::IndexOutOfBoundsException,
-                   decaf::lang::exceptions::NoSuchElementException );
+                   decaf::lang::exceptions::UnsupportedOperationException );
 
         /**
          * Sets the value at the given index to the new value specified,
@@ -91,12 +95,12 @@
          * @param index - index to get value from
          * @return value contained at the given index
          * @throw IndexOutOfBoundsException if index is > size()
-         * @throw NoSuchElementException if the type at index is not of the
-         * type that this method is to return.
+         * @throw UnsupportedOperationException if the type at index is not of the
+         * type that this method is to return or can convert to.
          */
         virtual unsigned char getByte( std::size_t index ) const
             throw( decaf::lang::exceptions::IndexOutOfBoundsException,
-                   decaf::lang::exceptions::NoSuchElementException );
+                   decaf::lang::exceptions::UnsupportedOperationException );
 
         /**
          * Sets the value at the given index to the new value specified,
@@ -115,12 +119,12 @@
          * @param index - index to get value from
          * @return value contained at the given index
          * @throw IndexOutOfBoundsException if index is > size()
-         * @throw NoSuchElementException if the type at index is not of the
-         * type that this method is to return.
+         * @throw UnsupportedOperationException if the type at index is not of the
+         * type that this method is to return or can convert to.
          */
         virtual char getChar( std::size_t index ) const
             throw( decaf::lang::exceptions::IndexOutOfBoundsException,
-                   decaf::lang::exceptions::NoSuchElementException );
+                   decaf::lang::exceptions::UnsupportedOperationException );
 
         /**
          * Sets the value at the given index to the new value specified,
@@ -139,12 +143,12 @@
          * @param index - index to get value from
          * @return value contained at the given index
          * @throw IndexOutOfBoundsException if index is > size()
-         * @throw NoSuchElementException if the type at index is not of the
-         * type that this method is to return.
+         * @throw UnsupportedOperationException if the type at index is not of the
+         * type that this method is to return or can convert to.
          */
         virtual short getShort( std::size_t index ) const
             throw( decaf::lang::exceptions::IndexOutOfBoundsException,
-                   decaf::lang::exceptions::NoSuchElementException );
+                   decaf::lang::exceptions::UnsupportedOperationException );
 
         /**
          * Sets the value at the given index to the new value specified,
@@ -163,12 +167,12 @@
          * @param index - index to get value from
          * @return value contained at the given index
          * @throw IndexOutOfBoundsException if index is > size()
-         * @throw NoSuchElementException if the type at index is not of the
-         * type that this method is to return.
+         * @throw UnsupportedOperationException if the type at index is not of the
+         * type that this method is to return or can convert to.
          */
         virtual int getInt( std::size_t index ) const
             throw( decaf::lang::exceptions::IndexOutOfBoundsException,
-                   decaf::lang::exceptions::NoSuchElementException );
+                   decaf::lang::exceptions::UnsupportedOperationException );
 
         /**
          * Sets the value at the given index to the new value specified,
@@ -187,12 +191,12 @@
          * @param index - index to get value from
          * @return value contained at the given index
          * @throw IndexOutOfBoundsException if index is > size()
-         * @throw NoSuchElementException if the type at index is not of the
-         * type that this method is to return.
+         * @throw UnsupportedOperationException if the type at index is not of the
+         * type that this method is to return or can convert to.
          */
         virtual long long getLong( std::size_t index ) const
             throw( decaf::lang::exceptions::IndexOutOfBoundsException,
-                   decaf::lang::exceptions::NoSuchElementException );
+                   decaf::lang::exceptions::UnsupportedOperationException );
 
         /**
          * Sets the value at the given index to the new value specified,
@@ -211,12 +215,12 @@
          * @param index - index to get value from
          * @return value contained at the given index
          * @throw IndexOutOfBoundsException if index is > size()
-         * @throw NoSuchElementException if the type at index is not of the
-         * type that this method is to return.
+         * @throw UnsupportedOperationException if the type at index is not of the
+         * type that this method is to return or can convert to.
          */
         virtual float getFloat( std::size_t index ) const
             throw( decaf::lang::exceptions::IndexOutOfBoundsException,
-                   decaf::lang::exceptions::NoSuchElementException );
+                   decaf::lang::exceptions::UnsupportedOperationException );
 
         /**
          * Sets the value at the given index to the new value specified,
@@ -235,12 +239,12 @@
          * @param index - index to get value from
          * @return value contained at the given index
          * @throw IndexOutOfBoundsException if index is > size()
-         * @throw NoSuchElementException if the type at index is not of the
-         * type that this method is to return.
+         * @throw UnsupportedOperationException if the type at index is not of the
+         * type that this method is to return or can convert to.
          */
         virtual double getDouble( std::size_t index ) const
             throw( decaf::lang::exceptions::IndexOutOfBoundsException,
-                   decaf::lang::exceptions::NoSuchElementException );
+                   decaf::lang::exceptions::UnsupportedOperationException );
 
         /**
          * Sets the value at the given index to the new value specified,
@@ -259,12 +263,12 @@
          * @param index - index to get value from
          * @return value contained at the given index
          * @throw IndexOutOfBoundsException if index is > size()
-         * @throw NoSuchElementException if the type at index is not of the
-         * type that this method is to return.
+         * @throw UnsupportedOperationException if the type at index is not of the
+         * type that this method is to return or can convert to.
          */
         virtual std::string getString( std::size_t index ) const
             throw( decaf::lang::exceptions::IndexOutOfBoundsException,
-                   decaf::lang::exceptions::NoSuchElementException );
+                   decaf::lang::exceptions::UnsupportedOperationException );
 
         /**
          * Sets the value at the given index to the new value specified,
@@ -283,12 +287,12 @@
          * @param index - index to get value from
          * @return value contained at the given index
          * @throw IndexOutOfBoundsException if index is > size()
-         * @throw NoSuchElementException if the type at index is not of the
-         * type that this method is to return.
+         * @throw UnsupportedOperationException if the type at index is not of the
+         * type that this method is to return or can convert to.
          */
         virtual std::vector<unsigned char> getByteArray( std::size_t index ) const
             throw( decaf::lang::exceptions::IndexOutOfBoundsException,
-                   decaf::lang::exceptions::NoSuchElementException );
+                   decaf::lang::exceptions::UnsupportedOperationException );
 
         /**
          * Sets the value at the given index to the new value specified,

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/PrimitiveMap.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/PrimitiveMap.cpp?rev=774396&r1=774395&r2=774396&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/PrimitiveMap.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/PrimitiveMap.cpp Wed May
13 15:14:35 2009
@@ -32,6 +32,10 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
+PrimitiveMap::~PrimitiveMap(){
+}
+
+////////////////////////////////////////////////////////////////////////////////
 PrimitiveMap::PrimitiveMap( const decaf::util::Map<std::string, PrimitiveValueNode>&
src )
   : decaf::util::StlMap<std::string, PrimitiveValueNode>( src ) {
 }
@@ -61,7 +65,7 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 bool PrimitiveMap::getBool( const string& key ) const
-    throw( NoSuchElementException ){
+    throw( NoSuchElementException, UnsupportedOperationException ){
 
     PrimitiveValueNode node = this->get( key );
     return converter.convert<bool>( node );
@@ -78,7 +82,7 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 unsigned char PrimitiveMap::getByte( const string& key ) const
-    throw( NoSuchElementException ){
+    throw( NoSuchElementException, UnsupportedOperationException ){
 
     PrimitiveValueNode node = this->get( key );
     return converter.convert<unsigned char>( node );
@@ -94,7 +98,7 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 char PrimitiveMap::getChar( const string& key ) const
-    throw( NoSuchElementException ){
+    throw( NoSuchElementException, UnsupportedOperationException ){
 
     PrimitiveValueNode node = this->get( key );
     return converter.convert<char>( node );
@@ -110,7 +114,7 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 short PrimitiveMap::getShort( const string& key ) const
-    throw( NoSuchElementException ){
+    throw( NoSuchElementException, UnsupportedOperationException ){
 
     PrimitiveValueNode node = this->get( key );
     return converter.convert<short>( node );
@@ -126,7 +130,7 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 int PrimitiveMap::getInt( const string& key ) const
-    throw( NoSuchElementException ){
+    throw( NoSuchElementException, UnsupportedOperationException ){
 
     PrimitiveValueNode node = this->get( key );
     return converter.convert<int>( node );
@@ -142,7 +146,7 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 long long PrimitiveMap::getLong( const string& key ) const
-    throw( NoSuchElementException ){
+    throw( NoSuchElementException, UnsupportedOperationException ){
 
     PrimitiveValueNode node = this->get( key );
     return converter.convert<long long>( node );
@@ -158,7 +162,7 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 double PrimitiveMap::getDouble( const string& key ) const
-    throw( NoSuchElementException ){
+    throw( NoSuchElementException, UnsupportedOperationException ){
 
     PrimitiveValueNode node = this->get( key );
     return converter.convert<double>( node );
@@ -174,7 +178,7 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 float PrimitiveMap::getFloat( const string& key ) const
-    throw( NoSuchElementException ){
+    throw( NoSuchElementException, UnsupportedOperationException ){
 
     PrimitiveValueNode node = this->get( key );
     return converter.convert<float>( node );
@@ -190,7 +194,7 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 string PrimitiveMap::getString( const string& key ) const
-    throw( NoSuchElementException ){
+    throw( NoSuchElementException, UnsupportedOperationException ){
 
     PrimitiveValueNode node = this->get( key );
     return converter.convert<std::string>( node );
@@ -206,10 +210,10 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 std::vector<unsigned char> PrimitiveMap::getByteArray( const std::string& key )
const
-    throw( decaf::lang::exceptions::NoSuchElementException ) {
+    throw( NoSuchElementException, UnsupportedOperationException ){
 
     PrimitiveValueNode node = this->get( key );
-    return node.getByteArray();
+    return converter.convert< std::vector<unsigned char> >( node );
 }
 
 ////////////////////////////////////////////////////////////////////////////////

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/PrimitiveMap.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/PrimitiveMap.h?rev=774396&r1=774395&r2=774396&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/PrimitiveMap.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/PrimitiveMap.h Wed May
13 15:14:35 2009
@@ -45,7 +45,7 @@
          */
         PrimitiveMap();
 
-        virtual ~PrimitiveMap() {}
+        virtual ~PrimitiveMap();
 
         /**
          * Copy Constructor
@@ -73,11 +73,13 @@
          *
          * @param key - the location to return the value from.
          * @returns the value at key in the type requested.
-         * @throw NoSuchElementException if key is not in the map or cannot
-         * be returned as the requested type.
+         * @throw NoSuchElementException if key is not in the map.
+         * @throw UnSupportedOperationException if the value cannot be converted
+         *                                      to the type this method returns
          */
         virtual bool getBool( const std::string& key ) const
-            throw( decaf::lang::exceptions::NoSuchElementException );
+            throw( decaf::lang::exceptions::NoSuchElementException,
+                   decaf::lang::exceptions::UnsupportedOperationException );
 
         /**
          * Sets the value at key to the specified type. Overwrites any data
@@ -94,11 +96,13 @@
          *
          * @param key - the location to return the value from.
          * @returns the value at key in the type requested.
-         * @throw NoSuchElementException if key is not in the map or cannot
-         * be returned as the requested type.
+         * @throw NoSuchElementException if key is not in the map.
+         * @throw UnSupportedOperationException if the value cannot be converted
+         *                                      to the type this method returns
          */
         virtual unsigned char getByte( const std::string& key ) const
-            throw( decaf::lang::exceptions::NoSuchElementException );
+            throw( decaf::lang::exceptions::NoSuchElementException,
+                   decaf::lang::exceptions::UnsupportedOperationException );
 
         /**
          * Sets the value at key to the specified type. Overwrites any data
@@ -115,11 +119,13 @@
          *
          * @param key - the location to return the value from.
          * @returns the value at key in the type requested.
-         * @throw NoSuchElementException if key is not in the map or cannot
-         * be returned as the requested type.
+         * @throw NoSuchElementException if key is not in the map.
+         * @throw UnSupportedOperationException if the value cannot be converted
+         *                                      to the type this method returns
          */
         virtual char getChar( const std::string& key ) const
-            throw( decaf::lang::exceptions::NoSuchElementException );
+            throw( decaf::lang::exceptions::NoSuchElementException,
+                   decaf::lang::exceptions::UnsupportedOperationException );
 
         /**
          * Sets the value at key to the specified type. Overwrites any data
@@ -136,11 +142,13 @@
          *
          * @param key - the location to return the value from.
          * @returns the value at key in the type requested.
-         * @throw NoSuchElementException if key is not in the map or cannot
-         * be returned as the requested type.
+         * @throw NoSuchElementException if key is not in the map.
+         * @throw UnSupportedOperationException if the value cannot be converted
+         *                                      to the type this method returns
          */
         virtual short getShort( const std::string& key ) const
-            throw( decaf::lang::exceptions::NoSuchElementException );
+            throw( decaf::lang::exceptions::NoSuchElementException,
+                   decaf::lang::exceptions::UnsupportedOperationException );
 
         /**
          * Sets the value at key to the specified type. Overwrites any data
@@ -157,11 +165,13 @@
          *
          * @param key - the location to return the value from.
          * @returns the value at key in the type requested.
-         * @throw NoSuchElementException if key is not in the map or cannot
-         * be returned as the requested type.
+         * @throw NoSuchElementException if key is not in the map.
+         * @throw UnSupportedOperationException if the value cannot be converted
+         *                                      to the type this method returns
          */
         virtual int getInt( const std::string& key ) const
-            throw( decaf::lang::exceptions::NoSuchElementException );
+            throw( decaf::lang::exceptions::NoSuchElementException,
+                   decaf::lang::exceptions::UnsupportedOperationException );
 
         /**
          * Sets the value at key to the specified type. Overwrites any data
@@ -178,11 +188,13 @@
          *
          * @param key - the location to return the value from.
          * @returns the value at key in the type requested.
-         * @throw NoSuchElementException if key is not in the map or cannot
-         * be returned as the requested type.
+         * @throw NoSuchElementException if key is not in the map.
+         * @throw UnSupportedOperationException if the value cannot be converted
+         *                                      to the type this method returns
          */
         virtual long long getLong( const std::string& key ) const
-            throw( decaf::lang::exceptions::NoSuchElementException );
+            throw( decaf::lang::exceptions::NoSuchElementException,
+                   decaf::lang::exceptions::UnsupportedOperationException );
 
         /**
          * Sets the value at key to the specified type. Overwrites any data
@@ -199,11 +211,13 @@
          *
          * @param key - the location to return the value from.
          * @returns the value at key in the type requested.
-         * @throw NoSuchElementException if key is not in the map or cannot
-         * be returned as the requested type.
+         * @throw NoSuchElementException if key is not in the map.
+         * @throw UnSupportedOperationException if the value cannot be converted
+         *                                      to the type this method returns
          */
         virtual float getFloat( const std::string& key ) const
-            throw( decaf::lang::exceptions::NoSuchElementException );
+            throw( decaf::lang::exceptions::NoSuchElementException,
+                   decaf::lang::exceptions::UnsupportedOperationException );
 
         /**
          * Sets the value at key to the specified type. Overwrites any data
@@ -220,11 +234,13 @@
          *
          * @param key - the location to return the value from.
          * @returns the value at key in the type requested.
-         * @throw NoSuchElementException if key is not in the map or cannot
-         * be returned as the requested type.
+         * @throw NoSuchElementException if key is not in the map.
+         * @throw UnSupportedOperationException if the value cannot be converted
+         *                                      to the type this method returns
          */
         virtual double getDouble( const std::string& key ) const
-            throw( decaf::lang::exceptions::NoSuchElementException );
+            throw( decaf::lang::exceptions::NoSuchElementException,
+                   decaf::lang::exceptions::UnsupportedOperationException );
 
         /**
          * Sets the value at key to the specified type. Overwrites any data
@@ -241,11 +257,13 @@
          *
          * @param key - the location to return the value from.
          * @returns the value at key in the type requested.
-         * @throw NoSuchElementException if key is not in the map or cannot
-         * be returned as the requested type.
+         * @throw NoSuchElementException if key is not in the map.
+         * @throw UnSupportedOperationException if the value cannot be converted
+         *                                      to the type this method returns
          */
         virtual std::string getString( const std::string& key ) const
-            throw( decaf::lang::exceptions::NoSuchElementException );
+            throw( decaf::lang::exceptions::NoSuchElementException,
+                   decaf::lang::exceptions::UnsupportedOperationException );
 
         /**
          * Sets the value at key to the specified type. Overwrites any data
@@ -262,11 +280,13 @@
          *
          * @param key - the location to return the value from.
          * @returns the value at key in the type requested.
-         * @throw NoSuchElementException if key is not in the map or cannot
-         * be returned as the requested type.
+         * @throw NoSuchElementException if key is not in the map.
+         * @throw UnSupportedOperationException if the value cannot be converted
+         *                                      to the type this method returns
          */
         virtual std::vector<unsigned char> getByteArray( const std::string& key
) const
-            throw( decaf::lang::exceptions::NoSuchElementException );
+            throw( decaf::lang::exceptions::NoSuchElementException,
+                   decaf::lang::exceptions::UnsupportedOperationException );
 
         /**
          * Sets the value at key to the specified type. Overwrites any data

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/PrimitiveValueConverter.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/PrimitiveValueConverter.cpp?rev=774396&r1=774395&r2=774396&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/PrimitiveValueConverter.cpp
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/PrimitiveValueConverter.cpp
Wed May 13 15:14:35 2009
@@ -242,4 +242,18 @@
     }
 }
 
+////////////////////////////////////////////////////////////////////////////////
+template<>
+std::vector<unsigned char> PrimitiveValueConverter::convert( const PrimitiveValueNode&
value ) const
+    throw( decaf::lang::exceptions::UnsupportedOperationException ) {
+
+    switch( value.getType() ) {
+        case PrimitiveValueNode::BYTE_ARRAY_TYPE:
+            return value.getByteArray();
+        default:
+            throw decaf::lang::exceptions::UnsupportedOperationException(
+                 __FILE__, __LINE__, "Unsupported Type Conversion" );
+    }
+}
+
 }}

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/PrimitiveValueConverter.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/PrimitiveValueConverter.h?rev=774396&r1=774395&r2=774396&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/PrimitiveValueConverter.h
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/PrimitiveValueConverter.h
Wed May 13 15:14:35 2009
@@ -65,7 +65,6 @@
                 __FILE__, __LINE__, "Invalid Conversion" );
         }
 
-
     };
 
     template<>
@@ -95,6 +94,9 @@
     template<>
     std::string PrimitiveValueConverter::convert( const PrimitiveValueNode& value ) const
         throw( decaf::lang::exceptions::UnsupportedOperationException );
+    template<>
+    std::vector<unsigned char> PrimitiveValueConverter::convert( const PrimitiveValueNode&
value ) const
+        throw( decaf::lang::exceptions::UnsupportedOperationException );
 
 }}
 

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/util/PrimitiveListTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/util/PrimitiveListTest.cpp?rev=774396&r1=774395&r2=774396&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/util/PrimitiveListTest.cpp
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/util/PrimitiveListTest.cpp
Wed May 13 15:14:35 2009
@@ -34,69 +34,73 @@
 
     plist.add( true );
     CPPUNIT_ASSERT( plist.getBool(0) == true );
+    CPPUNIT_ASSERT( plist.getString(0) == "true" );
     plist.add( false );
     CPPUNIT_ASSERT( plist.getBool(1) == false );
+    CPPUNIT_ASSERT( plist.getString(1) == "false" );
 
     CPPUNIT_ASSERT_THROW_MESSAGE(
-        "Should Throw NoSuchElementException",
+        "Should Throw UnsupportedOperationException",
         plist.getByte( 0 ),
-        decaf::lang::exceptions::NoSuchElementException );
+        decaf::lang::exceptions::UnsupportedOperationException );
 
     plist.setByte( 0, 1 );
     CPPUNIT_ASSERT( plist.getByte(0) == 1 );
 
     CPPUNIT_ASSERT_THROW_MESSAGE(
-        "Should Throw NoSuchElementException",
+        "Should Throw UnsupportedOperationException",
         plist.getChar( 0 ),
-        decaf::lang::exceptions::NoSuchElementException );
+        decaf::lang::exceptions::UnsupportedOperationException );
 
     plist.setChar( 0, 'a' );
     CPPUNIT_ASSERT( plist.getChar(0) == 'a' );
+    CPPUNIT_ASSERT( plist.getString(0) == "a" );
 
     CPPUNIT_ASSERT_THROW_MESSAGE(
-        "Should Throw NoSuchElementException",
+        "Should Throw UnsupportedOperationException",
         plist.getShort( 0 ),
-        decaf::lang::exceptions::NoSuchElementException );
+        decaf::lang::exceptions::UnsupportedOperationException );
 
     plist.setShort( 0, 2 );
     CPPUNIT_ASSERT( plist.getShort(0) == 2 );
+    CPPUNIT_ASSERT( plist.getInt(0) == 2 );
 
     CPPUNIT_ASSERT_THROW_MESSAGE(
-        "Should Throw NoSuchElementException",
-        plist.getInt( 0 ),
-        decaf::lang::exceptions::NoSuchElementException );
+        "Should Throw UnsupportedOperationException",
+        plist.getByte( 0 ),
+        decaf::lang::exceptions::UnsupportedOperationException );
 
     plist.setInt( 0, 3 );
     CPPUNIT_ASSERT( plist.getInt(0) == 3 );
 
     CPPUNIT_ASSERT_THROW_MESSAGE(
-        "Should Throw NoSuchElementException",
-        plist.getLong( 0 ),
-        decaf::lang::exceptions::NoSuchElementException );
+        "Should Throw UnsupportedOperationException",
+        plist.getShort( 0 ),
+        decaf::lang::exceptions::UnsupportedOperationException );
 
     plist.setLong( 0, 4L );
     CPPUNIT_ASSERT( plist.getLong(0) == 4L );
 
     CPPUNIT_ASSERT_THROW_MESSAGE(
-        "Should Throw NoSuchElementException",
+        "Should Throw UnsupportedOperationException",
         plist.getDouble( 0 ),
-        decaf::lang::exceptions::NoSuchElementException );
+        decaf::lang::exceptions::UnsupportedOperationException );
 
     plist.setDouble( 0, 2.3 );
     CPPUNIT_ASSERT( plist.getDouble(0) == 2.3 );
 
     CPPUNIT_ASSERT_THROW_MESSAGE(
-        "Should Throw NoSuchElementException",
+        "Should Throw UnsupportedOperationException",
         plist.getFloat( 0 ),
-        decaf::lang::exceptions::NoSuchElementException );
+        decaf::lang::exceptions::UnsupportedOperationException );
 
     plist.setFloat( 0, 3.2f );
     CPPUNIT_ASSERT( plist.getFloat(0) == 3.2f );
 
     CPPUNIT_ASSERT_THROW_MESSAGE(
-        "Should Throw NoSuchElementException",
-        plist.getString( 0 ),
-        decaf::lang::exceptions::NoSuchElementException );
+        "Should Throw UnsupportedOperationException",
+        plist.getChar( 0 ),
+        decaf::lang::exceptions::UnsupportedOperationException );
 
     plist.setString( 0, "hello" );
     CPPUNIT_ASSERT( plist.getString(0) == "hello" );
@@ -108,9 +112,9 @@
     byteArray.push_back( 'd' );
 
     CPPUNIT_ASSERT_THROW_MESSAGE(
-        "Should Throw NoSuchElementException",
+        "Should Throw UnsupportedOperationException",
         plist.getByteArray( 0 ),
-        decaf::lang::exceptions::NoSuchElementException );
+        decaf::lang::exceptions::UnsupportedOperationException );
 
     plist.setByteArray( 0, byteArray );
     CPPUNIT_ASSERT( plist.getByteArray(0) == byteArray );
@@ -146,9 +150,9 @@
     plist.add( byteArrayValue );
 
     CPPUNIT_ASSERT_THROW_MESSAGE(
-        "Should Throw NoSuchElementException",
+        "Should Throw UnsupportedOperationException",
         plist.getInt( 0 ),
-        decaf::lang::exceptions::NoSuchElementException );
+        decaf::lang::exceptions::UnsupportedOperationException );
 
     CPPUNIT_ASSERT_THROW_MESSAGE(
         "Should Throw IndexOutOfBoundsException",
@@ -176,9 +180,9 @@
     plist.remove( 0 );
 
     CPPUNIT_ASSERT_THROW_MESSAGE(
-        "Should Throw NoSuchElementException",
+        "Should Throw UnsupportedOperationException",
         plist.getInt( 0 ),
-        decaf::lang::exceptions::NoSuchElementException );
+        decaf::lang::exceptions::UnsupportedOperationException );
 
     plist.remove( 0 );
     plist.remove( 0 );



Mime
View raw message