You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2009/11/20 00:37:27 UTC

svn commit: r882361 [1/4] - in /activemq/activemq-cpp/trunk/activemq-cpp/src: main/activemq/commands/ main/activemq/wireformat/openwire/utils/ main/cms/ test/activemq/commands/ test/activemq/wireformat/openwire/utils/

Author: tabish
Date: Thu Nov 19 23:37:26 2009
New Revision: 882361

URL: http://svn.apache.org/viewvc?rev=882361&view=rev
Log:
https://issues.apache.org/activemq/browse/AMQCPP-269

Updates CMS API headers. Updated ActiveMQ commands to reflect the new API changes, and add additional unit testing to verify the changes.  Fix any issues found from all the new tests.

Modified:
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQBytesMessage.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQBytesMessage.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQMapMessage.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQMapMessage.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQMessageTemplate.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQTextMessage.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQTextMessage.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/openwire/utils/MessagePropertyInterceptor.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/openwire/utils/MessagePropertyInterceptor.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/BytesMessage.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/MapMessage.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/Message.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/TextMessage.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/commands/ActiveMQBytesMessageTest.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/commands/ActiveMQBytesMessageTest.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/commands/ActiveMQMapMessageTest.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/commands/ActiveMQMapMessageTest.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/commands/ActiveMQMessageTest.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/commands/ActiveMQMessageTest.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/commands/ActiveMQTextMessageTest.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/commands/ActiveMQTextMessageTest.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/wireformat/openwire/utils/MessagePropertyInterceptorTest.cpp

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQBytesMessage.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQBytesMessage.cpp?rev=882361&r1=882360&r2=882361&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQBytesMessage.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQBytesMessage.cpp Thu Nov 19 23:37:26 2009
@@ -18,19 +18,28 @@
 
 #include <activemq/util/CMSExceptionSupport.h>
 
+#include <decaf/io/ByteArrayInputStream.h>
+#include <decaf/io/EOFException.h>
+#include <decaf/io/IOException.h>
+
 using namespace std;
 using namespace activemq;
+using namespace activemq::util;
 using namespace activemq::commands;
 using namespace activemq::exceptions;
+using namespace decaf::io;
 using namespace decaf::lang;
 
 ////////////////////////////////////////////////////////////////////////////////
 ActiveMQBytesMessage::ActiveMQBytesMessage() :
