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 2010/03/20 22:57:24 UTC

svn commit: r925692 [7/14] - in /activemq/activemq-cpp/trunk/activemq-cpp/src: main/ main/activemq/commands/ main/activemq/io/ main/activemq/wireformat/openwire/ main/activemq/wireformat/openwire/marshal/ main/decaf/internal/io/ main/decaf/internal/nio...

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/Writer.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/Writer.h?rev=925692&r1=925691&r2=925692&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/Writer.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/Writer.h Sat Mar 20 21:57:20 2010
@@ -77,7 +77,7 @@ namespace io{
          * @throws IOException if an I/O error occurs.
          * @throws NullPointerException if buffer is NULL.
          */
-        virtual void write( const char* buffer, std::size_t size )
+        virtual void write( const char* buffer, int size )
             throw( decaf::io::IOException,
                    decaf::lang::exceptions::NullPointerException );
 
@@ -97,7 +97,7 @@ namespace io{
          * @throws NullPointerException if buffer is NULL.
          * @throws IndexOutOfBoundsException if offset + length > size of the buffer.
          */
-        virtual void write( const char* buffer, std::size_t size, std::size_t offset, std::size_t length )
+        virtual void write( const char* buffer, int size, int offset, int length )
             throw( decaf::io::IOException,
                    decaf::lang::exceptions::NullPointerException,
                    decaf::lang::exceptions::IndexOutOfBoundsException );
@@ -125,7 +125,7 @@ namespace io{
          * @throws IOException thrown if an error occurs.
          * @throws IndexOutOfBoundsException if offset+length is greater than the string length.
          */
-        virtual void write( const std::string& str, std::size_t offset, std::size_t length )
+        virtual void write( const std::string& str, int offset, int length )
             throw( decaf::io::IOException,
                    decaf::lang::exceptions::IndexOutOfBoundsException );
 
@@ -134,8 +134,7 @@ namespace io{
         virtual decaf::lang::Appendable& append( const decaf::lang::CharSequence* csq )
             throw ( decaf::io::IOException );
 
-        virtual decaf::lang::Appendable& append( const decaf::lang::CharSequence* csq,
-                                                 std::size_t start, std::size_t end )
+        virtual decaf::lang::Appendable& append( const decaf::lang::CharSequence* csq, int start, int end )
             throw( decaf::io::IOException,
                    decaf::lang::exceptions::IndexOutOfBoundsException );
 
@@ -143,13 +142,12 @@ namespace io{
 
         /**
          * Override this method to customize the functionality of the method
-         * write( char* buffer, std::size_t offset, std::size_t length ).
+         * write( char* buffer, int size, int offset, int length ).
          *
          * All subclasses must override this method to provide the basic Writer
          * functionality.
          */
-        virtual void doWriteArrayBounded( const char* buffer, std::size_t size,
-                                          std::size_t offset, std::size_t length )
+        virtual void doWriteArrayBounded( const char* buffer, int size, int offset, int length )
             throw( decaf::io::IOException,
                    decaf::lang::exceptions::NullPointerException,
                    decaf::lang::exceptions::IndexOutOfBoundsException ) = 0;
@@ -161,13 +159,13 @@ namespace io{
         virtual void doWriteVector( const std::vector<char>& buffer )
             throw( decaf::io::IOException );
 
-        virtual void doWriteArray( const char* buffer, std::size_t size )
+        virtual void doWriteArray( const char* buffer, int size )
             throw( decaf::io::IOException,
                    decaf::lang::exceptions::NullPointerException );
 
         virtual void doWriteString( const std::string& str ) throw( decaf::io::IOException );
 
-        virtual void doWriteStringBounded( const std::string& str, std::size_t offset, std::size_t length )
+        virtual void doWriteStringBounded( const std::string& str, int offset, int length )
             throw( decaf::io::IOException,
                    decaf::lang::exceptions::IndexOutOfBoundsException );
 
@@ -177,7 +175,7 @@ namespace io{
             throw ( decaf::io::IOException );
 
         virtual decaf::lang::Appendable& doAppendCharSequenceStartEnd( const decaf::lang::CharSequence* csq,
-                                                                       std::size_t start, std::size_t end )
+                                                                       int start, int end )
             throw( decaf::io::IOException,
                    decaf::lang::exceptions::IndexOutOfBoundsException );
 

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Appendable.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Appendable.h?rev=925692&r1=925691&r2=925692&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Appendable.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Appendable.h Sat Mar 20 21:57:20 2010
@@ -93,8 +93,7 @@ namespace lang{
          * @throws IndexOutOfBoundsException start is greater than end, or end is
          *         greater than csq.length()
          */
-        virtual Appendable& append( const CharSequence* csq,
-                                    std::size_t start, std::size_t end )
+        virtual Appendable& append( const CharSequence* csq, int start, int end )
             throw( decaf::lang::Exception ) = 0;
 
     };

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/CharSequence.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/CharSequence.h?rev=925692&r1=925691&r2=925692&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/CharSequence.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/CharSequence.h Sat Mar 20 21:57:20 2010
@@ -41,16 +41,16 @@ namespace lang{
         /**
          * @returns the length of the underlying character sequence.
          */
-        virtual std::size_t length() const = 0;
+        virtual int length() const = 0;
 
         /**
          * Returns the Char at the specified index so long as the index is not
          * greater than the length of the sequence.
          * @param index - position to return the char at.
          * @returns the char at the given position
-         * @throws IndexOutOfBoundsException if index is > than length()
+         * @throws IndexOutOfBoundsException if index is > than length() or negative
          */
-        virtual char charAt( std::size_t index ) const
+        virtual char charAt( int index ) const
             throw( lang::exceptions::IndexOutOfBoundsException ) = 0;
 
         /**
@@ -61,9 +61,9 @@ namespace lang{
          * @param start - the start index, inclusive
          * @param end - the end index, exclusive
          * @returns a new CharSequence
-         * @throws IndexOutOfBoundsException if start or end > length()
+         * @throws IndexOutOfBoundsException if start or end > length() or start or end are negative.
          */
-        virtual CharSequence* subSequence( std::size_t start, std::size_t end ) const
+        virtual CharSequence* subSequence( int start, int end ) const
             throw( lang::exceptions::IndexOutOfBoundsException ) = 0;
 
         /**

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/String.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/String.cpp?rev=925692&r1=925691&r2=925692&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/String.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/String.cpp Sat Mar 20 21:57:20 2010
@@ -74,7 +74,7 @@ String::~String() {
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-std::size_t String::length() const {
+int String::length() const {
     return this->contents->offset + this->contents->length;
 }
 
@@ -84,14 +84,14 @@ bool String::isEmpty() const {
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-char String::charAt( std::size_t index ) const
+char String::charAt( int index ) const
     throw( lang::exceptions::IndexOutOfBoundsException ) {
 
     try{
 
-        if( index >= this->length() ) {
+        if( index < 0 || index >= this->length() ) {
             throw IndexOutOfBoundsException(
-                __FILE__, __LINE__, "Index given exceeds length of this String." );
+                __FILE__, __LINE__, "Index given is out of bounds: %d.", index );
         }
 
         return this->contents->value[this->contents->offset + index];
@@ -101,7 +101,7 @@ char String::charAt( std::size_t index )
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-CharSequence* String::subSequence( std::size_t start DECAF_UNUSED, std::size_t end DECAF_UNUSED ) const
+CharSequence* String::subSequence( int start DECAF_UNUSED, int end DECAF_UNUSED ) const
     throw( lang::exceptions::IndexOutOfBoundsException ) {
 
     try{

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/String.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/String.h?rev=925692&r1=925691&r2=925692&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/String.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/String.h Sat Mar 20 21:57:20 2010
@@ -69,18 +69,18 @@ namespace lang {
         /**
          * {@inheritDoc}
          */
-        virtual std::size_t length() const;
+        virtual int length() const;
 
         /**
          * {@inheritDoc}
          */
-        virtual char charAt( std::size_t index ) const
+        virtual char charAt( int index ) const
             throw( lang::exceptions::IndexOutOfBoundsException );
 
         /**
          * {@inheritDoc}
          */
-        virtual CharSequence* subSequence( std::size_t start, std::size_t end ) const
+        virtual CharSequence* subSequence( int start, int end ) const
             throw( lang::exceptions::IndexOutOfBoundsException );
 
         /**

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/BufferedSocket.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/BufferedSocket.cpp?rev=925692&r1=925691&r2=925692&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/BufferedSocket.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/BufferedSocket.cpp Sat Mar 20 21:57:20 2010
@@ -101,10 +101,8 @@ void BufferedSocket::connect( const char
         socket->connect( host, port );
 
         // Now create the buffered streams that wrap around the socket.
-        inputStream = new BufferedInputStream(
-            socket->getInputStream(), (std::size_t)inputBufferSize );
-        outputStream = new BufferedOutputStream(
-            socket->getOutputStream(), (std::size_t)outputBufferSize );
+        inputStream = new BufferedInputStream( socket->getInputStream(), inputBufferSize );
+        outputStream = new BufferedOutputStream( socket->getOutputStream(), outputBufferSize );
     }
     DECAF_CATCH_RETHROW( SocketException )
     DECAF_CATCH_EXCEPTION_CONVERT( Exception, SocketException )

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/SocketInputStream.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/SocketInputStream.cpp?rev=925692&r1=925691&r2=925692&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/SocketInputStream.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/SocketInputStream.cpp Sat Mar 20 21:57:20 2010
@@ -70,7 +70,7 @@ void SocketInputStream::close() throw( d
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-std::size_t SocketInputStream::available() const throw ( io::IOException ){
+int SocketInputStream::available() const throw ( io::IOException ){
 
     // Check for a closed call from socket class, if closed then this read fails.
     if( closed ){
@@ -160,8 +160,7 @@ int SocketInputStream::doReadByte() thro
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-int SocketInputStream::doReadArrayBounded( unsigned char* buffer, std::size_t size,
-                                           std::size_t offset, std::size_t length )
+int SocketInputStream::doReadArrayBounded( unsigned char* buffer, int size, int offset, int length )
     throw ( decaf::io::IOException,
             decaf::lang::exceptions::IndexOutOfBoundsException,
             decaf::lang::exceptions::NullPointerException ) {
@@ -183,10 +182,19 @@ int SocketInputStream::doReadArrayBounde
             "SocketInputStream::read - Buffer passed is Null" );
     }
 
-    if( length > size - offset ) {
+    if( size < 0 ) {
         throw IndexOutOfBoundsException(
-            __FILE__, __LINE__,
-            "Given size{%d} - offset{%d} is less than length{%d}.", size, offset, length );
+            __FILE__, __LINE__, "size parameter out of Bounds: %d.", size );
+    }
+
+    if( offset > size || offset < 0 ) {
+        throw IndexOutOfBoundsException(
+            __FILE__, __LINE__, "offset parameter out of Bounds: %d.", offset );
+    }
+
+    if( length < 0 || length > size - offset ) {
+        throw IndexOutOfBoundsException(
+            __FILE__, __LINE__, "length parameter out of Bounds: %d.", length );
     }
 
     apr_size_t aprSize = (apr_size_t)length;
@@ -222,7 +230,7 @@ int SocketInputStream::doReadArrayBounde
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-std::size_t SocketInputStream::skip( std::size_t num DECAF_UNUSED )
+long long SocketInputStream::skip( long long num DECAF_UNUSED )
     throw ( io::IOException, lang::exceptions::UnsupportedOperationException ) {
 
     throw lang::exceptions::UnsupportedOperationException(

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/SocketInputStream.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/SocketInputStream.h?rev=925692&r1=925691&r2=925692&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/SocketInputStream.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/SocketInputStream.h Sat Mar 20 21:57:20 2010
@@ -49,25 +49,24 @@ namespace net{
         virtual ~SocketInputStream();
 
         /**
-         * Returns the number of bytes available on the socket to
-         * be read right now.
-         * @return The number of bytes currently available to
-         * be read on the socket.
+         * {@inheritDoc}
          */
-        virtual std::size_t available() const throw ( io::IOException );
+        virtual int available() const throw ( io::IOException );
 
         /**
          * Close - does nothing.  It is the responsibility of the owner
          * of the socket object to close it.
-         * @throws IOException
+         *
+         * {@inheritDoc}
          */
         virtual void close() throw( decaf::io::IOException );
 
         /**
          * Not supported.
-         * @throws an UnsupportedOperationException.
+         *
+         * {@inheritDoc}
          */
-        virtual std::size_t skip( std::size_t num )
+        virtual long long skip( long long num )
             throw ( io::IOException,
                     lang::exceptions::UnsupportedOperationException );
 
@@ -75,8 +74,7 @@ namespace net{
 
         virtual int doReadByte() throw ( io::IOException );
 
-        virtual int doReadArrayBounded( unsigned char* buffer, std::size_t size,
-                                        std::size_t offset, std::size_t length )
+        virtual int doReadArrayBounded( unsigned char* buffer, int size, int offset, int length )
             throw ( decaf::io::IOException,
                     decaf::lang::exceptions::IndexOutOfBoundsException,
                     decaf::lang::exceptions::NullPointerException );

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/SocketOutputStream.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/SocketOutputStream.cpp?rev=925692&r1=925691&r2=925692&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/SocketOutputStream.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/SocketOutputStream.cpp Sat Mar 20 21:57:20 2010
@@ -61,8 +61,7 @@ void SocketOutputStream::doWriteByte( un
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void SocketOutputStream::doWriteArrayBounded( const unsigned char* buffer, std::size_t size,
-                                              std::size_t offset, std::size_t length )
+void SocketOutputStream::doWriteArrayBounded( const unsigned char* buffer, int size, int offset, int length )
     throw ( decaf::io::IOException,
             decaf::lang::exceptions::NullPointerException,
             decaf::lang::exceptions::IndexOutOfBoundsException ) {
@@ -85,10 +84,19 @@ void SocketOutputStream::doWriteArrayBou
                 "SocketOutputStream::write - This Stream has been closed." );
         }
 
-        if( ( offset + length ) > size ) {
-            throw decaf::lang::exceptions::IndexOutOfBoundsException(
-                __FILE__, __LINE__,
-                "SocketOutputStream::write - given offset + length is greater than buffer size.");
+        if( size < 0 ) {
+            throw IndexOutOfBoundsException(
+                __FILE__, __LINE__, "size parameter out of Bounds: %d.", size );
+        }
+
+        if( offset > size || offset < 0 ) {
+            throw IndexOutOfBoundsException(
+                __FILE__, __LINE__, "offset parameter out of Bounds: %d.", offset );
+        }
+
+        if( length < 0 || length > size - offset ) {
+            throw IndexOutOfBoundsException(
+                __FILE__, __LINE__, "length parameter out of Bounds: %d.", length );
         }
 
         apr_size_t remaining = (apr_size_t)length;

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/SocketOutputStream.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/SocketOutputStream.h?rev=925692&r1=925691&r2=925692&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/SocketOutputStream.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/SocketOutputStream.h Sat Mar 20 21:57:20 2010
@@ -53,8 +53,7 @@ namespace net{
 
         virtual void doWriteByte( unsigned char c ) throw ( decaf::io::IOException );
 
-        virtual void doWriteArrayBounded( const unsigned char* buffer, std::size_t size,
-                                          std::size_t offset, std::size_t length )
+        virtual void doWriteArrayBounded( const unsigned char* buffer, int size, int offset, int length )
             throw ( decaf::io::IOException,
                     decaf::lang::exceptions::NullPointerException,
                     decaf::lang::exceptions::IndexOutOfBoundsException );

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/nio/Buffer.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/nio/Buffer.cpp?rev=925692&r1=925691&r2=925692&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/nio/Buffer.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/nio/Buffer.cpp Sat Mar 20 21:57:20 2010
@@ -25,7 +25,7 @@ using namespace decaf::lang;
 using namespace decaf::lang::exceptions;
 
 ////////////////////////////////////////////////////////////////////////////////
-Buffer::Buffer( std::size_t capacity ) {
+Buffer::Buffer( int capacity ) {
     this->_capacity = capacity;
     this->_limit = capacity;
     this->_position = 0;
@@ -44,10 +44,10 @@ Buffer::Buffer( const Buffer& other ) {
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-Buffer& Buffer::position( std::size_t newPosition )
+Buffer& Buffer::position( int newPosition )
     throw( lang::exceptions::IllegalArgumentException ) {
 
-    if( newPosition > this->_limit ) {
+    if( newPosition < 0 || newPosition > this->_limit ) {
         throw IllegalArgumentException(
             __FILE__, __LINE__,
             "Buffer::position - New Position is greater than set limit" );
@@ -63,9 +63,9 @@ Buffer& Buffer::position( std::size_t ne
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-Buffer& Buffer::limit( std::size_t newLimit ) throw( IllegalArgumentException ) {
+Buffer& Buffer::limit( int newLimit ) throw( IllegalArgumentException ) {
 
-    if( newLimit > this->capacity() ) {
+    if( newLimit < 0 || newLimit > this->capacity() ) {
         throw IllegalArgumentException(
             __FILE__, __LINE__,
             "Buffer::limit - new limit is larger than the capacity." );

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/nio/Buffer.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/nio/Buffer.h?rev=925692&r1=925691&r2=925692&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/nio/Buffer.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/nio/Buffer.h Sat Mar 20 21:57:20 2010
@@ -125,15 +125,15 @@ namespace nio{
     class DECAF_API Buffer {
     protected:
 
-        mutable std::size_t _position;
-        std::size_t _capacity;
-        std::size_t _limit;
-        std::size_t _mark;
+        mutable int _position;
+        int _capacity;
+        int _limit;
+        int _mark;
         bool _markSet;
 
     public:
 
-        Buffer( std::size_t capactiy );
+        Buffer( int capactiy );
         Buffer( const Buffer& other );
         virtual ~Buffer() {}
 
@@ -142,31 +142,35 @@ namespace nio{
         /**
          * @returns this buffer's capacity.
          */
-        virtual std::size_t capacity() const {
+        virtual int capacity() const {
             return this->_capacity;
         }
 
         /**
          * @returns the current position in the buffer
          */
-        virtual std::size_t position() const {
+        virtual int position() const {
             return this->_position;
         }
 
         /**
          * Sets this buffer's position. If the mark is defined and larger than the
          * new position then it is discarded.
-         * @param newPosition - the new postion in the buffer to set.
-         * @returns A reference to This buffer
+         *
+         * @param newPosition
+         *      The new postion in the buffer to set.
+         *
+         * @returns a reference to This buffer.
+         *
          * @throws IllegalArgumentException if preconditions on the new pos don't hold.
          */
-        virtual Buffer& position( std::size_t newPosition )
+        virtual Buffer& position( int newPosition )
             throw( lang::exceptions::IllegalArgumentException );
 
         /**
          * @returns this buffers Limit
          */
-        virtual std::size_t limit() const {
+        virtual int limit() const {
             return this->_limit;
         }
 
@@ -174,23 +178,29 @@ namespace nio{
          * Sets this buffer's limit. If the position is larger than the new limit then
          * it is set to the new limit. If the mark is defined and larger than the new
          * limit then it is discarded.
-         * @param newLimit - The new limit value; must be no larger than this
-         * buffer's capacity
+         *
+         * @param newLimit
+         *      The new limit value; must be no larger than this buffer's capacity.
+         *
          * @returns A reference to This buffer
+         *
          * @throws IllegalArgumentException if preconditions on the new pos don't hold.
          */
-        virtual Buffer& limit( std::size_t newLimit )
+        virtual Buffer& limit( int newLimit )
             throw( lang::exceptions::IllegalArgumentException );
 
         /**
          * Sets this buffer's mark at its position.
+         *
          * @returns a reference to this buffer.
          */
         virtual Buffer& mark();
 
         /**
          * Resets this buffer's position to the previously-marked position.
+         *
          * @returns a reference to this buffer.
+         *
          * @throws InvalidMarkException - If the mark has not been set
          */
         virtual Buffer& reset() throw( InvalidMarkException );
@@ -198,7 +208,7 @@ namespace nio{
         /**
          * Clears this buffer. The position is set to zero, the limit is set to the
          * capacity, and the mark is discarded.
-         * <p>
+         *
          * Invoke this method before using a sequence of channel-read or put operations
          * to fill this buffer. For example:
          *
@@ -208,6 +218,7 @@ namespace nio{
          * This method does not actually erase the data in the buffer, but it is named
          * as if it did because it will most often be used in situations in which that
          * might as well be the case.
+         *
          * @returns a reference to this buffer.
          */
         virtual Buffer& clear();
@@ -215,7 +226,7 @@ namespace nio{
         /**
          * Flips this buffer. The limit is set to the current position and then the
          * position is set to zero. If the mark is defined then it is discarded.
-         * <p>
+         *
          * After a sequence of channel-read or put operations, invoke this method to
          * prepare for a sequence of channel-write or relative get operations. For
          * example:
@@ -227,13 +238,14 @@ namespace nio{
          *
          * This method is often used in conjunction with the compact method when
          * transferring data from one place to another.
+         *
          * @returns a reference to this buffer.
          */
         virtual Buffer& flip();
 
         /**
          * Rewinds this buffer. The position is set to zero and the mark is discarded.
-         * <p>
+         *
          * Invoke this method before a sequence of channel-write or get operations,
          * assuming that the limit has already been set appropriately. For example:
          *
@@ -247,16 +259,18 @@ namespace nio{
 
         /**
          * Returns the number of elements between the current position and the limit.
+         *
          * @returns The number of elements remaining in this buffer
          */
-        virtual std::size_t remaining() const {
+        virtual int remaining() const {
             return _limit - _position;
         }
 
         /**
          * Tells whether there are any elements between the current position and the limit.
+         *
          * @returns true if, and only if, there is at least one element remaining in
-         * this buffer
+         *          this buffer.
          */
         virtual bool hasRemaining() const {
             return remaining() != 0;
@@ -264,7 +278,8 @@ namespace nio{
 
         /**
          * Tells whether or not this buffer is read-only.
-         * @returns true if, and only if, this buffer is read-only
+         *
+         * @returns true if, and only if, this buffer is read-only.
          */
         virtual bool isReadOnly() const = 0;
 

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/nio/ByteBuffer.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/nio/ByteBuffer.cpp?rev=925692&r1=925691&r2=925692&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/nio/ByteBuffer.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/nio/ByteBuffer.cpp Sat Mar 20 21:57:20 2010
@@ -31,23 +31,25 @@ using namespace decaf::lang;
 using namespace decaf::lang::exceptions;
 
 ////////////////////////////////////////////////////////////////////////////////
-ByteBuffer::ByteBuffer( std::size_t capacity ) : Buffer( capacity ) {
+ByteBuffer::ByteBuffer( int capacity )
+    throw( decaf::lang::exceptions::IllegalArgumentException ) : Buffer( capacity ) {
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-ByteBuffer* ByteBuffer::allocate( std::size_t capacity ) {
+ByteBuffer* ByteBuffer::allocate( int capacity )
+    throw( decaf::lang::exceptions::IllegalArgumentException ) {
 
     try{
-
         return BufferFactory::createByteBuffer( capacity );
     }
-    DECAF_CATCH_RETHROW( Exception )
-    DECAF_CATCHALL_THROW( Exception )
+    DECAF_CATCH_RETHROW( IllegalArgumentException )
+    DECAF_CATCHALL_THROW( IllegalArgumentException )
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-ByteBuffer* ByteBuffer::wrap( unsigned char* buffer, std::size_t offset, std::size_t length )
-    throw( lang::exceptions::NullPointerException ) {
+ByteBuffer* ByteBuffer::wrap( unsigned char* buffer, int size, int offset, int length )
+    throw( decaf::lang::exceptions::NullPointerException,
+           decaf::lang::exceptions::IndexOutOfBoundsException ) {
 
     try{
 
@@ -57,9 +59,15 @@ ByteBuffer* ByteBuffer::wrap( unsigned c
                 "ByteBuffer::wrap - Passed Buffer is Null.");
         }
 
-        return BufferFactory::createByteBuffer( buffer, offset, length );
+        if( size < 0 || offset < 0 || length < 0 || offset + length > size ) {
+            throw IndexOutOfBoundsException(
+                __FILE__, __LINE__, "Invalid array access parameters passed." );
+        }
+
+        return BufferFactory::createByteBuffer( buffer, size, offset, length );
     }
     DECAF_CATCH_RETHROW( NullPointerException )
+    DECAF_CATCH_RETHROW( IndexOutOfBoundsException )
     DECAF_CATCH_EXCEPTION_CONVERT( Exception, NullPointerException )
     DECAF_CATCHALL_THROW( NullPointerException )
 }
@@ -75,7 +83,7 @@ ByteBuffer* ByteBuffer::wrap( std::vecto
                 "ByteBuffer::wrap - Passed Buffer is Empty.");
         }
 
-        return BufferFactory::createByteBuffer( &buffer[0], 0, buffer.size() );
+        return BufferFactory::createByteBuffer( &buffer[0], (int)buffer.size(), 0, (int)buffer.size() );
     }
     DECAF_CATCH_RETHROW( NullPointerException )
     DECAF_CATCH_EXCEPTION_CONVERT( Exception, NullPointerException )
@@ -89,7 +97,7 @@ ByteBuffer& ByteBuffer::get( std::vector
     try{
 
         if( !buffer.empty() ) {
-            this->get( &buffer[0], 0, buffer.size() );
+            this->get( &buffer[0], (int)buffer.size(), 0, (int)buffer.size() );
         }
 
         return *this;
@@ -100,10 +108,8 @@ ByteBuffer& ByteBuffer::get( std::vector
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-ByteBuffer& ByteBuffer::get( unsigned char* buffer,
-                             std::size_t offset,
-                             std::size_t length )
-    throw( BufferUnderflowException, NullPointerException ) {
+ByteBuffer& ByteBuffer::get( unsigned char* buffer, int size, int offset, int length )
+    throw( BufferUnderflowException, NullPointerException, IndexOutOfBoundsException ) {
 
     try{
 
@@ -117,6 +123,11 @@ ByteBuffer& ByteBuffer::get( unsigned ch
                 "ByteBuffer::get - Passed Buffer is Null.");
         }
 
+        if( size < 0 || offset < 0 || length < 0 || offset + length > size ) {
+            throw IndexOutOfBoundsException(
+                 __FILE__, __LINE__, "Arguments violate array bounds." );
+        }
+
         if( length > this->remaining() ) {
             throw BufferUnderflowException(
                 __FILE__, __LINE__,
@@ -124,7 +135,7 @@ ByteBuffer& ByteBuffer::get( unsigned ch
         }
 
         // read length bytes starting from the offset
-        for( std::size_t ix = 0; ix < length; ++ix ) {
+        for( int ix = 0; ix < length; ++ix ) {
             buffer[ix + offset] = this->get();
         }
 
@@ -132,6 +143,7 @@ ByteBuffer& ByteBuffer::get( unsigned ch
     }
     DECAF_CATCH_RETHROW( BufferUnderflowException )
     DECAF_CATCH_RETHROW( NullPointerException )
+    DECAF_CATCH_RETHROW( IndexOutOfBoundsException )
     DECAF_CATCH_EXCEPTION_CONVERT( Exception, BufferUnderflowException )
     DECAF_CATCHALL_THROW( BufferUnderflowException )
 }
@@ -174,10 +186,8 @@ ByteBuffer& ByteBuffer::put( ByteBuffer&
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-ByteBuffer& ByteBuffer::put( const unsigned char* buffer,
-                             std::size_t offset,
-                             std::size_t length )
-    throw( BufferOverflowException, ReadOnlyBufferException, NullPointerException ) {
+ByteBuffer& ByteBuffer::put( const unsigned char* buffer, int size, int offset, int length )
+    throw( BufferOverflowException, ReadOnlyBufferException, NullPointerException, IndexOutOfBoundsException ) {
 
     try{
 
@@ -197,6 +207,11 @@ ByteBuffer& ByteBuffer::put( const unsig
                 "ByteBuffer::put - Passed Buffer is Null.");
         }
 
+        if( size < 0 || offset < 0 || length < 0 || offset + length > size ) {
+            throw IndexOutOfBoundsException(
+                 __FILE__, __LINE__, "Arguments violate array bounds." );
+        }
+
         if( length > this->remaining() ) {
             throw BufferOverflowException(
                 __FILE__, __LINE__,
@@ -204,7 +219,7 @@ ByteBuffer& ByteBuffer::put( const unsig
         }
 
         // read length bytes starting from the offset
-        for( std::size_t ix = 0; ix < length; ++ix ) {
+        for( int ix = 0; ix < length; ++ix ) {
             this->put( buffer[ix + offset] );
         }
 
@@ -224,7 +239,7 @@ ByteBuffer& ByteBuffer::put( std::vector
     try{
 
         if( !buffer.empty() ) {
-            this->put( &buffer[0], 0, buffer.size() );
+            this->put( &buffer[0], (int)buffer.size(), 0, (int)buffer.size() );
         }
 
         return *this;
@@ -240,12 +255,12 @@ int ByteBuffer::compareTo( const ByteBuf
 
     try{
 
-        std::size_t compareRemaining =
+        int compareRemaining =
             ( remaining() < value.remaining() ) ?
                 remaining() : value.remaining();
 
-        std::size_t thisPos = this->position();
-        std::size_t otherPos = value.position();
+        int thisPos = this->position();
+        int otherPos = value.position();
 
         unsigned char thisByte, otherByte = 0;
 
@@ -277,8 +292,8 @@ bool ByteBuffer::equals( const ByteBuffe
             return false;
         }
 
-        std::size_t myPosition = this->position();
-        std::size_t otherPosition = value.position();
+        int myPosition = this->position();
+        int otherPosition = value.position();
 
         while( myPosition < this->limit() ) {
             if( get( myPosition++ ) != value.get( otherPosition++ ) ) {