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 [10/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/ni...

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/nio/FloatBuffer.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/nio/FloatBuffer.h?rev=925692&r1=925691&r2=925692&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/nio/FloatBuffer.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/nio/FloatBuffer.h Sat Mar 20 21:57:20 2010
@@ -55,9 +55,14 @@ namespace nio{
         * Creates a FloatBuffer object that has its backing array allocated internally
         * and is then owned and deleted when this object is deleted.  The array is
         * initially created with all elements initialized to zero.
-        * @param capacity - size and limit of the Buffer in doubles
+        *
+        * @param capacity
+        *       The size and limit of the Buffer in floats.
+        *
+         * @throws IllegalArguementException if capacity is negative.
         */
-        FloatBuffer( std::size_t capacity );
+        FloatBuffer( int capacity )
+            throw( decaf::lang::exceptions::IllegalArgumentException );
 
     public:
 
@@ -70,13 +75,15 @@ namespace nio{
 
         /**
          * Returns the float array that backs this buffer  (optional operation).
-         * <p>
+         *
          * Modifications to this buffer's content will cause the returned array's content
          * to be modified, and vice versa.
-         * <p>
+         *
          * Invoke the hasArray method before invoking this method in order to ensure that
          * this buffer has an accessible backing array.
-         * @returns the array that backs this Buffer
+         *
+         * @returns the array that backs this Buffer.
+         *
          * @throws ReadOnlyBufferException if this Buffer is read only.
          * @throws UnsupportedOperationException if the underlying store has no array.
          */
@@ -87,63 +94,69 @@ namespace nio{
         /**
          * Returns the offset within this buffer's backing array of the first element of
          * the buffer  (optional operation).
-         * <p>
+         *
          * Invoke the hasArray method before invoking this method in order to ensure that
          * this buffer has an accessible backing array.
+         *
          * @returns The offset into the backing array where index zero starts.
+         *
          * @throws ReadOnlyBufferException if this Buffer is read only.
          * @throws UnsupportedOperationException if the underlying store has no array.
          */
-        virtual std::size_t arrayOffset()
+        virtual int arrayOffset()
             throw( decaf::lang::exceptions::UnsupportedOperationException,
                    ReadOnlyBufferException ) = 0;
 
         /**
          * Creates a new, read-only float buffer that shares this buffer's content.
-         * <p>
+         *
          * The content of the new buffer will be that of this buffer. Changes to this
          * buffer's content will be visible in the new buffer; the new buffer itself,
          * however, will be read-only and will not allow the shared content to be
          * modified. The two buffers' position, limit, and mark values will be
          * independent.
-         * <p>
+         *
          * If this buffer is itself read-only then this method behaves in exactly the
          * same way as the duplicate method.
-         * <p>
+         *
          * The new buffer's capacity, limit, position, and mark values will be
          * identical to those of this buffer.
+         *
          * @return The new, read-only float buffer which the caller then owns.
          */
         virtual FloatBuffer* asReadOnlyBuffer() const = 0;
 
         /**
          * Compacts this buffer
-         * <p>
+         *
          * The bytes between the buffer's current position and its limit, if any, are
          * copied to the beginning of the buffer. That is, the byte at index
          * p = position() is copied to index zero, the byte at index p + 1 is copied
          * to index one, and so forth until the byte at index limit() - 1 is copied
          * to index n = limit() - 1 - p. The buffer's position is then set to n+1 and
          * its limit is set to its capacity. The mark, if defined, is discarded.
-         * <p>
+         *
          * The buffer's position is set to the number of bytes copied, rather than to
          * zero, so that an invocation of this method can be followed immediately by
          * an invocation of another relative put method.
-         * @returns a reference to this FloatBuffer
-         * @throws ReadOnlyBufferException - If this buffer is read-only
+         *
+         * @returns a reference to this FloatBuffer.
+         *
+         * @throws ReadOnlyBufferException if this buffer is read-only
          */
         virtual FloatBuffer& compact() throw( ReadOnlyBufferException ) = 0;
 
         /**
          * Creates a new float buffer that shares this buffer's content.
-         * <p>
+         *
          * The content of the new buffer will be that of this buffer. Changes to this
          * buffer's content will be visible in the new buffer, and vice versa; the two
          * buffers' position, limit, and mark values will be independent.
-         * <p>
+         *
          * The new buffer's capacity, limit, position, and mark values will be identical
          * to those of this buffer. The new buffer will be read-only if, and only if,
          * this buffer is read-only.
+         *
          * @returns a new float Buffer which the caller owns.
          */
         virtual FloatBuffer* duplicate() = 0;
@@ -151,67 +164,86 @@ namespace nio{
         /**
          * Relative get method. Reads the value at this buffer's current position,
          * and then increments the position.
-         * @returns the float at the current position
-         * @throws BufferUnderflowException if there no more data to return
+         *
+         * @returns the float at the current position.
+         *
+         * @throws BufferUnderflowException if there no more data to return.
          */
         virtual float get() throw ( BufferUnderflowException ) = 0;
 
         /**
          * Absolute get method. Reads the value at the given index.
-         * @param index - the index in the Buffer where the float is to be read
+         *
+         * @param index
+         *      The index in the Buffer where the float is to be read
+         *
          * @returns the float that is located at the given index
-         * @throws IndexOutOfBoundsException - If index is not smaller than the
-         * buffer's limit
+         *
+         * @throws IndexOutOfBoundsException if index is not smaller than the
+         *         buffer's limit
          */
-        virtual float get( std::size_t index ) const
-            throw ( lang::exceptions::IndexOutOfBoundsException ) = 0;
+        virtual float get( int index ) const
+            throw ( decaf::lang::exceptions::IndexOutOfBoundsException ) = 0;
 
         /**
          * Relative bulk get method.
-         * <p>
+         *
          * This method transfers values from this buffer into the given destination
          * vector. An invocation of this method of the form src.get(a) behaves in
          * exactly the same way as the invocation.  The vector must be sized to the
          * amount of data that is to be read, that is to say, the caller should call
          * buffer.resize( N ) before calling this get method.
-         * @returns a reference to this Buffer
-         * @throws BufferUnderflowException - If there are fewer than length floats
-         * remaining in this buffer
+         *
+         * @returns a reference to this Buffer.
+         *
+         * @throws BufferUnderflowException if there are fewer than length floats
+         *         remaining in this buffer
          */
         FloatBuffer& get( std::vector<float> buffer )
             throw ( BufferUnderflowException );
 
         /**
          * Relative bulk get method.
-         * <p>
+         *
          * This method transfers floats from this buffer into the given destination array.
          * If there are fewer floats remaining in the buffer than are required to satisfy
          * the request, that is, if length > remaining(), then no bytes are transferred
          * and a BufferUnderflowException is thrown.
-         * <p>
+         *
          * Otherwise, this method copies length floats from this buffer into the given
          * array, starting at the current position of this buffer and at the given offset
          * in the array. The position of this buffer is then incremented by length.
-         * <p>
-         * @param buffer - pointer to an allocated buffer to fill
-         * @param offset - position in the buffer to start filling
-         * @param length - amount of data to put in the passed buffer
-         * @returns a reference to this Buffer
-         * @throws BufferUnderflowException - If there are fewer than length floats
-         * remaining in this buffer
+         *
+         * @param buffer
+         *      The pointer to an allocated buffer to fill.
+         * @param size
+         *      The size of the passed in buffer.
+         * @param offset
+         *      The position in the buffer to start filling.
+         * @param length
+         *      The amount of data to put in the passed buffer.
+         *
+         * @returns a reference to this Buffer.
+         *
+         * @throws BufferUnderflowException if there are fewer than length floats
+         *         remaining in this buffer
          * @throws NullPointerException if the passed buffer is null.
+         * @throws IndexOutOfBoundsException if the preconditions of size, offset, or length
+         *         are not met.
          */
-        FloatBuffer& get( float* buffer, std::size_t offset, std::size_t length )
+        FloatBuffer& get( float* buffer, int size, int offset, int length )
             throw( BufferUnderflowException,
-                   lang::exceptions::NullPointerException );
+                   decaf::lang::exceptions::IndexOutOfBoundsException,
+                   decaf::lang::exceptions::NullPointerException );
 
         /**
          * Tells whether or not this buffer is backed by an accessible float array.
          * If this method returns true then the array and arrayOffset methods may safely
          * be invoked.  Subclasses should override this method if they do not have a
          * backing array as this class always returns true.
+         *
          * @returns true if, and only if, this buffer is backed by an array and is not
-         * read-only
+         *          read-only
          */
         virtual bool hasArray() const = 0;
 
@@ -220,49 +252,68 @@ namespace nio{
          * this buffer. If there are more floats remaining in the source buffer than in
          * this buffer, that is, if src.remaining() > remaining(), then no floats are
          * transferred and a BufferOverflowException is thrown.
-         * <p>
+         *
          * Otherwise, this method copies n = src.remaining() floats from the given
          * buffer into this buffer, starting at each buffer's current position. The
          * positions of both buffers are then incremented by n.
-         * @param src - the buffer to take floats from an place in this one.
-         * @returns a reference to this buffer
-         * @throws BufferOverflowException - If there is insufficient space in this
-         * buffer for the remaining floats in the source buffer
-         * @throws IllegalArgumentException - If the source buffer is this buffer
-         * @throws ReadOnlyBufferException - If this buffer is read-only
+         *
+         * @param src
+         *      The buffer to take floats from an place in this one.
+         *
+         * @returns a reference to this buffer.
+         *
+         * @throws BufferOverflowException if there is insufficient space in this
+         *         buffer for the remaining floats in the source buffer
+         * @throws IllegalArgumentException if the source buffer is this buffer.
+         * @throws ReadOnlyBufferException if this buffer is read-only.
          */
         FloatBuffer& put( FloatBuffer& src )
             throw( BufferOverflowException, ReadOnlyBufferException,
-                   lang::exceptions::IllegalArgumentException );
+                   decaf::lang::exceptions::IllegalArgumentException );
 
         /**
          * This method transfers floats into this buffer from the given source array.
          * If there are more floats to be copied from the array than remain in this buffer,
          * that is, if length > remaining(), then no floats are transferred and a
          * BufferOverflowException is thrown.
-         * <p>
+         *
          * Otherwise, this method copies length bytes from the given array into this
          * buffer, starting at the given offset in the array and at the current position
          * of this buffer. The position of this buffer is then incremented by length.
-         * @param buffer- The array from which floats are to be read
-         * @param offset- The offset within the array of the first float to be read;
-         * @param length - The number of floats to be read from the given array
-         * @returns a reference to this buffer
-         * @throws BufferOverflowException - If there is insufficient space in this buffer
-         * @throws ReadOnlyBufferException - If this buffer is read-only
+         *
+         * @param buffer
+         *      The array from which floats are to be read.
+         * @param size
+         *      The size of the passed in buffer.
+         * @param offset
+         *      The offset within the array of the first float to be read.
+         * @param length
+         *      The number of floats to be read from the given array.
+         *
+         * @returns a reference to this buffer.
+         *
+         * @throws BufferOverflowException if there is insufficient space in this buffer
+         * @throws ReadOnlyBufferException if this buffer is read-only
          * @throws NullPointerException if the passed buffer is null.
+         * @throws IndexOutOfBoundsException if the preconditions of size, offset, or length
+         *         are not met.
          */
-        FloatBuffer& put( const float* buffer, std::size_t offset, std::size_t length )
+        FloatBuffer& put( const float* buffer, int size, int offset, int length )
             throw( BufferOverflowException, ReadOnlyBufferException,
-                   lang::exceptions::NullPointerException );
+                   decaf::lang::exceptions::IndexOutOfBoundsException,
+                   decaf::lang::exceptions::NullPointerException );
 
         /**
          * This method transfers the entire content of the given source floats array into
-         * this buffer.  This is the same as calling put( &buffer[0], 0, buffer.size()
-         * @param buffer - The buffer whose contents are copied to this FloatBuffer
-         * @returns a reference to this buffer
-         * @throws BufferOverflowException - If there is insufficient space in this buffer
-         * @throws ReadOnlyBufferException - If this buffer is read-only
+         * this buffer.  This is the same as calling put( &buffer[0], 0, buffer.size().
+         *
+         * @param buffer
+         *      The buffer whose contents are copied to this FloatBuffer
+         *
+         * @returns a reference to this buffer.
+         *
+         * @throws BufferOverflowException if there is insufficient space in this buffer
+         * @throws ReadOnlyBufferException if this buffer is read-only
          */
         FloatBuffer& put( std::vector<float>& buffer )
             throw( BufferOverflowException, ReadOnlyBufferException );
@@ -270,26 +321,35 @@ namespace nio{
         /**
          * Writes the given floats into this buffer at the current position, and then
          * increments the position.
-         * @param value - the floats value to be written
-         * @returns a reference to this buffer
-         * @throws BufferOverflowException - If this buffer's current position is not
-         * smaller than its limit
-         * @throws ReadOnlyBufferException - If this buffer is read-only
+         *
+         * @param value
+         *      The floats value to be written.
+         *
+         * @returns a reference to this buffer.
+         *
+         * @throws BufferOverflowException if this buffer's current position is not
+         *         smaller than its limit
+         * @throws ReadOnlyBufferException if this buffer is read-only
          */
         virtual FloatBuffer& put( float value )
             throw( BufferOverflowException, ReadOnlyBufferException ) = 0;
 
         /**
          * Writes the given floats into this buffer at the given index.
-         * @param index - position in the Buffer to write the data
-         * @param value - the floats to write.
-         * @returns a reference to this buffer
-         * @throws IndexOutOfBoundsException - If index greater than the buffer's limit
-         * minus the size of the type being written.
-         * @throws ReadOnlyBufferException - If this buffer is read-only
+         *
+         * @param index
+         *      The position in the Buffer to write the data.
+         * @param value
+         *      The floats to write.
+         *
+         * @returns a reference to this buffer.
+         *
+         * @throws IndexOutOfBoundsException if index greater than the buffer's limit
+         *         minus the size of the type being written, or index is negative.
+         * @throws ReadOnlyBufferException if this buffer is read-only.
          */
-        virtual FloatBuffer& put( std::size_t index, float value )
-            throw( lang::exceptions::IndexOutOfBoundsException,
+        virtual FloatBuffer& put( int index, float value )
+            throw( decaf::lang::exceptions::IndexOutOfBoundsException,
                    ReadOnlyBufferException ) = 0;
 
         /**
@@ -298,10 +358,11 @@ namespace nio{
          * current position. Changes to this buffer's content will be visible in the new
          * buffer, and vice versa; the two buffers' position, limit, and mark values will
          * be independent.
-         * <p>
+         *
          * The new buffer's position will be zero, its capacity and its limit will be the
          * number of bytes remaining in this buffer, and its mark will be undefined. The
          * new buffer will be read-only if, and only if, this buffer is read-only.
+         *
          * @returns the newly create FloatBuffer which the caller owns.
          */
         virtual FloatBuffer* slice() const = 0;
@@ -309,32 +370,22 @@ namespace nio{
     public:  // Comparable
 
         /**
-         * Compares this object with the specified object for order. Returns a
-         * negative integer, zero, or a positive integer as this object is less
-         * than, equal to, or greater than the specified object.
-         * @param value - the Object to be compared.
-         * @returns a negative integer, zero, or a positive integer as this
-         * object is less than, equal to, or greater than the specified object.
+         * {@inheritDoc}
          */
         virtual int compareTo( const FloatBuffer& value ) const;
 
         /**
-         * @return true if this value is considered equal to the passed value.
+         * {@inheritDoc}
          */
         virtual bool equals( const FloatBuffer& value ) const;
 
         /**
-         * Compares equality between this object and the one passed.
-         * @param value - the value to be compared to this one.
-         * @return true if this object is equal to the one passed.
+         * {@inheritDoc}
          */
         virtual bool operator==( const FloatBuffer& value ) const;
 
         /**
-         * Compares this object to another and returns true if this object
-         * is considered to be less than the one passed.  This
-         * @param value - the value to be compared to this one.
-         * @return true if this object is equal to the one passed.
+         * {@inheritDoc}
          */
         virtual bool operator<( const FloatBuffer& value ) const;
 
@@ -342,34 +393,50 @@ namespace nio{
 
         /**
          * Allocates a new Double buffer.
-         * <p>
+         *
          * The new buffer's position will be zero, its limit will be its capacity, and
          * its mark will be undefined. It will have a backing array, and its array offset
          * will be zero.
-         * @param capacity - The size of the Double buffer in floats
+         *
+         * @param capacity
+         *      The size of the Double buffer in floats.
+         *
          * @returns the FloatBuffer that was allocated, caller owns.
          */
-        static FloatBuffer* allocate( std::size_t capacity );
+        static FloatBuffer* allocate( int capacity )
+            throw( decaf::lang::exceptions::IllegalArgumentException );
 
         /**
          * Wraps the passed buffer with a new FloatBuffer.
-         * <p>
+         *
          * The new buffer will be backed by the given float array; that is, modifications
          * to the buffer will cause the array to be modified and vice versa. The new
          * buffer's capacity will be array.length, its position will be offset, its limit
          * will be offset + length, and its mark will be undefined. Its backing array
          * will be the given array, and its array offset will be zero.
-         * @param array - The array that will back the new buffer
-         * @param offset - The offset of the subarray to be used
-         * @param length - The length of the subarray to be used
+         *
+         * @param array
+         *      The array that will back the new buffer.
+         * @param size
+         *      The size of the array that was passed in.
+         * @param offset
+         *      The offset of the subarray to be used.
+         * @param length
+         *      The length of the subarray to be used.
+         *
          * @returns a new FloatBuffer that is backed by buffer, caller owns.
-         */
-        static FloatBuffer* wrap( float* array, std::size_t offset, std::size_t length )
-            throw( lang::exceptions::NullPointerException );
+         *
+         * @throws NullPointerException if the array pointer is NULL.
+         * @throws IndexOutOfBoundsException if the preconditions of size, offset, or length
+         *         are not met.
+         */
+        static FloatBuffer* wrap( float* array, int size, int offset, int length )
+            throw( decaf::lang::exceptions::NullPointerException,
+                   decaf::lang::exceptions::IndexOutOfBoundsException );
 
         /**
          * Wraps the passed STL float Vector in a FloatBuffer.
-         * <p>
+         *
          * The new buffer will be backed by the given float array; modifications to the
          * buffer will cause the array to be modified and vice versa. The new buffer's
          * capacity and limit will be buffer.size(), its position will be zero, and its

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/nio/IntBuffer.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/nio/IntBuffer.cpp?rev=925692&r1=925691&r2=925692&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/nio/IntBuffer.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/nio/IntBuffer.cpp Sat Mar 20 21:57:20 2010
@@ -29,16 +29,16 @@ using namespace decaf::lang::exceptions;
 using namespace decaf::internal::nio;
 
 ////////////////////////////////////////////////////////////////////////////////
-IntBuffer::IntBuffer( std::size_t capacity )
- :  Buffer( capacity ) {
+IntBuffer::IntBuffer( int capacity )
+    throw( decaf::lang::exceptions::IllegalArgumentException ) : Buffer( capacity ) {
 
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-IntBuffer* IntBuffer::allocate( std::size_t capacity ) {
+IntBuffer* IntBuffer::allocate( int capacity )
+    throw( decaf::lang::exceptions::IllegalArgumentException ) {
 
     try{
-
         return BufferFactory::createIntBuffer( capacity );
     }
     DECAF_CATCH_RETHROW( Exception )
@@ -46,8 +46,9 @@ IntBuffer* IntBuffer::allocate( std::siz
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-IntBuffer* IntBuffer::wrap( int* buffer, std::size_t offset, std::size_t length )
-    throw( lang::exceptions::NullPointerException ) {
+IntBuffer* IntBuffer::wrap( int* buffer, int size, int offset, int length )
+    throw( decaf::lang::exceptions::IndexOutOfBoundsException,
+           decaf::lang::exceptions::NullPointerException ) {
 
     try{
 
@@ -57,7 +58,7 @@ IntBuffer* IntBuffer::wrap( int* buffer,
                 "IntBuffer::wrap - Passed Buffer is Null.");
         }
 
-        return BufferFactory::createIntBuffer( buffer, offset, length );
+        return BufferFactory::createIntBuffer( buffer, size, offset, length );
     }
     DECAF_CATCH_RETHROW( NullPointerException )
     DECAF_CATCH_EXCEPTION_CONVERT( Exception, NullPointerException )
@@ -75,7 +76,7 @@ IntBuffer* IntBuffer::wrap( std::vector<
                 "IntBuffer::wrap - Passed Buffer is Empty.");
         }
 
-        return BufferFactory::createIntBuffer( &buffer[0], 0, buffer.size() );
+        return BufferFactory::createIntBuffer( &buffer[0], (int)buffer.size(), 0, (int)buffer.size() );
     }
     DECAF_CATCH_RETHROW( NullPointerException )
     DECAF_CATCH_EXCEPTION_CONVERT( Exception, NullPointerException )
@@ -102,7 +103,7 @@ IntBuffer& IntBuffer::get( std::vector<i
     try{
 
         if( !buffer.empty() ) {
-            this->get( &buffer[0], 0, buffer.size() );
+            this->get( &buffer[0], (int)buffer.size(), 0, (int)buffer.size() );
         }
         return *this;
     }
@@ -112,9 +113,10 @@ IntBuffer& IntBuffer::get( std::vector<i
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-IntBuffer& IntBuffer::get( int* buffer, std::size_t offset, std::size_t length )
+IntBuffer& IntBuffer::get( int* buffer, int size, int offset, int length )
     throw( BufferUnderflowException,
-           lang::exceptions::NullPointerException ) {
+           decaf::lang::exceptions::IndexOutOfBoundsException,
+           decaf::lang::exceptions::NullPointerException ) {
 
     try{
 
@@ -128,19 +130,26 @@ IntBuffer& IntBuffer::get( int* buffer, 
                 "IntBuffer::get - Passed Buffer is Null" );
         }
 
+        if( size < 0 || offset < 0 || length < 0 || (long long)offset + (long long)length > (long long)size ) {
+            throw IndexOutOfBoundsException(
+                 __FILE__, __LINE__, "Arguments violate array bounds." );
+        }
+
         if( length > remaining() ) {
             throw BufferUnderflowException(
                 __FILE__, __LINE__,
                 "IntBuffer::get - Not enough data to fill length = %d", length );
         }
 
-        for( std::size_t ix = 0; ix < length; ++ix ){
+        for( int ix = 0; ix < length; ++ix ){
             buffer[offset + ix] = this->get();
         }
 
         return *this;
     }
     DECAF_CATCH_RETHROW( BufferUnderflowException )
+    DECAF_CATCH_RETHROW( IndexOutOfBoundsException )
+    DECAF_CATCH_RETHROW( NullPointerException )
     DECAF_CATCH_EXCEPTION_CONVERT( Exception, BufferUnderflowException )
     DECAF_CATCHALL_THROW( BufferUnderflowException )
 }
@@ -184,9 +193,10 @@ IntBuffer& IntBuffer::put( IntBuffer& sr
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-IntBuffer& IntBuffer::put( const int* buffer, std::size_t offset, std::size_t length )
+IntBuffer& IntBuffer::put( const int* buffer, int size, int offset, int length )
     throw( BufferOverflowException, ReadOnlyBufferException,
-           lang::exceptions::NullPointerException ) {
+           decaf::lang::exceptions::IndexOutOfBoundsException,
+           decaf::lang::exceptions::NullPointerException ) {
 
     try{
 
@@ -206,6 +216,11 @@ IntBuffer& IntBuffer::put( const int* bu
                 "IntBuffer::put - Passed Buffer is Null.");
         }
 
+        if( size < 0 || offset < 0 || length < 0 || (long long)offset + (long long)length > (long long)size ) {
+            throw IndexOutOfBoundsException(
+                 __FILE__, __LINE__, "Arguments violate array bounds." );
+        }
+
         if( length > this->remaining() ) {
             throw BufferOverflowException(
                 __FILE__, __LINE__,
@@ -213,7 +228,7 @@ IntBuffer& IntBuffer::put( const int* bu
         }
 
         // 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] );
         }
 
@@ -222,6 +237,7 @@ IntBuffer& IntBuffer::put( const int* bu
     DECAF_CATCH_RETHROW( BufferOverflowException )
     DECAF_CATCH_RETHROW( ReadOnlyBufferException )
     DECAF_CATCH_RETHROW( NullPointerException )
+    DECAF_CATCH_RETHROW( IndexOutOfBoundsException )
     DECAF_CATCH_EXCEPTION_CONVERT( Exception, BufferOverflowException )
     DECAF_CATCHALL_THROW( BufferOverflowException )
 }
@@ -233,7 +249,7 @@ IntBuffer& IntBuffer::put( std::vector<i
     try{
 
         if( !buffer.empty() ) {
-            this->put( &buffer[0], 0, buffer.size() );
+            this->put( &buffer[0], (int)buffer.size(), 0, (int)buffer.size() );
         }
 
         return *this;
@@ -249,8 +265,8 @@ int IntBuffer::compareTo( const IntBuffe
 
     int compareRemaining = Math::min( (int)remaining(), (int)value.remaining() );
 
-    std::size_t thisPos = this->position();
-    std::size_t otherPos = value.position();
+    int thisPos = this->position();
+    int otherPos = value.position();
     int thisVal, otherVal;
 
     while( compareRemaining > 0 ) {
@@ -281,8 +297,8 @@ bool IntBuffer::equals( const IntBuffer&
         return false;
     }
 
-    std::size_t myPosition = this->position();
-    std::size_t otherPosition = value.position();
+    int myPosition = this->position();
+    int otherPosition = value.position();
     bool equalSoFar = true;
 
     while( equalSoFar && ( myPosition < this->limit() ) ) {

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/nio/IntBuffer.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/nio/IntBuffer.h?rev=925692&r1=925691&r2=925692&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/nio/IntBuffer.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/nio/IntBuffer.h Sat Mar 20 21:57:20 2010
@@ -52,12 +52,17 @@ namespace nio{
     protected:
 
         /**
-        * Creates a IntBuffer object that has its backing array allocated internally
-        * and is then owned and deleted when this object is deleted.  The array is
-        * initially created with all elements initialized to zero.
-        * @param capacity - size and limit of the Buffer in doubles
-        */
-        IntBuffer( std::size_t capacity );
+         * Creates a IntBuffer object that has its backing array allocated internally
+         * and is then owned and deleted when this object is deleted.  The array is
+         * initially created with all elements initialized to zero.
+         *
+         * @param capacity
+         *       The size and limit of the Buffer in integers.
+         *
+         * @throws IllegalArguementException if capacity is negative.
+         */
+        IntBuffer( int capacity )
+            throw( decaf::lang::exceptions::IllegalArgumentException );
 
     public:
 
@@ -70,13 +75,15 @@ namespace nio{
 
         /**
          * Returns the int array that backs this buffer  (optional operation).
-         * <p>
+         *
          * Modifications to this buffer's content will cause the returned array's content
          * to be modified, and vice versa.
-         * <p>
+         *
          * Invoke the hasArray method before invoking this method in order to ensure that
          * this buffer has an accessible backing array.
-         * @returns the array that backs this Buffer
+         *
+         * @returns the array that backs this Buffer.
+         *
          * @throws ReadOnlyBufferException if this Buffer is read only.
          * @throws UnsupportedOperationException if the underlying store has no array.
          */
@@ -87,63 +94,69 @@ namespace nio{
         /**
          * Returns the offset within this buffer's backing array of the first element of
          * the buffer  (optional operation).
-         * <p>
+         *
          * Invoke the hasArray method before invoking this method in order to ensure that
          * this buffer has an accessible backing array.
+         *
          * @returns The offset into the backing array where index zero starts.
+         *
          * @throws ReadOnlyBufferException if this Buffer is read only.
          * @throws UnsupportedOperationException if the underlying store has no array.
          */
-        virtual std::size_t arrayOffset()
+        virtual int arrayOffset()
             throw( decaf::lang::exceptions::UnsupportedOperationException,
                    ReadOnlyBufferException ) = 0;
 
         /**
          * Creates a new, read-only int buffer that shares this buffer's content.
-         * <p>
+         *
          * The content of the new buffer will be that of this buffer. Changes to this
          * buffer's content will be visible in the new buffer; the new buffer itself,
          * however, will be read-only and will not allow the shared content to be
          * modified. The two buffers' position, limit, and mark values will be
          * independent.
-         * <p>
+         *
          * If this buffer is itself read-only then this method behaves in exactly the
          * same way as the duplicate method.
-         * <p>
+         *
          * The new buffer's capacity, limit, position, and mark values will be
          * identical to those of this buffer.
+         *
          * @return The new, read-only int buffer which the caller then owns.
          */
         virtual IntBuffer* asReadOnlyBuffer() const = 0;
 
         /**
          * Compacts this buffer
-         * <p>
+         *
          * The bytes between the buffer's current position and its limit, if any, are
          * copied to the beginning of the buffer. That is, the byte at index
          * p = position() is copied to index zero, the byte at index p + 1 is copied
          * to index one, and so forth until the byte at index limit() - 1 is copied
          * to index n = limit() - 1 - p. The buffer's position is then set to n+1 and
          * its limit is set to its capacity. The mark, if defined, is discarded.
-         * <p>
+         *
          * The buffer's position is set to the number of bytes copied, rather than to
          * zero, so that an invocation of this method can be followed immediately by
          * an invocation of another relative put method.
+         *
          * @returns a reference to this IntBuffer
-         * @throws ReadOnlyBufferException - If this buffer is read-only
+         *
+         * @throws ReadOnlyBufferException if this buffer is read-only.
          */
         virtual IntBuffer& compact() throw( ReadOnlyBufferException ) = 0;
 
         /**
          * Creates a new int buffer that shares this buffer's content.
-         * <p>
+         *
          * The content of the new buffer will be that of this buffer. Changes to this
          * buffer's content will be visible in the new buffer, and vice versa; the two
          * buffers' position, limit, and mark values will be independent.
-         * <p>
+         *
          * The new buffer's capacity, limit, position, and mark values will be identical
          * to those of this buffer. The new buffer will be read-only if, and only if,
          * this buffer is read-only.
+         *
          * @returns a new int Buffer which the caller owns.
          */
         virtual IntBuffer* duplicate() = 0;
@@ -151,67 +164,86 @@ namespace nio{
         /**
          * Relative get method. Reads the value at this buffer's current position,
          * and then increments the position.
-         * @returns the int at the current position
-         * @throws BufferUnderflowException if there no more data to return
+         *
+         * @returns the int at the current position.
+         *
+         * @throws BufferUnderflowException if there no more data to return.
          */
         virtual int get() throw ( BufferUnderflowException ) = 0;
 
         /**
          * Absolute get method. Reads the value at the given index.
-         * @param index - the index in the Buffer where the int is to be read
-         * @returns the int that is located at the given index
-         * @throws IndexOutOfBoundsException - If index is not smaller than the
-         * buffer's limit
+         *
+         * @param index
+         *      The index in the Buffer where the int is to be read.
+         *
+         * @returns the int that is located at the given index.
+         *
+         * @throws IndexOutOfBoundsException if index is not smaller than the
+         *         buffer's limit, or index is negative.
          */
-        virtual int get( std::size_t index ) const
-            throw ( lang::exceptions::IndexOutOfBoundsException ) = 0;
+        virtual int get( int index ) const
+            throw ( decaf::lang::exceptions::IndexOutOfBoundsException ) = 0;
 
         /**
          * Relative bulk get method.
-         * <p>
+         *
          * This method transfers values from this buffer into the given destination
          * vector. An invocation of this method of the form src.get(a) behaves in
          * exactly the same way as the invocation.  The vector must be sized to the
          * amount of data that is to be read, that is to say, the caller should call
          * buffer.resize( N ) before calling this get method.
-         * @returns a reference to this Buffer
-         * @throws BufferUnderflowException - If there are fewer than length ints
-         * remaining in this buffer
+         *
+         * @returns a reference to this Buffer.
+         *
+         * @throws BufferUnderflowException if there are fewer than length ints
+         *         remaining in this buffer.
          */
         IntBuffer& get( std::vector<int> buffer )
             throw ( BufferUnderflowException );
 
         /**
          * Relative bulk get method.
-         * <p>
+         *
          * This method transfers ints from this buffer into the given destination array.
          * If there are fewer ints remaining in the buffer than are required to satisfy
          * the request, that is, if length > remaining(), then no bytes are transferred
          * and a BufferUnderflowException is thrown.
-         * <p>
+         *
          * Otherwise, this method copies length ints from this buffer into the given
          * array, starting at the current position of this buffer and at the given offset
          * in the array. The position of this buffer is then incremented by length.
-         * <p>
-         * @param buffer - pointer to an allocated buffer to fill
-         * @param offset - position in the buffer to start filling
-         * @param length - amount of data to put in the passed buffer
-         * @returns a reference to this Buffer
-         * @throws BufferUnderflowException - If there are fewer than length ints
-         * remaining in this buffer
+         *
+         * @param buffer
+         *      The pointer to an allocated buffer to fill.
+         * @param size
+         *      The size of the buffer that was passed in.
+         * @param offset
+         *      The position in the buffer to start filling.
+         * @param length
+         *      The amount of data to put in the passed buffer.
+         *
+         * @returns a reference to this Buffer.
+         *
+         * @throws BufferUnderflowException if there are fewer than length ints
+         *         remaining in this buffer.
          * @throws NullPointerException if the passed buffer is null.
+         * @throws IndexOutOfBoundsException if the preconditions of size, offset, or length
+         *         are not met.
          */
-        IntBuffer& get( int* buffer, std::size_t offset, std::size_t length )
+        IntBuffer& get( int* buffer, int size, int offset, int length )
             throw( BufferUnderflowException,
-                   lang::exceptions::NullPointerException );
+                   decaf::lang::exceptions::IndexOutOfBoundsException,
+                   decaf::lang::exceptions::NullPointerException );
 
         /**
          * Tells whether or not this buffer is backed by an accessible int array.
          * If this method returns true then the array and arrayOffset methods may safely
          * be invoked.  Subclasses should override this method if they do not have a
          * backing array as this class always returns true.
+         *
          * @returns true if, and only if, this buffer is backed by an array and is not
-         * read-only
+         * read-only.
          */
         virtual bool hasArray() const = 0;
 
@@ -220,76 +252,104 @@ namespace nio{
          * this buffer. If there are more ints remaining in the source buffer than in
          * this buffer, that is, if src.remaining() > remaining(), then no ints are
          * transferred and a BufferOverflowException is thrown.
-         * <p>
+         *
          * Otherwise, this method copies n = src.remaining() ints from the given
          * buffer into this buffer, starting at each buffer's current position. The
          * positions of both buffers are then incremented by n.
-         * @param src - the buffer to take ints from an place in this one.
-         * @returns a reference to this buffer
-         * @throws BufferOverflowException - If there is insufficient space in this
-         * buffer for the remaining ints in the source buffer
-         * @throws IllegalArgumentException - If the source buffer is this buffer
-         * @throws ReadOnlyBufferException - If this buffer is read-only
+         *
+         * @param src
+         *      The buffer to take ints from an place in this one.
+         *
+         * @returns a reference to this buffer.
+         *
+         * @throws BufferOverflowException if there is insufficient space in this
+         *         buffer for the remaining ints in the source buffer.
+         * @throws IllegalArgumentException if the source buffer is this buffer.
+         * @throws ReadOnlyBufferException if this buffer is read-only.
          */
         IntBuffer& put( IntBuffer& src )
             throw( BufferOverflowException, ReadOnlyBufferException,
-                   lang::exceptions::IllegalArgumentException );
+                   decaf::lang::exceptions::IllegalArgumentException );
 
         /**
          * This method transfers ints into this buffer from the given source array.
          * If there are more ints to be copied from the array than remain in this buffer,
          * that is, if length > remaining(), then no ints are transferred and a
          * BufferOverflowException is thrown.
-         * <p>
+         *
          * Otherwise, this method copies length bytes from the given array into this
          * buffer, starting at the given offset in the array and at the current position
          * of this buffer. The position of this buffer is then incremented by length.
-         * @param buffer- The array from which ints are to be read
-         * @param offset- The offset within the array of the first int to be read;
-         * @param length - The number of ints to be read from the given array
-         * @returns a reference to this buffer
-         * @throws BufferOverflowException - If there is insufficient space in this buffer
-         * @throws ReadOnlyBufferException - If this buffer is read-only
+         *
+         * @param buffer
+         *      The array from which integers are to be read.
+         * @param size
+         *      The size of the buffer passed.
+         * @param offset
+         *      The offset within the array of the first char to be read.
+         * @param length
+         *      The number of integers to be read from the given array.
+         *
+         * @returns a reference to this buffer.
+         *
+         * @throws BufferOverflowException if there is insufficient space in this buffer.
+         * @throws ReadOnlyBufferException if this buffer is read-only.
          * @throws NullPointerException if the passed buffer is null.
+         * @throws IndexOutOfBoundsException if the preconditions of size, offset, or length
+         *         are not met.
          */
-        IntBuffer& put( const int* buffer, std::size_t offset, std::size_t length )
+        IntBuffer& put( const int* buffer, int size, int offset, int length )
             throw( BufferOverflowException, ReadOnlyBufferException,
-                   lang::exceptions::NullPointerException );
+                   decaf::lang::exceptions::IndexOutOfBoundsException,
+                   decaf::lang::exceptions::NullPointerException );
 
         /**
          * This method transfers the entire content of the given source ints array into
-         * this buffer.  This is the same as calling put( &buffer[0], 0, buffer.size()
-         * @param buffer - The buffer whose contents are copied to this IntBuffer
-         * @returns a reference to this buffer
-         * @throws BufferOverflowException - If there is insufficient space in this buffer
-         * @throws ReadOnlyBufferException - If this buffer is read-only
+         * this buffer.  This is the same as calling put( &buffer[0], 0, buffer.size().
+         *
+         * @param buffer
+         *      The buffer whose contents are copied to this IntBuffer.
+         *
+         * @returns a reference to this buffer.
+         *
+         * @throws BufferOverflowException if there is insufficient space in this buffer.
+         * @throws ReadOnlyBufferException if this buffer is read-only.
          */
         IntBuffer& put( std::vector<int>& buffer )
             throw( BufferOverflowException, ReadOnlyBufferException );
 
         /**
-         * Writes the given ints into this buffer at the current position, and then
+         * Writes the given integer into this buffer at the current position, and then
          * increments the position.
-         * @param value - the ints value to be written
-         * @returns a reference to this buffer
-         * @throws BufferOverflowException - If this buffer's current position is not
-         * smaller than its limit
-         * @throws ReadOnlyBufferException - If this buffer is read-only
+         *
+         * @param value
+         *      The integer value to be written.
+         *
+         * @returns a reference to this buffer.
+         *
+         * @throws BufferOverflowException if this buffer's current position is not
+         *         smaller than its limit.
+         * @throws ReadOnlyBufferException if this buffer is read-only.
          */
         virtual IntBuffer& put( int value )
             throw( BufferOverflowException, ReadOnlyBufferException ) = 0;
 
         /**
          * Writes the given ints into this buffer at the given index.
-         * @param index - position in the Buffer to write the data
-         * @param value - the ints to write.
-         * @returns a reference to this buffer
+         *
+         * @param index
+         *      The position in the Buffer to write the data.
+         * @param value
+         *      The ints to write.
+         *
+         * @returns a reference to this buffer.
+         *
          * @throws IndexOutOfBoundsException - If index greater than the buffer's limit
-         * minus the size of the type being written.
-         * @throws ReadOnlyBufferException - If this buffer is read-only
+         *         minus the size of the type being written, or the index is negative.
+         * @throws ReadOnlyBufferException - If this buffer is read-only.
          */
-        virtual IntBuffer& put( std::size_t index, int value )
-            throw( lang::exceptions::IndexOutOfBoundsException,
+        virtual IntBuffer& put( int index, int value )
+            throw( decaf::lang::exceptions::IndexOutOfBoundsException,
                    ReadOnlyBufferException ) = 0;
 
         /**
@@ -298,10 +358,11 @@ namespace nio{
          * current position. Changes to this buffer's content will be visible in the new
          * buffer, and vice versa; the two buffers' position, limit, and mark values will
          * be independent.
-         * <p>
+         *
          * The new buffer's position will be zero, its capacity and its limit will be the
          * number of bytes remaining in this buffer, and its mark will be undefined. The
          * new buffer will be read-only if, and only if, this buffer is read-only.
+         *
          * @returns the newly create IntBuffer which the caller owns.
          */
         virtual IntBuffer* slice() const = 0;
@@ -309,32 +370,22 @@ namespace nio{
     public:  // Comparable
 
         /**
-         * Compares this object with the specified object for order. Returns a
-         * negative integer, zero, or a positive integer as this object is less
-         * than, equal to, or greater than the specified object.
-         * @param value - the Object to be compared.
-         * @returns a negative integer, zero, or a positive integer as this
-         * object is less than, equal to, or greater than the specified object.
+         * {@inheritDoc}
          */
         virtual int compareTo( const IntBuffer& value ) const;
 
         /**
-         * @return true if this value is considered equal to the passed value.
+         * {@inheritDoc}
          */
         virtual bool equals( const IntBuffer& value ) const;
 
         /**
-         * Compares equality between this object and the one passed.
-         * @param value - the value to be compared to this one.
-         * @return true if this object is equal to the one passed.
+         * {@inheritDoc}
          */
         virtual bool operator==( const IntBuffer& value ) const;
 
         /**
-         * Compares this object to another and returns true if this object
-         * is considered to be less than the one passed.  This
-         * @param value - the value to be compared to this one.
-         * @return true if this object is equal to the one passed.
+         * {@inheritDoc}
          */
         virtual bool operator<( const IntBuffer& value ) const;
 
@@ -342,41 +393,60 @@ namespace nio{
 
         /**
          * Allocates a new Double buffer.
-         * <p>
+         *
          * The new buffer's position will be zero, its limit will be its capacity, and
          * its mark will be undefined. It will have a backing array, and its array offset
          * will be zero.
-         * @param capacity - The size of the Double buffer in ints
+         *
+         * @param capacity
+         *      The size of the Double buffer in integers.
+         *
          * @returns the IntBuffer that was allocated, caller owns.
          */
-        static IntBuffer* allocate( std::size_t capacity );
+        static IntBuffer* allocate( int capacity )
+            throw( decaf::lang::exceptions::IllegalArgumentException );
 
         /**
          * Wraps the passed buffer with a new IntBuffer.
-         * <p>
+         *
          * The new buffer will be backed by the given int array; that is, modifications
          * to the buffer will cause the array to be modified and vice versa. The new
          * buffer's capacity will be array.length, its position will be offset, its limit
          * will be offset + length, and its mark will be undefined. Its backing array
          * will be the given array, and its array offset will be zero.
-         * @param array - The array that will back the new buffer
-         * @param offset - The offset of the subarray to be used
-         * @param length - The length of the subarray to be used
+         *
+         * @param array
+         *      The array that will back the new buffer.
+         * @param size
+         *      The size of the passed in array.
+         * @param offset
+         *      The offset of the subarray to be used.
+         * @param length
+         *      The length of the subarray to be used.
+         *
          * @returns a new IntBuffer that is backed by buffer, caller owns.
-         */
-        static IntBuffer* wrap( int* array, std::size_t offset, std::size_t length )
-            throw( lang::exceptions::NullPointerException );
+         *
+         * @throws NullPointerException if the array pointer is NULL.
+         * @throws IndexOutOfBoundsException if the preconditions of size, offset, or length
+         *         are not met.
+         */
+        static IntBuffer* wrap( int* array, int size, int offset, int length )
+            throw( decaf::lang::exceptions::NullPointerException,
+                   decaf::lang::exceptions::IndexOutOfBoundsException );
 
         /**
          * Wraps the passed STL int Vector in a IntBuffer.
-         * <p>
+         *
          * The new buffer will be backed by the given int array; modifications to the
          * buffer will cause the array to be modified and vice versa. The new buffer's
          * capacity and limit will be buffer.size(), its position will be zero, and its
          * mark will be undefined. Its backing array will be the given array, and its
          * array offset will be zero.
-         * @param buffer - The vector that will back the new buffer, the vector must
-         * have been sized to the desired size already by calling vector.resize( N ).
+         *
+         * @param buffer
+         *      The vector that will back the new buffer, the vector must have been sized
+         *      to the desired size already by calling vector.resize( N ).
+         *
          * @returns a new IntBuffer that is backed by buffer, caller owns.
          */
         static IntBuffer* wrap( std::vector<int>& buffer );

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/nio/LongBuffer.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/nio/LongBuffer.cpp?rev=925692&r1=925691&r2=925692&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/nio/LongBuffer.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/nio/LongBuffer.cpp Sat Mar 20 21:57:20 2010
@@ -29,16 +29,16 @@ using namespace decaf::lang::exceptions;
 using namespace decaf::internal::nio;
 
 ////////////////////////////////////////////////////////////////////////////////
-LongBuffer::LongBuffer( std::size_t capacity )
- :  Buffer( capacity ) {
+LongBuffer::LongBuffer( int capacity )
+    throw( decaf::lang::exceptions::IllegalArgumentException ) : Buffer( capacity ) {
 
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-LongBuffer* LongBuffer::allocate( std::size_t capacity ) {
+LongBuffer* LongBuffer::allocate( int capacity )
+    throw( decaf::lang::exceptions::IllegalArgumentException ) {
 
     try{
-
         return BufferFactory::createLongBuffer( capacity );
     }
     DECAF_CATCH_RETHROW( Exception )
@@ -46,8 +46,9 @@ LongBuffer* LongBuffer::allocate( std::s
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-LongBuffer* LongBuffer::wrap( long long* buffer, std::size_t offset, std::size_t length )
-    throw( lang::exceptions::NullPointerException ) {
+LongBuffer* LongBuffer::wrap( long long* buffer, int size, int offset, int length )
+    throw( decaf::lang::exceptions::IndexOutOfBoundsException,
+           decaf::lang::exceptions::NullPointerException ) {
 
     try{
 
@@ -57,7 +58,7 @@ LongBuffer* LongBuffer::wrap( long long*
                 "LongBuffer::wrap - Passed Buffer is Null.");
         }
 
-        return BufferFactory::createLongBuffer( buffer, offset, length );
+        return BufferFactory::createLongBuffer( buffer, size, offset, length );
     }
     DECAF_CATCH_RETHROW( NullPointerException )
     DECAF_CATCH_EXCEPTION_CONVERT( Exception, NullPointerException )
@@ -75,7 +76,7 @@ LongBuffer* LongBuffer::wrap( std::vecto
                 "LongBuffer::wrap - Passed Buffer is Empty.");
         }
 
-        return BufferFactory::createLongBuffer( &buffer[0], 0, buffer.size() );
+        return BufferFactory::createLongBuffer( &buffer[0], (int)buffer.size(), 0, (int)buffer.size() );
     }
     DECAF_CATCH_RETHROW( NullPointerException )
     DECAF_CATCH_EXCEPTION_CONVERT( Exception, NullPointerException )
@@ -102,7 +103,7 @@ LongBuffer& LongBuffer::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;
     }
@@ -112,9 +113,10 @@ LongBuffer& LongBuffer::get( std::vector
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-LongBuffer& LongBuffer::get( long long* buffer, std::size_t offset, std::size_t length )
+LongBuffer& LongBuffer::get( long long* buffer, int size, int offset, int length )
     throw( BufferUnderflowException,
-           lang::exceptions::NullPointerException ) {
+           decaf::lang::exceptions::IndexOutOfBoundsException,
+           decaf::lang::exceptions::NullPointerException ) {
 
     try{
 
@@ -128,19 +130,26 @@ LongBuffer& LongBuffer::get( long long* 
                 "LongBuffer::get - Passed Buffer is Null" );
         }
 
+        if( size < 0 || offset < 0 || length < 0 || (long long)offset + (long long)length > (long long)size ) {
+            throw IndexOutOfBoundsException(
+                 __FILE__, __LINE__, "Arguments violate array bounds." );
+        }
+
         if( length > remaining() ) {
             throw BufferUnderflowException(
                 __FILE__, __LINE__,
                 "LongBuffer::get - Not enough data to fill length = %d", length );
         }
 
-        for( std::size_t ix = 0; ix < length; ++ix ){
+        for( int ix = 0; ix < length; ++ix ){
             buffer[offset + ix] = this->get();
         }
 
         return *this;
     }
     DECAF_CATCH_RETHROW( BufferUnderflowException )
+    DECAF_CATCH_RETHROW( IndexOutOfBoundsException )
+    DECAF_CATCH_RETHROW( NullPointerException )
     DECAF_CATCH_EXCEPTION_CONVERT( Exception, BufferUnderflowException )
     DECAF_CATCHALL_THROW( BufferUnderflowException )
 }
@@ -184,9 +193,10 @@ LongBuffer& LongBuffer::put( LongBuffer&
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-LongBuffer& LongBuffer::put( const long long* buffer, std::size_t offset, std::size_t length )
+LongBuffer& LongBuffer::put( const long long* buffer, int size, int offset, int length )
     throw( BufferOverflowException, ReadOnlyBufferException,
-           lang::exceptions::NullPointerException ) {
+           decaf::lang::exceptions::IndexOutOfBoundsException,
+           decaf::lang::exceptions::NullPointerException ) {
 
     try{
 
@@ -206,6 +216,11 @@ LongBuffer& LongBuffer::put( const long 
                 "LongBuffer::put - Passed Buffer is Null.");
         }
 
+        if( size < 0 || offset < 0 || length < 0 || (long long)offset + (long long)length > (long long)size ) {
+            throw IndexOutOfBoundsException(
+                 __FILE__, __LINE__, "Arguments violate array bounds." );
+        }
+
         if( length > this->remaining() ) {
             throw BufferOverflowException(
                 __FILE__, __LINE__,
@@ -213,7 +228,7 @@ LongBuffer& LongBuffer::put( const long 
         }
 
         // 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] );
         }
 
@@ -222,6 +237,7 @@ LongBuffer& LongBuffer::put( const long 
     DECAF_CATCH_RETHROW( BufferOverflowException )
     DECAF_CATCH_RETHROW( ReadOnlyBufferException )
     DECAF_CATCH_RETHROW( NullPointerException )
+    DECAF_CATCH_RETHROW( IndexOutOfBoundsException )
     DECAF_CATCH_EXCEPTION_CONVERT( Exception, BufferOverflowException )
     DECAF_CATCHALL_THROW( BufferOverflowException )
 }
@@ -233,7 +249,7 @@ LongBuffer& LongBuffer::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;
@@ -247,10 +263,10 @@ LongBuffer& LongBuffer::put( std::vector
 ////////////////////////////////////////////////////////////////////////////////
 int LongBuffer::compareTo( const LongBuffer& value ) const {
 
-    std::size_t compareRemaining = (std::size_t)Math::min( (int)remaining(), (int)value.remaining() );
+    int compareRemaining = (int)Math::min( (int)remaining(), (int)value.remaining() );
 
-    std::size_t thisPos = this->position();
-    std::size_t otherPos = value.position();
+    int thisPos = this->position();
+    int otherPos = value.position();
     long long thisVal, otherVal;
 
     while( compareRemaining > 0 ) {
@@ -281,8 +297,8 @@ bool LongBuffer::equals( const LongBuffe
         return false;
     }
 
-    std::size_t myPosition = this->position();
-    std::size_t otherPosition = value.position();
+    int myPosition = this->position();
+    int otherPosition = value.position();
     bool equalSoFar = true;
 
     while( equalSoFar && ( myPosition < this->limit() ) ) {

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/nio/LongBuffer.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/nio/LongBuffer.h?rev=925692&r1=925691&r2=925692&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/nio/LongBuffer.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/nio/LongBuffer.h Sat Mar 20 21:57:20 2010
@@ -52,12 +52,17 @@ namespace nio{
     protected:
 
         /**
-        * Creates a LongBuffer object that has its backing array allocated long longernally
-        * and is then owned and deleted when this object is deleted.  The array is
-        * initially created with all elements initialized to zero.
-        * @param capacity - size and limit of the Buffer in doubles
-        */
-        LongBuffer( std::size_t capacity );
+         * Creates a LongBuffer object that has its backing array allocated long longernally
+         * and is then owned and deleted when this object is deleted.  The array is
+         * initially created with all elements initialized to zero.
+         *
+         * @param capacity
+         *       The size and limit of the Buffer in long longs.
+         *
+         * @throws IllegalArguementException if capacity is negative.
+         */
+        LongBuffer( int capacity )
+            throw( decaf::lang::exceptions::IllegalArgumentException );
 
     public:
 
@@ -70,13 +75,15 @@ namespace nio{
 
         /**
          * Returns the long long array that backs this buffer  (optional operation).
-         * <p>
+         *
          * Modifications to this buffer's content will cause the returned array's content
          * to be modified, and vice versa.
-         * <p>
+         *
          * Invoke the hasArray method before invoking this method in order to ensure that
          * this buffer has an accessible backing array.
-         * @returns the array that backs this Buffer
+         *
+         * @returns the array that backs this Buffer.
+         *
          * @throws ReadOnlyBufferException if this Buffer is read only.
          * @throws UnsupportedOperationException if the underlying store has no array.
          */
@@ -87,63 +94,69 @@ namespace nio{
         /**
          * Returns the offset within this buffer's backing array of the first element of
          * the buffer  (optional operation).
-         * <p>
+         *
          * Invoke the hasArray method before invoking this method in order to ensure that
          * this buffer has an accessible backing array.
+         *
          * @returns The offset long longo the backing array where index zero starts.
+         *
          * @throws ReadOnlyBufferException if this Buffer is read only.
          * @throws UnsupportedOperationException if the underlying store has no array.
          */
-        virtual std::size_t arrayOffset()
+        virtual int arrayOffset()
             throw( decaf::lang::exceptions::UnsupportedOperationException,
                    ReadOnlyBufferException ) = 0;
 
         /**
          * Creates a new, read-only long long buffer that shares this buffer's content.
-         * <p>
+         *
          * The content of the new buffer will be that of this buffer. Changes to this
          * buffer's content will be visible in the new buffer; the new buffer itself,
          * however, will be read-only and will not allow the shared content to be
          * modified. The two buffers' position, limit, and mark values will be
          * independent.
-         * <p>
+         *
          * If this buffer is itself read-only then this method behaves in exactly the
          * same way as the duplicate method.
-         * <p>
+         *
          * The new buffer's capacity, limit, position, and mark values will be
          * identical to those of this buffer.
+         *
          * @return The new, read-only long long buffer which the caller then owns.
          */
         virtual LongBuffer* asReadOnlyBuffer() const = 0;
 
         /**
          * Compacts this buffer
-         * <p>
+         *
          * The bytes between the buffer's current position and its limit, if any, are
          * copied to the beginning of the buffer. That is, the byte at index
          * p = position() is copied to index zero, the byte at index p + 1 is copied
          * to index one, and so forth until the byte at index limit() - 1 is copied
          * to index n = limit() - 1 - p. The buffer's position is then set to n+1 and
          * its limit is set to its capacity. The mark, if defined, is discarded.
-         * <p>
+         *
          * The buffer's position is set to the number of bytes copied, rather than to
          * zero, so that an invocation of this method can be followed immediately by
          * an invocation of another relative put method.
-         * @returns a reference to this LongBuffer
-         * @throws ReadOnlyBufferException - If this buffer is read-only
+         *
+         * @returns a reference to this LongBuffer.
+         *
+         * @throws ReadOnlyBufferException if this buffer is read-only.
          */
         virtual LongBuffer& compact() throw( ReadOnlyBufferException ) = 0;
 
         /**
          * Creates a new long long buffer that shares this buffer's content.
-         * <p>
+         *
          * The content of the new buffer will be that of this buffer. Changes to this
          * buffer's content will be visible in the new buffer, and vice versa; the two
          * buffers' position, limit, and mark values will be independent.
-         * <p>
+         *
          * The new buffer's capacity, limit, position, and mark values will be identical
          * to those of this buffer. The new buffer will be read-only if, and only if,
          * this buffer is read-only.
+         *
          * @returns a new long long Buffer which the caller owns.
          */
         virtual LongBuffer* duplicate() = 0;
@@ -151,67 +164,86 @@ namespace nio{
         /**
          * Relative get method. Reads the value at this buffer's current position,
          * and then increments the position.
-         * @returns the long long at the current position
-         * @throws BufferUnderflowException if there no more data to return
+         *
+         * @returns the long long at the current position.
+         *
+         * @throws BufferUnderflowException if there no more data to return.
          */
         virtual long long get() throw ( BufferUnderflowException ) = 0;
 
         /**
          * Absolute get method. Reads the value at the given index.
-         * @param index - the index in the Buffer where the long long is to be read
-         * @returns the long long that is located at the given index
-         * @throws IndexOutOfBoundsException - If index is not smaller than the
-         * buffer's limit
+         *
+         * @param index
+         *      The index in the Buffer where the long long is to be read.
+         *
+         * @returns the long long that is located at the given index.
+         *
+         * @throws IndexOutOfBoundsException if index is not smaller than the
+         *         buffer's limit, or index is negative.
          */
-        virtual long long get( std::size_t index ) const
-            throw ( lang::exceptions::IndexOutOfBoundsException ) = 0;
+        virtual long long get( int index ) const
+            throw ( decaf::lang::exceptions::IndexOutOfBoundsException ) = 0;
 
         /**
          * Relative bulk get method.
-         * <p>
+         *
          * This method transfers values from this buffer long longo the given destination
          * vector. An invocation of this method of the form src.get(a) behaves in
          * exactly the same way as the invocation.  The vector must be sized to the
          * amount of data that is to be read, that is to say, the caller should call
          * buffer.resize( N ) before calling this get method.
-         * @returns a reference to this Buffer
-         * @throws BufferUnderflowException - If there are fewer than length long longs
-         * remaining in this buffer
+         *
+         * @returns a reference to this Buffer.
+         *
+         * @throws BufferUnderflowException if there are fewer than length long longs
+         *         remaining in this buffer.
          */
         LongBuffer& get( std::vector<long long> buffer )
             throw ( BufferUnderflowException );
 
         /**
          * Relative bulk get method.
-         * <p>
+         *
          * This method transfers long longs from this buffer long longo the given destination array.
          * If there are fewer long longs remaining in the buffer than are required to satisfy
          * the request, that is, if length > remaining(), then no bytes are transferred
          * and a BufferUnderflowException is thrown.
-         * <p>
+         *
          * Otherwise, this method copies length long longs from this buffer long longo the given
          * array, starting at the current position of this buffer and at the given offset
          * in the array. The position of this buffer is then incremented by length.
-         * <p>
-         * @param buffer - long longer to an allocated buffer to fill
-         * @param offset - position in the buffer to start filling
-         * @param length - amount of data to put in the passed buffer
-         * @returns a reference to this Buffer
-         * @throws BufferUnderflowException - If there are fewer than length long longs
-         * remaining in this buffer
+         *
+         * @param buffer
+         *      The pointer to an allocated long long buffer to fill.
+         * @param size
+         *      The size of the passed in buffer.
+         * @param offset
+         *      The position in the buffer to start filling.
+         * @param length
+         *      The amount of data to put in the passed buffer.
+         *
+         * @returns a reference to this Buffer.
+         *
+         * @throws BufferUnderflowException if there are fewer than length long longs
+         *         remaining in this buffer
          * @throws NullPolong longerException if the passed buffer is null.
+         * @throws IndexOutOfBoundsException if the preconditions of size, offset, or length
+         *         are not met.
          */
-        LongBuffer& get( long long* buffer, std::size_t offset, std::size_t length )
+        LongBuffer& get( long long* buffer, int size, int offset, int length )
             throw( BufferUnderflowException,
-                   lang::exceptions::NullPointerException );
+                   decaf::lang::exceptions::IndexOutOfBoundsException,
+                   decaf::lang::exceptions::NullPointerException );
 
         /**
          * Tells whether or not this buffer is backed by an accessible long long array.
          * If this method returns true then the array and arrayOffset methods may safely
          * be invoked.  Subclasses should override this method if they do not have a
          * backing array as this class always returns true.
+         *
          * @returns true if, and only if, this buffer is backed by an array and is not
-         * read-only
+         *          read-only.
          */
         virtual bool hasArray() const = 0;
 
@@ -220,16 +252,20 @@ namespace nio{
          * this buffer. If there are more long longs remaining in the source buffer than in
          * this buffer, that is, if src.remaining() > remaining(), then no long longs are
          * transferred and a BufferOverflowException is thrown.
-         * <p>
+         *
          * Otherwise, this method copies n = src.remaining() long longs from the given
          * buffer long longo this buffer, starting at each buffer's current position. The
          * positions of both buffers are then incremented by n.
-         * @param src - the buffer to take long longs from an place in this one.
-         * @returns a reference to this buffer
-         * @throws BufferOverflowException - If there is insufficient space in this
-         * buffer for the remaining long longs in the source buffer
-         * @throws IllegalArgumentException - If the source buffer is this buffer
-         * @throws ReadOnlyBufferException - If this buffer is read-only
+         *
+         * @param src
+         *      The buffer to take long longs from an place in this one.
+         *
+         * @returns a reference to this buffer.
+         *
+         * @throws BufferOverflowException if there is insufficient space in this
+         *         buffer for the remaining long longs in the source buffer
+         * @throws IllegalArgumentException if the source buffer is this buffer
+         * @throws ReadOnlyBufferException if this buffer is read-only
          */
         LongBuffer& put( LongBuffer& src )
             throw( BufferOverflowException, ReadOnlyBufferException,
@@ -240,29 +276,44 @@ namespace nio{
          * If there are more long longs to be copied from the array than remain in this buffer,
          * that is, if length > remaining(), then no long longs are transferred and a
          * BufferOverflowException is thrown.
-         * <p>
+         *
          * Otherwise, this method copies length bytes from the given array long longo this
          * buffer, starting at the given offset in the array and at the current position
          * of this buffer. The position of this buffer is then incremented by length.
-         * @param buffer- The array from which long longs are to be read
-         * @param offset- The offset within the array of the first long long to be read;
-         * @param length - The number of long longs to be read from the given array
-         * @returns a reference to this buffer
-         * @throws BufferOverflowException - If there is insufficient space in this buffer
-         * @throws ReadOnlyBufferException - If this buffer is read-only
+         *
+         * @param buffer
+         *      The array from which long longs are to be read.
+         * @param size
+         *      The size of the buffer passed.
+         * @param offset
+         *      The offset within the array of the first char to be read.
+         * @param length
+         *      The number of long longs to be read from the given array.
+         *
+         * @returns a reference to this buffer.
+         *
+         * @throws BufferOverflowException if there is insufficient space in this buffer
+         * @throws ReadOnlyBufferException if this buffer is read-only
          * @throws NullPolong longerException if the passed buffer is null.
+         * @throws IndexOutOfBoundsException if the preconditions of size, offset, or length
+         *         are not met.
          */
-        LongBuffer& put( const long long* buffer, std::size_t offset, std::size_t length )
+        LongBuffer& put( const long long* buffer, int size, int offset, int length )
             throw( BufferOverflowException, ReadOnlyBufferException,
-                   lang::exceptions::NullPointerException );
+                   decaf::lang::exceptions::IndexOutOfBoundsException,
+                   decaf::lang::exceptions::NullPointerException );
 
         /**
          * This method transfers the entire content of the given source long longs array long longo
-         * this buffer.  This is the same as calling put( &buffer[0], 0, buffer.size()
-         * @param buffer - The buffer whose contents are copied to this LongBuffer
-         * @returns a reference to this buffer
-         * @throws BufferOverflowException - If there is insufficient space in this buffer
-         * @throws ReadOnlyBufferException - If this buffer is read-only
+         * this buffer.  This is the same as calling put( &buffer[0], 0, buffer.size().
+         *
+         * @param buffer
+         *      The buffer whose contents are copied to this LongBuffer.
+         *
+         * @returns a reference to this buffer.
+         *
+         * @throws BufferOverflowException if there is insufficient space in this buffer.
+         * @throws ReadOnlyBufferException if this buffer is read-only.
          */
         LongBuffer& put( std::vector<long long>& buffer )
             throw( BufferOverflowException, ReadOnlyBufferException );
@@ -270,26 +321,35 @@ namespace nio{
         /**
          * Writes the given long longs long longo this buffer at the current position, and then
          * increments the position.
-         * @param value - the long longs value to be written
-         * @returns a reference to this buffer
-         * @throws BufferOverflowException - If this buffer's current position is not
-         * smaller than its limit
-         * @throws ReadOnlyBufferException - If this buffer is read-only
+         *
+         * @param value
+         *      The long longs value to be written.
+         *
+         * @returns a reference to this buffer.
+         *
+         * @throws BufferOverflowException if this buffer's current position is not
+         *         smaller than its limit
+         * @throws ReadOnlyBufferException if this buffer is read-only
          */
         virtual LongBuffer& put( long long value )
             throw( BufferOverflowException, ReadOnlyBufferException ) = 0;
 
         /**
          * Writes the given long longs long longo this buffer at the given index.
-         * @param index - position in the Buffer to write the data
-         * @param value - the long longs to write.
-         * @returns a reference to this buffer
-         * @throws IndexOutOfBoundsException - If index greater than the buffer's limit
-         * minus the size of the type being written.
-         * @throws ReadOnlyBufferException - If this buffer is read-only
+         *
+         * @param index
+         *      The position in the Buffer to write the data
+         * @param value
+         *      The long longs to write.
+         *
+         * @returns a reference to this buffer.
+         *
+         * @throws IndexOutOfBoundsException if index greater than the buffer's limit
+         *         minus the size of the type being written.
+         * @throws ReadOnlyBufferException if this buffer is read-only
          */
-        virtual LongBuffer& put( std::size_t index, long long value )
-            throw( lang::exceptions::IndexOutOfBoundsException,
+        virtual LongBuffer& put( int index, long long value )
+            throw( decaf::lang::exceptions::IndexOutOfBoundsException,
                    ReadOnlyBufferException ) = 0;
 
         /**
@@ -298,10 +358,11 @@ namespace nio{
          * current position. Changes to this buffer's content will be visible in the new
          * buffer, and vice versa; the two buffers' position, limit, and mark values will
          * be independent.
-         * <p>
+         *
          * The new buffer's position will be zero, its capacity and its limit will be the
          * number of bytes remaining in this buffer, and its mark will be undefined. The
          * new buffer will be read-only if, and only if, this buffer is read-only.
+         *
          * @returns the newly create LongBuffer which the caller owns.
          */
         virtual LongBuffer* slice() const = 0;
@@ -309,32 +370,22 @@ namespace nio{
     public:  // Comparable
 
         /**
-         * Compares this object with the specified object for order. Returns a
-         * negative long longeger, zero, or a positive long longeger as this object is less
-         * than, equal to, or greater than the specified object.
-         * @param value - the Object to be compared.
-         * @returns a negative long longeger, zero, or a positive long longeger as this
-         * object is less than, equal to, or greater than the specified object.
+         * {@inheritDoc}
          */
         virtual int compareTo( const LongBuffer& value ) const;
 
         /**
-         * @return true if this value is considered equal to the passed value.
+         * {@inheritDoc}
          */
         virtual bool equals( const LongBuffer& value ) const;
 
         /**
-         * Compares equality between this object and the one passed.
-         * @param value - the value to be compared to this one.
-         * @return true if this object is equal to the one passed.
+         * {@inheritDoc}
          */
         virtual bool operator==( const LongBuffer& value ) const;
 
         /**
-         * Compares this object to another and returns true if this object
-         * is considered to be less than the one passed.  This
-         * @param value - the value to be compared to this one.
-         * @return true if this object is equal to the one passed.
+         * {@inheritDoc}
          */
         virtual bool operator<( const LongBuffer& value ) const;
 
@@ -342,41 +393,60 @@ namespace nio{
 
         /**
          * Allocates a new Double buffer.
-         * <p>
+         *
          * The new buffer's position will be zero, its limit will be its capacity, and
          * its mark will be undefined. It will have a backing array, and its array offset
          * will be zero.
-         * @param capacity - The size of the Double buffer in long longs
+         *
+         * @param capacity
+         *      The size of the Double buffer in long longs.
+         *
          * @returns the LongBuffer that was allocated, caller owns.
          */
-        static LongBuffer* allocate( std::size_t capacity );
+        static LongBuffer* allocate( int capacity )
+            throw( decaf::lang::exceptions::IllegalArgumentException );
 
         /**
          * Wraps the passed buffer with a new LongBuffer.
-         * <p>
+         *
          * The new buffer will be backed by the given long long array; that is, modifications
          * to the buffer will cause the array to be modified and vice versa. The new
          * buffer's capacity will be array.length, its position will be offset, its limit
          * will be offset + length, and its mark will be undefined. Its backing array
          * will be the given array, and its array offset will be zero.
-         * @param array - The array that will back the new buffer
-         * @param offset - The offset of the subarray to be used
-         * @param length - The length of the subarray to be used
+         *
+         * @param array
+         *      The array that will back the new buffer.
+         * @param size
+         *      The size of the passed in array.
+         * @param offset
+         *      The offset of the subarray to be used.
+         * @param length
+         *      The length of the subarray to be used.
+         *
          * @returns a new LongBuffer that is backed by buffer, caller owns.
-         */
-        static LongBuffer* wrap( long long* array, std::size_t offset, std::size_t length )
-            throw( lang::exceptions::NullPointerException );
+         *
+         * @throws NullPointerException if the array pointer is NULL.
+         * @throws IndexOutOfBoundsException if the preconditions of size, offset, or length
+         *         are not met.
+         */
+        static LongBuffer* wrap( long long* array, int size, int offset, int length )
+            throw( decaf::lang::exceptions::NullPointerException,
+                   decaf::lang::exceptions::IndexOutOfBoundsException );
 
         /**
          * Wraps the passed STL long long Vector in a LongBuffer.
-         * <p>
+         *
          * The new buffer will be backed by the given long long array; modifications to the
          * buffer will cause the array to be modified and vice versa. The new buffer's
          * capacity and limit will be buffer.size(), its position will be zero, and its
          * mark will be undefined. Its backing array will be the given array, and its
          * array offset will be zero.
-         * @param buffer - The vector that will back the new buffer, the vector must
-         * have been sized to the desired size already by calling vector.resize( N ).
+         *
+         * @param buffer
+         *      The vector that will back the new buffer, the vector must have been sized
+         *      to the desired size already by calling vector.resize( N ).
+         *
          * @returns a new LongBuffer that is backed by buffer, caller owns.
          */
         static LongBuffer* wrap( std::vector<long long>& buffer );