-    ActiveMQMessageTemplate< cms::BytesMessage >(),
-    dataInputStream( &inputStream ),
-    dataOutputStream( &outputStream ) {
+    ActiveMQMessageTemplate< cms::BytesMessage >(), length( 0 ) {
+
+    this->clearBody();
+}
 
-    clearBody();
+////////////////////////////////////////////////////////////////////////////////
+ActiveMQBytesMessage::~ActiveMQBytesMessage() {
+    this->reset();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -47,8 +56,24 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 void ActiveMQBytesMessage::copyDataStructure( const DataStructure* src ) {
+
+    // Protect against invalid self assignment.
+    if( this == src ) {
+        return;
+    }
+
+    const ActiveMQBytesMessage* srcPtr = dynamic_cast<const ActiveMQBytesMessage*>( src );
+
+    if( srcPtr == NULL || src == NULL ) {
+        throw decaf::lang::exceptions::NullPointerException(
+            __FILE__, __LINE__,
+            "ActiveMQBytesMessage::copyDataStructure - src is NULL or invalid" );
+    }
+
+    ActiveMQBytesMessage* nonConstSrc = const_cast<ActiveMQBytesMessage*>( srcPtr );
+    nonConstSrc->storeContent();
+
     ActiveMQMessageTemplate<cms::BytesMessage>::copyDataStructure( src );
-    this->reset();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -68,26 +93,31 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void ActiveMQBytesMessage::setBodyBytes( const unsigned char* buffer,
-                                         std::size_t numBytes )
-    throw( cms::CMSException ) {
+void ActiveMQBytesMessage::setBodyBytes( const unsigned char* buffer, std::size_t numBytes )
+    throw( cms::MessageNotWriteableException, cms::CMSException ) {
 
     try{
 
-        clearBody();
-        std::vector<unsigned char>& content = getContent();
-        content.insert( content.end(), buffer, buffer + numBytes );
+        initializeWriting();
+        dataOut->write( buffer, 0, numBytes );
     }
     AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-const unsigned char* ActiveMQBytesMessage::getBodyBytes() const throw ( cms::CMSException ) {
+unsigned char* ActiveMQBytesMessage::getBodyBytes() const
+    throw( cms::MessageNotReadableException, cms::CMSException ) {
 
     try{
 
-        if( getContent().size() > 0 ) {
-            return reinterpret_cast<const unsigned char*>( &( getContent()[0] ) );
+        initializeReading();
+
+        int length = this->getBodyLength();
+
+        if( length != 0 ) {
+            unsigned char* buffer = new unsigned char[length];
+            this->readBytes( buffer, length );
+            return buffer;
         } else {
             return NULL;
         }
@@ -96,284 +126,488 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-std::size_t ActiveMQBytesMessage::getBodyLength() const throw ( cms::CMSException ) {
+std::size_t ActiveMQBytesMessage::getBodyLength() const
+    throw( cms::MessageNotReadableException, cms::CMSException ) {
 
     try{
-        return getContent().size();
+        initializeReading();
+        return this->length;
     }
     AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void ActiveMQBytesMessage::reset() throw ( cms::CMSException ) {
+void ActiveMQBytesMessage::clearBody() throw( cms::CMSException ) {
+
+    // Invoke base class's version.
+    ActiveMQMessageTemplate<cms::BytesMessage>::clearBody();
+
+    this->dataOut.reset( NULL );
+    this->dataIn.reset( NULL );
+    this->length = 0;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void ActiveMQBytesMessage::onSend() {
+
+    this->storeContent();
+    ActiveMQMessageTemplate<cms::BytesMessage>::onSend();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void ActiveMQBytesMessage::reset()
+    throw ( cms::MessageFormatException, cms::CMSException ) {
 
     try{
-        this->setReadOnlyBody( true );
-        inputStream.setBuffer( getContent() );
+        storeContent();
+        this->bytesOut.reset( NULL );
+        this->dataIn.reset( NULL );
+        this->dataOut.reset( NULL );
+        this->length = 0;
+        this->setReadOnlyBody(true);
     }
     AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-bool ActiveMQBytesMessage::readBoolean() const throw ( cms::CMSException ) {
+bool ActiveMQBytesMessage::readBoolean() const
+    throw ( cms::MessageEOFException, cms::MessageNotReadableException, cms::CMSException ) {
 
+    initializeReading();
     try{
-        failIfWriteOnlyBody();
-        return dataInputStream.readBoolean();
+        return this->dataIn->readBoolean();
+    } catch( EOFException& ex ) {
+        throw CMSExceptionSupport::createMessageEOFException( ex );
+    } catch( IOException& ex ) {
+        throw CMSExceptionSupport::createMessageFormatException( ex );
+    } catch( Exception& ex ) {
+        throw CMSExceptionSupport::create( ex );
     }
-    AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void ActiveMQBytesMessage::writeBoolean( bool value ) throw ( cms::CMSException ) {
+void ActiveMQBytesMessage::writeBoolean( bool value )
+    throw ( cms::MessageNotWriteableException, cms::CMSException ) {
 
+    initializeWriting();
     try{
-        failIfReadOnlyBody();
-        dataOutputStream.writeBoolean( value );
+        this->dataOut->writeBoolean( value );
+    } catch( EOFException& ex ) {
+        throw CMSExceptionSupport::createMessageEOFException( ex );
+    } catch( Exception& ex ) {
+        throw CMSExceptionSupport::create( ex );
     }
-    AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-unsigned char ActiveMQBytesMessage::readByte() const throw ( cms::CMSException ) {
+unsigned char ActiveMQBytesMessage::readByte() const
+    throw ( cms::MessageEOFException, cms::MessageNotReadableException, cms::CMSException ) {
 
+    initializeReading();
     try{
-        failIfWriteOnlyBody();
-        return dataInputStream.readByte();
+        return this->dataIn->readByte();
+    } catch( EOFException& ex ) {
+        throw CMSExceptionSupport::createMessageEOFException( ex );
+    } catch( IOException& ex ) {
+        throw CMSExceptionSupport::createMessageFormatException( ex );
+    } catch( Exception& ex ) {
+        throw CMSExceptionSupport::create( ex );
     }
-    AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void ActiveMQBytesMessage::writeByte( unsigned char value ) throw ( cms::CMSException ) {
+void ActiveMQBytesMessage::writeByte( unsigned char value )
+    throw ( cms::MessageNotWriteableException, cms::CMSException ) {
 
+    initializeWriting();
     try{
-        failIfReadOnlyBody();
-        dataOutputStream.writeByte( value );
+        this->dataOut->writeByte( value );
+    } catch( EOFException& ex ) {
+        throw CMSExceptionSupport::createMessageEOFException( ex );
+    } catch( Exception& ex ) {
+        throw CMSExceptionSupport::create( ex );
     }
-    AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 std::size_t ActiveMQBytesMessage::readBytes( std::vector<unsigned char>& value ) const
-    throw ( cms::CMSException ) {
+    throw ( cms::MessageEOFException, cms::MessageNotReadableException, cms::CMSException ) {
+
+    return this->readBytes( &value[0], value.size() );
+}
 
+////////////////////////////////////////////////////////////////////////////////
+void ActiveMQBytesMessage::writeBytes( const std::vector<unsigned char>& value )
+    throw ( cms::MessageNotWriteableException, cms::CMSException ) {
+
+    initializeWriting();
     try{
-        failIfWriteOnlyBody();
-        return dataInputStream.read( value );
+        this->dataOut->write( value );
+    } catch( EOFException& ex ) {
+        throw CMSExceptionSupport::createMessageEOFException( ex );
+    } catch( Exception& ex ) {
+        throw CMSExceptionSupport::create( ex );
     }
-    AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void ActiveMQBytesMessage::writeBytes( const std::vector<unsigned char>& value ) throw ( cms::CMSException ) {
+std::size_t ActiveMQBytesMessage::readBytes( unsigned char* buffer, std::size_t length ) const
+    throw ( cms::MessageEOFException, cms::MessageNotReadableException, cms::CMSException ) {
 
+    initializeReading();
     try{
-        failIfReadOnlyBody();
-        dataOutputStream.write( value );
+
+        std::size_t n = 0;
+
+        while( n < length ) {
+            int count = this->dataIn->read( buffer, n, length - n );
+            if( count < 0 ) {
+                break;
+            }
+            n += count;
+        }
+
+        if( n == 0 && length > 0 ) {
+            n = -1;
+        }
+
+        return n;
+
+    } catch( EOFException& ex ) {
+        throw CMSExceptionSupport::createMessageEOFException( ex );
+    } catch( IOException& ex ) {
+        throw CMSExceptionSupport::createMessageFormatException( ex );
+    } catch( Exception& ex ) {
+        throw CMSExceptionSupport::create( ex );
     }
-    AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-std::size_t ActiveMQBytesMessage::readBytes( unsigned char*& buffer, std::size_t length ) const
-    throw ( cms::CMSException ) {
+void ActiveMQBytesMessage::writeBytes( const unsigned char* value, std::size_t offset, std::size_t length )
+    throw ( cms::MessageNotWriteableException, cms::CMSException ) {
 
+    initializeWriting();
     try{
-        failIfWriteOnlyBody();
-        return dataInputStream.read( buffer, 0, length );
+        this->dataOut->write( value, offset, length );
+    } catch( EOFException& ex ) {
+        throw CMSExceptionSupport::createMessageEOFException( ex );
+    } catch( Exception& ex ) {
+        throw CMSExceptionSupport::create( ex );
     }
-    AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void ActiveMQBytesMessage::writeBytes( const unsigned char* value,
-                                       std::size_t offset,
-                                       std::size_t length ) throw ( cms::CMSException ) {
+char ActiveMQBytesMessage::readChar() const
+    throw ( cms::MessageEOFException, cms::MessageNotReadableException, cms::CMSException ) {
 
+    initializeReading();
     try{
-        failIfReadOnlyBody();
-        dataOutputStream.write( value, offset, length );
+        return this->dataIn->readChar();
+    } catch( EOFException& ex ) {
+        throw CMSExceptionSupport::createMessageEOFException( ex );
+    } catch( IOException& ex ) {
+        throw CMSExceptionSupport::createMessageFormatException( ex );
+    } catch( Exception& ex ) {
+        throw CMSExceptionSupport::create( ex );
     }
-    AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-char ActiveMQBytesMessage::readChar() const throw ( cms::CMSException ) {
+void ActiveMQBytesMessage::writeChar( char value )
+    throw ( cms::MessageNotWriteableException, cms::CMSException ) {
 
+    initializeWriting();
     try{
-        failIfWriteOnlyBody();
-        return dataInputStream.readChar();
+        this->dataOut->writeChar( value );
+    } catch( EOFException& ex ) {
+        throw CMSExceptionSupport::createMessageEOFException( ex );
+    } catch( Exception& ex ) {
+        throw CMSExceptionSupport::create( ex );
     }
-    AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void ActiveMQBytesMessage::writeChar( char value ) throw ( cms::CMSException ) {
+float ActiveMQBytesMessage::readFloat() const
+    throw ( cms::MessageEOFException, cms::MessageNotReadableException, cms::CMSException ) {
 
+    initializeReading();
     try{
-        failIfReadOnlyBody();
-        dataOutputStream.writeChar( value );
+        return this->dataIn->readFloat();
+    } catch( EOFException& ex ) {
+        throw CMSExceptionSupport::createMessageEOFException( ex );
+    } catch( IOException& ex ) {
+        throw CMSExceptionSupport::createMessageFormatException( ex );
+    } catch( Exception& ex ) {
+        throw CMSExceptionSupport::create( ex );
     }
-    AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-float ActiveMQBytesMessage::readFloat() const throw ( cms::CMSException ) {
+void ActiveMQBytesMessage::writeFloat( float value )
+    throw ( cms::MessageNotWriteableException, cms::CMSException ) {
 
+    initializeWriting();
     try{
-        failIfWriteOnlyBody();
-        return dataInputStream.readFloat();
+        this->dataOut->writeFloat( value );
+    } catch( EOFException& ex ) {
+        throw CMSExceptionSupport::createMessageEOFException( ex );
+    } catch( Exception& ex ) {
+        throw CMSExceptionSupport::create( ex );
     }
-    AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void ActiveMQBytesMessage::writeFloat( float value ) throw ( cms::CMSException ) {
+double ActiveMQBytesMessage::readDouble() const
+    throw ( cms::MessageEOFException, cms::MessageNotReadableException, cms::CMSException ) {
 
+    initializeReading();
     try{
-        failIfReadOnlyBody();
-        dataOutputStream.writeFloat( value );
+        return this->dataIn->readDouble();
+    } catch( EOFException& ex ) {
+        throw CMSExceptionSupport::createMessageEOFException( ex );
+    } catch( IOException& ex ) {
+        throw CMSExceptionSupport::createMessageFormatException( ex );
+    } catch( Exception& ex ) {
+        throw CMSExceptionSupport::create( ex );
     }
-    AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-double ActiveMQBytesMessage::readDouble() const throw ( cms::CMSException ) {
+void ActiveMQBytesMessage::writeDouble( double value )
+    throw ( cms::MessageNotWriteableException, cms::CMSException ) {
 
+    initializeWriting();
     try{
-        failIfWriteOnlyBody();
-        return dataInputStream.readDouble();
+        this->dataOut->writeDouble( value );
+    } catch( EOFException& ex ) {
+        throw CMSExceptionSupport::createMessageEOFException( ex );
+    } catch( Exception& ex ) {
+        throw CMSExceptionSupport::create( ex );
     }
-    AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void ActiveMQBytesMessage::writeDouble( double value ) throw ( cms::CMSException ) {
+short ActiveMQBytesMessage::readShort() const
+    throw ( cms::MessageEOFException, cms::MessageNotReadableException, cms::CMSException ) {
 
+    initializeReading();
     try{
-        failIfReadOnlyBody();
-        dataOutputStream.writeDouble( value );
+        return this->dataIn->readShort();
+    } catch( EOFException& ex ) {
+        throw CMSExceptionSupport::createMessageEOFException( ex );
+    } catch( IOException& ex ) {
+        throw CMSExceptionSupport::createMessageFormatException( ex );
+    } catch( Exception& ex ) {
+        throw CMSExceptionSupport::create( ex );
     }
-    AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-short ActiveMQBytesMessage::readShort() const throw ( cms::CMSException ) {
+void ActiveMQBytesMessage::writeShort( short value )
+    throw ( cms::MessageNotWriteableException, cms::CMSException ) {
 
+    initializeWriting();
     try{
-        failIfWriteOnlyBody();
-        return dataInputStream.readShort();
+        this->dataOut->writeShort( value );
+    } catch( EOFException& ex ) {
+        throw CMSExceptionSupport::createMessageEOFException( ex );
+    } catch( Exception& ex ) {
+        throw CMSExceptionSupport::create( ex );
     }
-    AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void ActiveMQBytesMessage::writeShort( short value ) throw ( cms::CMSException ) {
+unsigned short ActiveMQBytesMessage::readUnsignedShort() const
+    throw ( cms::MessageEOFException, cms::MessageNotReadableException, cms::CMSException ) {
 
+    initializeReading();
     try{
-        failIfReadOnlyBody();
-        dataOutputStream.writeShort( value );
+        return this->dataIn->readUnsignedShort();
+    } catch( EOFException& ex ) {
+        throw CMSExceptionSupport::createMessageEOFException( ex );
+    } catch( IOException& ex ) {
+        throw CMSExceptionSupport::createMessageFormatException( ex );
+    } catch( Exception& ex ) {
+        throw CMSExceptionSupport::create( ex );
     }
-    AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-unsigned short ActiveMQBytesMessage::readUnsignedShort() const throw ( cms::CMSException ) {
+void ActiveMQBytesMessage::writeUnsignedShort( unsigned short value )
+    throw ( cms::MessageNotWriteableException, cms::CMSException ) {
 
+    initializeWriting();
     try{
-        failIfWriteOnlyBody();
-        return dataInputStream.readUnsignedShort();
+        this->dataOut->writeUnsignedShort( value );
+    } catch( EOFException& ex ) {
+        throw CMSExceptionSupport::createMessageEOFException( ex );
+    } catch( Exception& ex ) {
+        throw CMSExceptionSupport::create( ex );
     }
-    AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void ActiveMQBytesMessage::writeUnsignedShort( unsigned short value ) throw ( cms::CMSException ) {
+int ActiveMQBytesMessage::readInt() const
+    throw ( cms::MessageEOFException, cms::MessageNotReadableException, cms::CMSException ) {
 
+    initializeReading();
     try{
-        failIfReadOnlyBody();
-        dataOutputStream.writeUnsignedShort( value );
+        return this->dataIn->readInt();
+    } catch( EOFException& ex ) {
+        throw CMSExceptionSupport::createMessageEOFException( ex );
+    } catch( IOException& ex ) {
+        throw CMSExceptionSupport::createMessageFormatException( ex );
+    } catch( Exception& ex ) {
+        throw CMSExceptionSupport::create( ex );
     }
-    AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-int ActiveMQBytesMessage::readInt() const throw ( cms::CMSException ) {
+void ActiveMQBytesMessage::writeInt( int value )
+    throw ( cms::MessageNotWriteableException, cms::CMSException ) {
 
+    initializeWriting();
     try{
-        failIfWriteOnlyBody();
-        return dataInputStream.readInt();
+        this->dataOut->writeInt( value );
+    } catch( EOFException& ex ) {
+        throw CMSExceptionSupport::createMessageEOFException( ex );
+    } catch( Exception& ex ) {
+        throw CMSExceptionSupport::create( ex );
     }
-    AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void ActiveMQBytesMessage::writeInt( int value ) throw ( cms::CMSException ) {
+long long ActiveMQBytesMessage::readLong() const
+    throw ( cms::MessageEOFException, cms::MessageNotReadableException, cms::CMSException ) {
 
+    initializeReading();
     try{
-        failIfReadOnlyBody();
-        dataOutputStream.writeInt( value );
+        return this->dataIn->readLong();
+    } catch( EOFException& ex ) {
+        throw CMSExceptionSupport::createMessageEOFException( ex );
+    } catch( IOException& ex ) {
+        throw CMSExceptionSupport::createMessageFormatException( ex );
+    } catch( Exception& ex ) {
+        throw CMSExceptionSupport::create( ex );
     }
-    AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-long long ActiveMQBytesMessage::readLong() const throw ( cms::CMSException ) {
+void ActiveMQBytesMessage::writeLong( long long value )
+    throw ( cms::MessageNotWriteableException, cms::CMSException ) {
 
+    initializeWriting();
     try{
-        failIfWriteOnlyBody();
-        return dataInputStream.readLong();
+        this->dataOut->writeLong( value );
+    } catch( EOFException& ex ) {
+        throw CMSExceptionSupport::createMessageEOFException( ex );
+    } catch( Exception& ex ) {
+        throw CMSExceptionSupport::create( ex );
     }
-    AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void ActiveMQBytesMessage::writeLong( long long value ) throw ( cms::CMSException ) {
+std::string ActiveMQBytesMessage::readString() const
+    throw ( cms::MessageEOFException, cms::MessageNotReadableException, cms::CMSException ) {
 
+    initializeReading();
     try{
-        failIfReadOnlyBody();
-        dataOutputStream.writeLong( value );
+        return this->dataIn->readString();
+    } catch( EOFException& ex ) {
+        throw CMSExceptionSupport::createMessageEOFException( ex );
+    } catch( IOException& ex ) {
+        throw CMSExceptionSupport::createMessageFormatException( ex );
+    } catch( Exception& ex ) {
+        throw CMSExceptionSupport::create( ex );
     }
-    AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-std::string ActiveMQBytesMessage::readString() const throw ( cms::CMSException ) {
+void ActiveMQBytesMessage::writeString( const std::string& value )
+    throw ( cms::MessageNotWriteableException, cms::CMSException ) {
 
+    initializeWriting();
     try{
-        failIfWriteOnlyBody();
-        return dataInputStream.readString();
+        this->dataOut->writeChars( value );
+    } catch( EOFException& ex ) {
+        throw CMSExceptionSupport::createMessageEOFException( ex );
+    } catch( Exception& ex ) {
+        throw CMSExceptionSupport::create( ex );
     }
-    AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void ActiveMQBytesMessage::writeString( const std::string& value ) throw ( cms::CMSException ) {
+std::string ActiveMQBytesMessage::readUTF() const
+    throw ( cms::MessageEOFException, cms::MessageNotReadableException, cms::CMSException ) {
 
+    initializeReading();
     try{
-        failIfReadOnlyBody();
-        dataOutputStream.writeChars( value );
+        return this->dataIn->readUTF();
+    } catch( EOFException& ex ) {
+        throw CMSExceptionSupport::createMessageEOFException( ex );
+    } catch( IOException& ex ) {
+        throw CMSExceptionSupport::createMessageFormatException( ex );
+    } catch( Exception& ex ) {
+        throw CMSExceptionSupport::create( ex );
     }
-    AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-std::string ActiveMQBytesMessage::readUTF() const throw ( cms::CMSException ) {
+void ActiveMQBytesMessage::writeUTF( const std::string& value )
+    throw ( cms::MessageNotWriteableException, cms::CMSException ) {
 
+    initializeWriting();
     try{
-        failIfWriteOnlyBody();
-        return dataInputStream.readUTF();
+        this->dataOut->writeUTF( value );
+    } catch( EOFException& ex ) {
+        throw CMSExceptionSupport::createMessageEOFException( ex );
+    } catch( Exception& ex ) {
+        throw CMSExceptionSupport::create( ex );
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void ActiveMQBytesMessage::storeContent() {
+
+    try {
+
+        if( this->dataOut.get() != NULL ) {
+
+            this->dataOut->close();
+
+            this->setContent( this->bytesOut->toByteArrayRef() );
+
+            this->dataOut.reset( NULL );
+            this->bytesOut.reset( NULL );
+        }
     }
     AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void ActiveMQBytesMessage::writeUTF( const std::string& value ) throw ( cms::CMSException ) {
+void ActiveMQBytesMessage::initializeReading() const {
 
+    this->failIfWriteOnlyBody();
+    try {
+        if( this->dataIn.get() == NULL) {
+            ByteArrayInputStream* is = new ByteArrayInputStream( this->getContent() );
+            this->dataIn.reset( new DataInputStream( is, true ) );
+            this->length = this->getContent().size();
+        }
+    }
+    AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void ActiveMQBytesMessage::initializeWriting() {
+
+    this->failIfReadOnlyBody();
     try{
-        failIfReadOnlyBody();
-        dataOutputStream.writeUTF( value );
+        if( this->dataOut.get() == NULL ) {
+            this->length = 0;
+            this->bytesOut.reset( new ByteArrayOutputStream() );
+            this->dataOut.reset( new DataOutputStream( this->bytesOut.get() ) );
+        }
     }
     AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
 }

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQBytesMessage.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQBytesMessage.h?rev=882361&r1=882360&r2=882361&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQBytesMessage.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQBytesMessage.h Thu Nov 19 23:37:26 2009
@@ -25,7 +25,6 @@
 
 #include <activemq/util/Config.h>
 #include <activemq/commands/ActiveMQMessageTemplate.h>
-#include <decaf/io/ByteArrayInputStream.h>
 #include <decaf/io/ByteArrayOutputStream.h>
 #include <decaf/io/DataInputStream.h>
 #include <decaf/io/DataOutputStream.h>
@@ -42,26 +41,25 @@
     private:
 
         /**
-         * InputStream that wraps around the command's content when in
-         * read-only mode.
-         */
-        mutable decaf::io::ByteArrayInputStream inputStream;
-
-        /**
          * OutputStream that wraps around the command's content when in
          * write-only mode.
          */
-        decaf::io::ByteArrayOutputStream outputStream;
+        std::auto_ptr<decaf::io::ByteArrayOutputStream> bytesOut;
 
         /**
          * DataInputStream wrapper around the input stream.
          */
-        mutable decaf::io::DataInputStream dataInputStream;
+        mutable std::auto_ptr<decaf::io::DataInputStream> dataIn;
 
         /**
          * DataOutputStream wrapper around the output stream.
          */
-        decaf::io::DataOutputStream dataOutputStream;
+        std::auto_ptr<decaf::io::DataOutputStream> dataOut;
+
+        /**
+         * Tracks the actual length of the Message when compressed.
+         */
+        mutable int length;
 
     public:
 
@@ -70,7 +68,7 @@
     public:
 
         ActiveMQBytesMessage();
-        virtual ~ActiveMQBytesMessage() {}
+        virtual ~ActiveMQBytesMessage();
 
         virtual unsigned char getDataStructureType() const;
 
@@ -122,13 +120,12 @@
          * Clears out the body of the message.  This does not clear the
          * headers or properties.
          */
-        virtual void clearBody() throw( cms::CMSException ) {
+        virtual void clearBody() throw( cms::CMSException );
 
-            // Invoke base class's version.
-            ActiveMQMessageTemplate<cms::BytesMessage>::clearBody();
-
-            outputStream.setBuffer( getContent() );
-        }
+        /**
+         * Store the Data that was written to the stream before a send
+         */
+        virtual void onSend();
 
     public:   // CMS BytesMessage
 
@@ -136,65 +133,104 @@
          * sets the bytes given to the message body.
          *
          * @param buffer
-         *      Byte Buffer to copy.
+         *      Byte Buffer to copy
          * @param numBytes
-         *      Number of bytes in Buffer to copy.
-         * @throws CMSException
+         *      Number of bytes in Buffer to copy
+         *
+         * @throws CMSException - If an internal error occurs.
+         * @throws MessageNotWriteableException - if in Read Only Mode.
          */
-        virtual void setBodyBytes( const unsigned char* buffer,
-                                   std::size_t numBytes ) throw( cms::CMSException );
+        virtual void setBodyBytes( const unsigned char* buffer, std::size_t numBytes )
+            throw( cms::MessageNotWriteableException, cms::CMSException );
 
         /**
          * Gets the bytes that are contained in this message, user should
          * copy this data into a user allocated buffer.  Call
          * <code>getBodyLength</code> to determine the number of bytes
          * to expect.
+         *
          * @return const pointer to a byte buffer
+         *
+         * @throws CMSException - If an internal error occurs.
+         * @throws MessageNotReadableException - If the message is in Write Only Mode.
          */
-        virtual const unsigned char* getBodyBytes() const throw( cms::CMSException );
+        virtual unsigned char* getBodyBytes() const
+            throw( cms::MessageNotReadableException, cms::CMSException );
 
         /**
          * Returns the number of bytes contained in the body of this message.
+         *
          * @return number of bytes.
+         *
+         * @throws CMSException - If an internal error occurs.
+         * @throws MessageNotReadableException - If the message is in Write Only Mode.
          */
-        virtual std::size_t getBodyLength() const throw( cms::CMSException );
+        virtual std::size_t getBodyLength() const
+            throw( cms::MessageNotReadableException, cms::CMSException );
 
         /**
          * Puts the message body in read-only mode and repositions the stream
          * of bytes to the beginning.
-         * @throws CMSException
+         *
+         * @throws CMSException - If the provider fails to perform the reset operation.
+         * @throws MessageFormatException - If the Message has an invalid format.
          */
-        virtual void reset() throw ( cms::CMSException );
+        virtual void reset() throw ( cms::MessageFormatException, cms::CMSException );
 
         /**
          * Reads a Boolean from the Bytes message stream
          * @returns boolean value from stream
-         * @throws CMSException
-         */
-        virtual bool readBoolean() const throw ( cms::CMSException );
+         *
+         * @throws CMSException - if the CMS provider fails to read the message due to
+         *                        some internal error.
+         * @throws MessageEOFException - if unexpected end of bytes stream has been reached.
+         * @throws MessageNotReadableException - if the message is in write-only mode.
+         */
+        virtual bool readBoolean() const throw ( cms::MessageEOFException,
+                                                 cms::MessageNotReadableException,
+                                                 cms::CMSException );
 
         /**
          * Writes a boolean to the bytes message stream as a 1-byte value.
          * The value true is written as the value (byte)1; the value false
          * is written as the value (byte)0.
-         * @param value - boolean to write to the stream
-         * @throws CMSException
+         *
+         * @param value
+         *      boolean to write to the stream
+         *
+         * @throws CMSException - if the CMS provider fails to write the message due to
+         *                        some internal error.
+         * @throws MessageNotWriteableException - if the message is in read-only mode.
          */
-        virtual void writeBoolean( bool value ) throw ( cms::CMSException );
+        virtual void writeBoolean( bool value ) throw ( cms::MessageNotWriteableException,
+                                                        cms::CMSException );
 
         /**
          * Reads a Byte from the Bytes message stream
+         *
          * @returns unsigned char value from stream
-         * @throws CMSException
-         */
-        virtual unsigned char readByte() const throw ( cms::CMSException );
+         *
+         * @throws CMSException - if the CMS provider fails to read the message due to
+         *                        some internal error.
+         * @throws MessageEOFException - if unexpected end of bytes stream has been reached.
+         * @throws MessageNotReadableException - if the message is in write-only mode.
+         */
+        virtual unsigned char readByte() const throw ( cms::MessageEOFException,
+                                                       cms::MessageNotReadableException,
+                                                       cms::CMSException );
 
         /**
          * Writes a byte to the bytes message stream as a 1-byte value
-         * @param value - byte to write to the stream
-         * @throws CMSException
+         *
+         * @param value
+         *      byte to write to the stream
+         *
+         * @throws CMSException - if the CMS provider fails to write the message due to
+         *                        some internal error.
+         * @throws MessageNotWriteableException - if the message is in read-only mode.
          */
-        virtual void writeByte( unsigned char value ) throw ( cms::CMSException );
+        virtual void writeByte( unsigned char value ) throw ( cms::MessageNotWriteableException,
+                                                              cms::CMSException );
 
         /**
          * Reads a byte array from the bytes message stream.
@@ -209,23 +245,35 @@
          * length of the vector, indicating that there are no more bytes left to
          * be read from the stream. The next read of the stream returns -1.
          *
-         * @param value - buffer to place data in
+         * @param value
+         *      buffer to place data in
          * @returns the total number of bytes read into the buffer, or -1 if
          *          there is no more data because the end of the stream has
          *          been reached
-         * @throws CMSException if an error occurs.
+         *
+         * @throws CMSException - if the CMS provider fails to read the message due to
+         *                        some internal error.
+         * @throws MessageEOFException - if unexpected end of bytes stream has been reached.
+         * @throws MessageNotReadableException - if the message is in write-only mode.
          */
         virtual std::size_t readBytes( std::vector<unsigned char>& value ) const
-            throw ( cms::CMSException );
+            throw ( cms::MessageEOFException,
+                    cms::MessageNotReadableException,
+                    cms::CMSException );
 
         /**
          * Writes a byte array to the bytes message stream using the vector
          * size as the number of bytes to write.
-         * @param value - bytes to write to the stream.
-         * @throws CMSException
+         *
+         * @param value
+         *      bytes to write to the stream
+         *
+         * @throws CMSException - if the CMS provider fails to write the message due to
+         *                        some internal error.
+         * @throws MessageNotWriteableException - if the message is in read-only mode.
          */
-        virtual void writeBytes(
-            const std::vector<unsigned char>& value ) throw ( cms::CMSException );
+        virtual void writeBytes( const std::vector<unsigned char>& value )
+            throw ( cms::MessageNotWriteableException, cms::CMSException );
 
         /**
          * Reads a portion of the bytes message stream.
@@ -244,154 +292,292 @@
          * array value, then an IndexOutOfBoundsException is thrown. No bytes
          * will be read from the stream for this exception case.
          *
-         * @param buffer - the buffer into which the data is read
-         * @param length - the number of bytes to read; must be less than or
-         *                 equal to value.length
+         * @param buffer
+         *      the buffer into which the data is read
+         * @param length
+         *      the number of bytes to read; must be less than or equal to
+         *      value.length
          * @returns the total number of bytes read into the buffer, or -1 if
          *          there is no more data because the end of the stream has
          *          been reached
-         * @throws CMSException
-         */
-        virtual std::size_t readBytes( unsigned char*& buffer, std::size_t length ) const
-            throw ( cms::CMSException );
+         *
+         * @throws CMSException - if the CMS provider fails to read the message due to
+         *                        some internal error.
+         * @throws MessageEOFException - if unexpected end of bytes stream has been reached.
+         * @throws MessageNotReadableException - if the message is in write-only mode.
+         */
+        virtual std::size_t readBytes( unsigned char* buffer, std::size_t length ) const
+            throw ( cms::MessageEOFException,
+                    cms::MessageNotReadableException,
+                    cms::CMSException );
 
         /**
          * Writes a portion of a byte array to the bytes message stream.
          * size as the number of bytes to write.
-         * @param value - bytes to write to the stream
-         * @param offset - the initial offset within the byte array
-         * @param length - the number of bytes to use
-         * @throws CMSException
-         */
-        virtual void writeBytes( const unsigned char* value,
-                                 std::size_t offset,
-                                 std::size_t length ) throw ( cms::CMSException );
+         *
+         * @param value
+         *      bytes to write to the stream
+         * @param offset
+         *      the initial offset within the byte array
+         * @param length
+         *      the number of bytes to use
+         *
+         * @throws CMSException - if the CMS provider fails to write the message due to
+         *                        some internal error.
+         * @throws MessageNotWriteableException - if the message is in read-only mode.
+         */
+        virtual void writeBytes( const unsigned char* value, std::size_t offset, std::size_t length )
+            throw ( cms::MessageNotWriteableException, cms::CMSException );
 
         /**
          * Reads a Char from the Bytes message stream
+         *
          * @returns char value from stream
-         * @throws CMSException
-         */
-        virtual char readChar() const throw ( cms::CMSException );
+         *
+         * @throws CMSException - if the CMS provider fails to read the message due to
+         *                        some internal error.
+         * @throws MessageEOFException - if unexpected end of bytes stream has been reached.
+         * @throws MessageNotReadableException - if the message is in write-only mode.
+         */
+        virtual char readChar() const throw ( cms::MessageEOFException,
+                                              cms::MessageNotReadableException,
+                                              cms::CMSException );
 
         /**
          * Writes a char to the bytes message stream as a 1-byte value
-         * @param value - char to write to the stream
-         * @throws CMSException
+         *
+         * @param value
+         *      char to write to the stream
+         *
+         * @throws CMSException - if the CMS provider fails to write the message due to
+         *                        some internal error.
+         * @throws MessageNotWriteableException - if the message is in read-only mode.
          */
-        virtual void writeChar( char value ) throw ( cms::CMSException );
+        virtual void writeChar( char value ) throw ( cms::MessageNotWriteableException,
+                                                     cms::CMSException );
 
         /**
          * Reads a 32 bit float from the Bytes message stream
+         *
          * @returns double value from stream
-         * @throws CMSException
-         */
-        virtual float readFloat() const throw ( cms::CMSException );
+         *
+         * @throws CMSException - if the CMS provider fails to read the message due to
+         *                        some internal error.
+         * @throws MessageEOFException - if unexpected end of bytes stream has been reached.
+         * @throws MessageNotReadableException - if the message is in write-only mode.
+         */
+        virtual float readFloat() const throw ( cms::MessageEOFException,
+                                                cms::MessageNotReadableException,
+                                                cms::CMSException );
 
         /**
          * Writes a float to the bytes message stream as a 4 byte value
-         * @param value - float to write to the stream
-         * @throws CMSException
+         * @param value
+         *      float to write to the stream
+         *
+         * @throws CMSException - if the CMS provider fails to write the message due to
+         *                        some internal error.
+         * @throws MessageNotWriteableException - if the message is in read-only mode.
          */
-        virtual void writeFloat( float value ) throw ( cms::CMSException );
+        virtual void writeFloat( float value ) throw ( cms::MessageNotWriteableException,
+                                                       cms::CMSException );
 
         /**
          * Reads a 64 bit double from the Bytes message stream
+         *
          * @returns double value from stream
-         * @throws CMSException
-         */
-        virtual double readDouble() const throw ( cms::CMSException );
+         *
+         * @throws CMSException - if the CMS provider fails to read the message due to
+         *                        some internal error.
+         * @throws MessageEOFException - if unexpected end of bytes stream has been reached.
+         * @throws MessageNotReadableException - if the message is in write-only mode.
+         */
+        virtual double readDouble() const throw ( cms::MessageEOFException,
+                                                  cms::MessageNotReadableException,
+                                                  cms::CMSException );
 
         /**
          * Writes a double to the bytes message stream as a 8 byte value
-         * @param value - double to write to the stream
-         * @throws CMSException
+         * @param value
+         *      double to write to the stream
+         *
+         * @throws CMSException - if the CMS provider fails to write the message due to
+         *                        some internal error.
+         * @throws MessageNotWriteableException - if the message is in read-only mode.
          */
-        virtual void writeDouble( double value ) throw ( cms::CMSException );
+        virtual void writeDouble( double value ) throw ( cms::MessageNotWriteableException,
+                                                         cms::CMSException );
 
         /**
          * Reads a 16 bit signed short from the Bytes message stream
+         *
          * @returns short value from stream
-         * @throws CMSException
-         */
-        virtual short readShort() const throw ( cms::CMSException );
+         *
+         * @throws CMSException - if the CMS provider fails to read the message due to
+         *                        some internal error.
+         * @throws MessageEOFException - if unexpected end of bytes stream has been reached.
+         * @throws MessageNotReadableException - if the message is in write-only mode.
+         */
+        virtual short readShort() const throw ( cms::MessageEOFException,
+                                                cms::MessageNotReadableException,
+                                                cms::CMSException );
 
         /**
          * Writes a signed short to the bytes message stream as a 2 byte value
-         * @param value - signed short to write to the stream
-         * @throws CMSException
+         *
+         * @param value
+         *      signed short to write to the stream
+         *
+         * @throws CMSException - if the CMS provider fails to write the message due to
+         *                        some internal error.
+         * @throws MessageNotWriteableException - if the message is in read-only mode.
          */
-        virtual void writeShort( short value ) throw ( cms::CMSException );
+        virtual void writeShort( short value ) throw ( cms::MessageNotWriteableException,
+                                                       cms::CMSException );
 
         /**
          * Reads a 16 bit unsigned short from the Bytes message stream
+         *
          * @returns unsigned short value from stream
-         * @throws CMSException
-         */
-        virtual unsigned short readUnsignedShort() const throw ( cms::CMSException );
+         *
+         * @throws CMSException - if the CMS provider fails to read the message due to
+         *                        some internal error.
+         * @throws MessageEOFException - if unexpected end of bytes stream has been reached.
+         * @throws MessageNotReadableException - if the message is in write-only mode.
+         */
+        virtual unsigned short readUnsignedShort() const throw ( cms::MessageEOFException,
+                                                                 cms::MessageNotReadableException,
+                                                                 cms::CMSException );
 
         /**
          * Writes a unsigned short to the bytes message stream as a 2 byte value
-         * @param value - unsigned short to write to the stream
-         * @throws CMSException
+         *
+         * @param value
+         *      unsigned short to write to the stream
+         *
+         * @throws CMSException - if the CMS provider fails to write the message due to
+         *                        some internal error.
+         * @throws MessageNotWriteableException - if the message is in read-only mode.
          */
-        virtual void writeUnsignedShort( unsigned short value ) throw ( cms::CMSException );
+        virtual void writeUnsignedShort( unsigned short value )
+            throw ( cms::MessageNotWriteableException, cms::CMSException );
 
         /**
-         * Reads a 32 bit signed intger from the Bytes message stream
+         * Reads a 32 bit signed integer from the Bytes message stream
+         *
          * @returns int value from stream
-         * @throws CMSException
-         */
-        virtual int readInt() const throw ( cms::CMSException );
+         *
+         * @throws CMSException - if the CMS provider fails to read the message due to
+         *                        some internal error.
+         * @throws MessageEOFException - if unexpected end of bytes stream has been reached.
+         * @throws MessageNotReadableException - if the message is in write-only mode.
+         */
+        virtual int readInt() const throw ( cms::MessageEOFException,
+                                            cms::MessageNotReadableException,
+                                            cms::CMSException );
 
         /**
          * Writes a signed int to the bytes message stream as a 4 byte value
-         * @param value - signed int to write to the stream
-         * @throws CMSException
+         *
+         * @param value
+         *      signed int to write to the stream
+         *
+         * @throws CMSException - if the CMS provider fails to write the message due to
+         *                        some internal error.
+         * @throws MessageNotWriteableException - if the message is in read-only mode.
          */
-        virtual void writeInt( int value ) throw ( cms::CMSException );
+        virtual void writeInt( int value ) throw ( cms::MessageNotWriteableException,
+                                                   cms::CMSException );
 
         /**
          * Reads a 64 bit long from the Bytes message stream
+         *
          * @returns long long value from stream
-         * @throws CMSException
-         */
-        virtual long long readLong() const throw ( cms::CMSException );
+         *
+         * @throws CMSException - if the CMS provider fails to read the message due to
+         *                        some internal error.
+         * @throws MessageEOFException - if unexpected end of bytes stream has been reached.
+         * @throws MessageNotReadableException - if the message is in write-only mode.
+         */
+        virtual long long readLong() const throw ( cms::MessageEOFException,
+                                                   cms::MessageNotReadableException,
+                                                   cms::CMSException );
 
         /**
          * Writes a long long to the bytes message stream as a 8 byte value
-         * @param value - signed long long to write to the stream
-         * @throws CMSException
+         *
+         * @param value
+         *      signed long long to write to the stream
+         *
+         * @throws CMSException - if the CMS provider fails to write the message due to
+         *                        some internal error.
+         * @throws MessageNotWriteableException - if the message is in read-only mode.
          */
-        virtual void writeLong( long long value ) throw ( cms::CMSException );
+        virtual void writeLong( long long value ) throw ( cms::MessageNotWriteableException,
+                                                          cms::CMSException );
 
         /**
          * Reads an ASCII String from the Bytes message stream
+         *
          * @returns String from stream
-         * @throws CMSException
-         */
-        virtual std::string readString() const throw ( cms::CMSException );
+         *
+         * @throws CMSException - if the CMS provider fails to read the message due to
+         *                        some internal error.
+         * @throws MessageEOFException - if unexpected end of bytes stream has been reached.
+         * @throws MessageNotReadableException - if the message is in write-only mode.
+         */
+        virtual std::string readString() const throw ( cms::MessageEOFException,
+                                                       cms::MessageNotReadableException,
+                                                       cms::CMSException );
 
         /**
          * Writes an ASCII String to the Bytes message stream
-         * @param value - String to write to the stream
-         * @throws CMSException
+         *
+         * @param value
+         *      String to write to the stream
+         *
+         * @throws CMSException - if the CMS provider fails to write the message due to
+         *                        some internal error.
+         * @throws MessageNotWriteableException - if the message is in read-only mode.
          */
-        virtual void writeString( const std::string& value ) throw ( cms::CMSException );
+        virtual void writeString( const std::string& value )
+            throw ( cms::MessageNotWriteableException, cms::CMSException );
 
         /**
          * Reads an UTF String from the BytesMessage stream
+         *
          * @returns String from stream
-         * @throws CMSException
-         */
-        virtual std::string readUTF() const throw ( cms::CMSException );
+         *
+         * @throws CMSException - if the CMS provider fails to read the message due to
+         *                        some internal error.
+         * @throws MessageEOFException - if unexpected end of bytes stream has been reached.
+         * @throws MessageNotReadableException - if the message is in write-only mode.
+         */
+        virtual std::string readUTF() const throw ( cms::MessageEOFException,
+                                                    cms::MessageNotReadableException,
+                                                    cms::CMSException );
 
         /**
          * Writes an UTF String to the BytesMessage stream
-         * @param value - String to write to the stream
-         * @throws CMSException
+         *
+         * @param value
+         *      String to write to the stream
+         *
+         * @throws CMSException - if the CMS provider fails to read the message due to
+         *                        some internal error.
+         * @throws MessageEOFException - if unexpected end of bytes stream has been reached.
+         * @throws MessageNotReadableException - if the message is in write-only mode.
          */
-        virtual void writeUTF( const std::string& value ) throw ( cms::CMSException );
+        virtual void writeUTF( const std::string& value )
+            throw ( cms::MessageNotWriteableException, cms::CMSException );
+
+    private:
+
+        void storeContent();
+
+        void initializeReading() const;
+
+        void initializeWriting();
 
     };
 

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQMapMessage.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQMapMessage.cpp?rev=882361&r1=882360&r2=882361&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQMapMessage.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQMapMessage.cpp Thu Nov 19 23:37:26 2009
@@ -18,6 +18,8 @@
 #include <activemq/wireformat/openwire/marshal/PrimitiveTypesMarshaller.h>
 #include <activemq/util/CMSExceptionSupport.h>
 
+#include <decaf/lang/exceptions/UnsupportedOperationException.h>
+
 using namespace std;
 using namespace decaf;
 using namespace decaf::lang;
@@ -80,6 +82,13 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
+void ActiveMQMapMessage::clearBody() throw( cms::CMSException ) {
+
+    ActiveMQMessageTemplate<cms::MapMessage>::clearBody();
+    this->getMap().clear();
+}
+
+////////////////////////////////////////////////////////////////////////////////
 void ActiveMQMapMessage::beforeMarshal( WireFormat* wireFormat )
     throw ( decaf::io::IOException ) {
 
@@ -174,20 +183,22 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 bool ActiveMQMapMessage::getBoolean( const std::string& name ) const
-    throw( cms::CMSException ) {
+    throw( cms::MessageFormatException, cms::CMSException ) {
 
     try{
         return getMap().getBool( name );
+    } catch( UnsupportedOperationException& ex ) {
+        throw CMSExceptionSupport::createMessageFormatException( ex );
     }
     AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 void ActiveMQMapMessage::setBoolean( const std::string& name, bool value )
-    throw( cms::CMSException ) {
+    throw( cms::MessageNotWriteableException, cms::CMSException ) {
 
+    failIfReadOnlyBody();
     try{
-        failIfReadOnlyBody();
         getMap().setBool( name, value );
     }
     AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
@@ -195,21 +206,22 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 unsigned char ActiveMQMapMessage::getByte( const std::string& name ) const
-    throw( cms::CMSException ) {
+    throw( cms::MessageFormatException, cms::CMSException ) {
 
     try{
         return getMap().getByte( name );
+    } catch( UnsupportedOperationException& ex ) {
+        throw CMSExceptionSupport::createMessageFormatException( ex );
     }
     AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void ActiveMQMapMessage::setByte( const std::string& name,
-                                  unsigned char value )
-                                      throw( cms::CMSException ) {
+void ActiveMQMapMessage::setByte( const std::string& name, unsigned char value )
+    throw( cms::MessageNotWriteableException, cms::CMSException ) {
 
+    failIfReadOnlyBody();
     try{
-        failIfReadOnlyBody();
         getMap().setByte( name, value );
     }
     AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
@@ -217,10 +229,12 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 std::vector<unsigned char> ActiveMQMapMessage::getBytes( const std::string& name ) const
-    throw( cms::CMSException ) {
+    throw( cms::MessageFormatException, cms::CMSException ) {
 
     try{
         return getMap().getByteArray( name );
+    } catch( UnsupportedOperationException& ex ) {
+        throw CMSExceptionSupport::createMessageFormatException( ex );
     }
     AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
 }
@@ -228,10 +242,10 @@
 ////////////////////////////////////////////////////////////////////////////////
 void ActiveMQMapMessage::setBytes( const std::string& name,
                                    const std::vector<unsigned char>& value )
-                                       throw( cms::CMSException ) {
+                                       throw( cms::MessageNotWriteableException, cms::CMSException ) {
 
+    failIfReadOnlyBody();
     try{
-        failIfReadOnlyBody();
         getMap().setByteArray( name, value );
     }
     AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
@@ -239,20 +253,22 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 char ActiveMQMapMessage::getChar( const std::string& name ) const
-    throw( cms::CMSException ) {
+    throw( cms::MessageFormatException, cms::CMSException ) {
 
     try{
         return getMap().getChar( name );
+    } catch( UnsupportedOperationException& ex ) {
+        throw CMSExceptionSupport::createMessageFormatException( ex );
     }
     AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 void ActiveMQMapMessage::setChar( const std::string& name, char value )
-    throw( cms::CMSException ) {
+    throw( cms::MessageNotWriteableException, cms::CMSException ) {
 
+    failIfReadOnlyBody();
     try{
-        failIfReadOnlyBody();
         getMap().setChar( name, value );
     }
     AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
@@ -260,21 +276,22 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 double ActiveMQMapMessage::getDouble( const std::string& name ) const
-    throw( cms::CMSException ) {
+    throw( cms::MessageFormatException, cms::CMSException ) {
 
     try{
         return getMap().getDouble( name );
+    } catch( UnsupportedOperationException& ex ) {
+        throw CMSExceptionSupport::createMessageFormatException( ex );
     }
     AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void ActiveMQMapMessage::setDouble( const std::string& name,
-                                    double value )
-                                        throw( cms::CMSException ) {
+void ActiveMQMapMessage::setDouble( const std::string& name, double value )
+    throw( cms::MessageNotWriteableException, cms::CMSException ) {
 
+    failIfReadOnlyBody();
     try{
-        failIfReadOnlyBody();
         getMap().setDouble( name, value );
     }
     AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
@@ -282,20 +299,22 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 float ActiveMQMapMessage::getFloat( const std::string& name ) const
-    throw( cms::CMSException ) {
+    throw( cms::MessageFormatException, cms::CMSException ) {
 
     try{
         return getMap().getFloat( name );
+    } catch( UnsupportedOperationException& ex ) {
+        throw CMSExceptionSupport::createMessageFormatException( ex );
     }
     AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 void ActiveMQMapMessage::setFloat( const std::string& name, float value )
-    throw( cms::CMSException ) {
+    throw( cms::MessageNotWriteableException, cms::CMSException ) {
 
+    failIfReadOnlyBody();
     try{
-        failIfReadOnlyBody();
         getMap().setFloat( name, value );
     }
     AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
@@ -303,20 +322,22 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 int ActiveMQMapMessage::getInt( const std::string& name ) const
-    throw( cms::CMSException ) {
+    throw( cms::MessageFormatException, cms::CMSException ) {
 
     try{
         return getMap().getInt( name );
+    } catch( UnsupportedOperationException& ex ) {
+        throw CMSExceptionSupport::createMessageFormatException( ex );
     }
     AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 void ActiveMQMapMessage::setInt( const std::string& name, int value )
-    throw( cms::CMSException ) {
+    throw( cms::MessageNotWriteableException, cms::CMSException ) {
 
+    failIfReadOnlyBody();
     try{
-        failIfReadOnlyBody();
         getMap().setInt( name, value );
     }
     AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
@@ -324,20 +345,22 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 long long ActiveMQMapMessage::getLong( const std::string& name ) const
-    throw( cms::CMSException ) {
+    throw( cms::MessageFormatException, cms::CMSException ) {
 
     try{
         return getMap().getLong( name );
+    } catch( UnsupportedOperationException& ex ) {
+        throw CMSExceptionSupport::createMessageFormatException( ex );
     }
     AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 void ActiveMQMapMessage::setLong( const std::string& name, long long value )
-    throw( cms::CMSException ) {
+    throw( cms::MessageNotWriteableException, cms::CMSException ) {
 
+    failIfReadOnlyBody();
     try{
-        failIfReadOnlyBody();
         getMap().setLong( name, value );
     }
     AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
@@ -345,20 +368,22 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 short ActiveMQMapMessage::getShort( const std::string& name ) const
-    throw( cms::CMSException ) {
+    throw( cms::MessageFormatException, cms::CMSException ) {
 
     try{
         return getMap().getShort( name );
+    } catch( UnsupportedOperationException& ex ) {
+        throw CMSExceptionSupport::createMessageFormatException( ex );
     }
     AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 void ActiveMQMapMessage::setShort( const std::string& name, short value )
-    throw( cms::CMSException ) {
+    throw( cms::MessageNotWriteableException, cms::CMSException ) {
 
+    failIfReadOnlyBody();
     try{
-        failIfReadOnlyBody();
         getMap().setShort( name, value );
     }
     AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
@@ -366,21 +391,22 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 std::string ActiveMQMapMessage::getString( const std::string& name ) const
-    throw( cms::CMSException ) {
+    throw( cms::MessageFormatException, cms::CMSException ) {
 
     try{
         return getMap().getString( name );
+    } catch( UnsupportedOperationException& ex ) {
+        throw CMSExceptionSupport::createMessageFormatException( ex );
     }
     AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void ActiveMQMapMessage::setString( const std::string& name,
-                                    const std::string& value )
-                                        throw( cms::CMSException ) {
+void ActiveMQMapMessage::setString( const std::string& name, const std::string& value )
+    throw( cms::MessageNotWriteableException, cms::CMSException ) {
 
+    failIfReadOnlyBody();
     try{
-        failIfReadOnlyBody();
         getMap().setString( name, value );
     }
     AMQ_CATCH_ALL_THROW_CMSEXCEPTION()

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQMapMessage.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQMapMessage.h?rev=882361&r1=882360&r2=882361&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQMapMessage.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQMapMessage.h Thu Nov 19 23:37:26 2009
@@ -98,6 +98,12 @@
          */
         virtual bool equals( const DataStructure* value ) const;
 
+        /**
+         * Clears out the body of the message.  This does not clear the
+         * headers or properties.
+         */
+        virtual void clearBody() throw( cms::CMSException );
+
     public:   // CMS Message
 
         /**
@@ -114,192 +120,285 @@
         /**
          * 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
+         *
+         * @throws CMSException - if the operation fails due to an internal error.
          */
-        virtual std::vector<std::string> getMapNames() const throw( cms::CMSException );
+        virtual std::vector< std::string > getMapNames() const throw( cms::CMSException );
 
         /**
          * Indicates whether an item exists in this MapMessage object.
-         * @param name - String name of the Object in question
+         *
+         * @param name
+         *      String name of the Object in question
          * @return boolean value indicating if the name is in the map
-         * @throws CMSException
+         *
+         * @throws CMSException - if the operation fails due to an internal error.
          */
         virtual bool itemExists( const std::string& name ) const throw( cms::CMSException );
 
         /**
          * Returns the Boolean value of the Specified name
-         * @param name of the value to fetch from the map
-         * @throws CMSException
+         *
+         * @param name
+         *      Name of the value to fetch from the map
+         *
+         * @throws CMSException - if the operation fails due to an internal error.
+         * @throws MessageFormatExceptio - if this type conversion is invalid.
          */
         virtual bool getBoolean( const std::string& name ) const
-            throw( cms::CMSException );
+            throw( cms::MessageFormatException, 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
+         *
+         * @param name
+         *      the name of the boolean
+         * @param value
+         *      the boolean value to set in the Map
+         *
+         * @throws CMSException - if the operation fails due to an internal error.
+         * @throws MessageNotWriteableException - if the Message is in Read-only Mode.
          */
-        virtual void setBoolean( const std::string& name,
-                                 bool value ) throw( cms::CMSException );
+        virtual void setBoolean( const std::string& name, bool value )
+            throw( cms::MessageNotWriteableException, cms::CMSException );
 
         /**
          * Returns the Byte value of the Specified name
-         * @param name of the value to fetch from the map
-         * @throws CMSException
+         *
+         * @param name
+         *      Name of the value to fetch from the map
+         *
+         * @throws CMSException - if the operation fails due to an internal error.
+         * @throws MessageFormatException - if this type conversion is invalid.
          */
         virtual unsigned char getByte( const std::string& name ) const
-            throw( cms::CMSException );
+            throw( cms::MessageFormatException, 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 );
+         *
+         * @param name
+         *      the name of the Byte
+         * @param value
+         *      the Byte value to set in the Map
+         *
+         * @throws CMSException - if the operation fails due to an internal error.
+         * @throws MessageNotWriteableException - if the Message is in Read-only Mode.
+         */
+        virtual void setByte( const std::string& name, unsigned char value )
+            throw( cms::MessageNotWriteableException, cms::CMSException );
 
         /**
          * Returns the Bytes value of the Specified name
-         * @param name of the value to fetch from the map
-         * @throws CMSException
+         *
+         * @param name
+         *      Name of the value to fetch from the map
+         *
+         * @throws CMSException - if the operation fails due to an internal error.
+         * @throws MessageFormatException - if this type conversion is invalid.
          */
         virtual std::vector<unsigned char> getBytes( const std::string& name ) const
-            throw( cms::CMSException );
+            throw( cms::MessageFormatException, 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
+         *
+         * @param name
+         *      The name of the Bytes
+         * @param value
+         *      The Bytes value to set in the Map
+         *
+         * @throws CMSException - if the operation fails due to an internal error.
+         * @throws MessageNotWriteableException - if the Message is in Read-only Mode.
          */
         virtual void setBytes( const std::string& name,
                                const std::vector<unsigned char>& value )
-                                   throw( cms::CMSException );
+                                    throw( cms::MessageNotWriteableException, cms::CMSException );
 
         /**
          * Returns the Char value of the Specified name
-         * @param name of the value to fetch from the map
-         * @throws CMSException
+         *
+         * @param name
+         *      name of the value to fetch from the map
+         *
+         * @throws CMSException - if the operation fails due to an internal error.
+         * @throws MessageFormatException - if this type conversion is invalid.
          */
         virtual char getChar( const std::string& name ) const
-            throw( cms::CMSException );
+            throw( cms::MessageFormatException, 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
+         *
+         * @param name
+         *      the name of the Char
+         * @param value
+         *      the Char value to set in the Map
+         *
+         * @throws CMSException - if the operation fails due to an internal error.
+         * @throws MessageNotWriteableException - if the Message is in Read-only Mode.
          */
         virtual void setChar( const std::string& name, char value )
-            throw( cms::CMSException );
+            throw( cms::MessageNotWriteableException, cms::CMSException );
 
         /**
          * Returns the Double value of the Specified name
-         * @param name of the value to fetch from the map
-         * @throws CMSException
+         *
+         * @param name
+         *      Name of the value to fetch from the map
+         *
+         * @throws CMSException - if the operation fails due to an internal error.
+         * @throws MessageFormatException - if this type conversion is invalid.
          */
         virtual double getDouble( const std::string& name ) const
-            throw( cms::CMSException );
+            throw( cms::MessageFormatException, 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
+         *
+         * @param name
+         *      The name of the Double
+         * @param value
+         *      The Double value to set in the Map
+         *
+         * @throws CMSException - if the operation fails due to an internal error.
+         * @throws MessageNotWriteableException - if the Message is in Read-only Mode.
          */
-        virtual void setDouble( const std::string& name,
-                                double value ) throw( cms::CMSException );
+        virtual void setDouble( const std::string& name, double value )
+            throw( cms::MessageNotWriteableException, cms::CMSException );
 
         /**
          * Returns the Float value of the Specified name
-         * @param name of the value to fetch from the map
-         * @throws CMSException
+         *
+         * @param name
+         *      Name of the value to fetch from the map
+         *
+         * @throws CMSException - if the operation fails due to an internal error.
+         * @throws MessageFormatException - if this type conversion is invalid.
          */
         virtual float getFloat( const std::string& name ) const
-            throw( cms::CMSException );
+            throw( cms::MessageFormatException, 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
+         *
+         * @param name
+         *      The name of the Float
+         * @param value
+         *      The Float value to set in the Map
+         *
+         * @throws CMSException - if the operation fails due to an internal error.
+         * @throws MessageNotWriteableException - if the Message is in Read-only Mode.
          */
         virtual void setFloat( const std::string& name, float value )
-            throw( cms::CMSException );
+            throw( cms::MessageNotWriteableException, cms::CMSException );
 
         /**
          * Returns the Int value of the Specified name
-         * @param name of the value to fetch from the map
-         * @throws CMSException
+         *
+         * @param name
+         *      Name of the value to fetch from the map
+         *
+         * @throws CMSException - if the operation fails due to an internal error.
+         * @throws MessageFormatException - if this type conversion is invalid.
          */
         virtual int getInt( const std::string& name ) const
-            throw( cms::CMSException );
+            throw( cms::MessageFormatException, 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
+         *
+         * @param name
+         *      The name of the Int
+         * @param value
+         *      The Int value to set in the Map
+         *
+         * @throws CMSException - if the operation fails due to an internal error.
+         * @throws MessageNotWriteableException - if the Message is in Read-only Mode.
          */
         virtual void setInt( const std::string& name, int value )
-            throw( cms::CMSException );
+            throw( cms::MessageNotWriteableException, cms::CMSException );
 
         /**
          * Returns the Long value of the Specified name
-         * @param name of the value to fetch from the map
-         * @throws CMSException
+         *
+         * @param name
+         *      Name of the value to fetch from the map
+         *
+         * @throws CMSException - if the operation fails due to an internal error.
+         * @throws MessageFormatException - if this type conversion is invalid.
          */
         virtual long long getLong( const std::string& name ) const
-            throw( cms::CMSException );
+            throw( cms::MessageFormatException, 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
+         *
+         * @param name
+         *      The name of the Long
+         * @param value
+         *      The Long value to set in the Map
+         *
+         * @throws CMSException - if the operation fails due to an internal error.
+         * @throws MessageNotWriteableException - if the Message is in Read-only Mode.
          */
         virtual void setLong( const std::string& name, long long value )
-            throw( cms::CMSException );
+            throw( cms::MessageNotWriteableException, cms::CMSException );
 
         /**
          * Returns the Short value of the Specified name
-         * @param name of the value to fetch from the map
-         * @throws CMSException
+         *
+         * @param name
+         *      Name of the value to fetch from the map
+         *
+         * @throws CMSException - if the operation fails due to an internal error.
+         * @throws MessageFormatException - if this type conversion is invalid.
          */
         virtual short getShort( const std::string& name ) const
-            throw( cms::CMSException );
+            throw( cms::MessageFormatException, 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
+         *
+         * @param name
+         *      The name of the Short
+         * @param value
+         *      The Short value to set in the Map
+         *
+         * @throws CMSException - if the operation fails due to an internal error.
+         * @throws MessageNotWriteableException - if the Message is in Read-only Mode.
          */
         virtual void setShort( const std::string& name, short value )
-            throw( cms::CMSException );
+            throw( cms::MessageNotWriteableException, cms::CMSException );
 
         /**
          * Returns the String value of the Specified name
-         * @param name of the value to fetch from the map
-         * @throws CMSException
+         *
+         * @param name
+         *      Name of the value to fetch from the map
+         *
+         * @throws CMSException - if the operation fails due to an internal error.
+         * @throws MessageFormatException - if this type conversion is invalid.
          */
         virtual std::string getString( const std::string& name ) const
-            throw( cms::CMSException );
+            throw( cms::MessageFormatException, 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 );
+         *
+         * @param name
+         *      The name of the String
+         * @param value
+         *      The String value to set in the Map
+         *
+         * @throws CMSException - if the operation fails due to an internal error.
+         * @throws MessageNotWriteableException - if the Message is in Read-only Mode.
+         */
+        virtual void setString( const std::string& name, const std::string& value )
+            throw( cms::MessageNotWriteableException, cms::CMSException );
 
     protected: