activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r925692 [9/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...
Date Sat, 20 Mar 2010 21:57:24 GMT
Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/nio/CharBuffer.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/nio/CharBuffer.h?rev=925692&r1=925691&r2=925692&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/nio/CharBuffer.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/nio/CharBuffer.h Sat Mar 20 21:57:20 2010
@@ -72,9 +72,14 @@ namespace nio{
          * Creates a CharBuffer 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 of the array, this is the limit we read and write to.
+         *
+         * @param capacity
+         *      The size of the array, this is the limit we read and write to.
+         *
+         * @throws IllegalArguementException if capacity is negative.
          */
-        CharBuffer( std::size_t capacity );
+        CharBuffer( int capacity )
+            throw( decaf::lang::exceptions::IllegalArgumentException );
 
     public:
 
@@ -86,9 +91,13 @@ namespace nio{
         virtual std::string toString() const;
 
         /**
-         * Appends the specified character to this buffer
-         * @param value - the char to append.
-         * @returns a reference to this modified CharBuffer
+         * Appends the specified character to this buffer.
+         *
+         * @param value
+         *      The char to append.
+         *
+         * @returns a reference to this modified CharBuffer.
+         *
          * @throws BufferOverflowException if there is no more space
          * @throws ReadOnlyBufferException if this Buffer is read only.
          */
@@ -98,8 +107,12 @@ namespace nio{
         /**
          * Appends the specified character sequence to this buffer.
          * If value is Null the the string "null" is appended to the buffer.
-         * @param value - the CharSequence to append.
+         *
+         * @param value
+         *      The CharSequence to append.
+         *
          * @returns a reference to this modified CharBuffer
+         *
          * @throws BufferOverflowException if there is no more space
          * @throws ReadOnlyBufferException if this Buffer is read only.
          */
@@ -109,27 +122,35 @@ namespace nio{
         /**
          * Appends a subsequence of the specified character sequence to this buffer
          * If value is Null the the string "null" is appended to the buffer.
-         * @param value - the CharSequence to append.
-         * @param start - the index to start appending from.
-         * @param end - the index to append to.
-         * @returns a reference to this modified CharBuffer
+         *
+         * @param value
+         *      The CharSequence to append.
+         * @param start
+         *      The index to start appending from.
+         * @param end
+         *      The index to append to.
+         *
+         * @returns a reference to this modified CharBuffer.
+         *
          * @throws BufferOverflowException if there is no more space
          * @throws ReadOnlyBufferException if this Buffer is read only.
          * @throws IndexOutOfBoundsException if start > end, or > length of sequence.
          */
-        CharBuffer& append( const lang::CharSequence* value, std::size_t start, std::size_t end )
+        CharBuffer& append( const lang::CharSequence* value, int start, int end )
             throw ( decaf::lang::exceptions::IndexOutOfBoundsException,
                     BufferOverflowException, ReadOnlyBufferException );
 
         /**
          * Returns the character 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.
          */
@@ -140,73 +161,82 @@ 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 char 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 char buffer which the caller then owns.
          */
         virtual CharBuffer* asReadOnlyBuffer() const = 0;
 
         /**
          * Reads the character at the given index relative to the current position.
-         * <p>
+         *
          * @param index - The index of the character to be read relative to position
-         * @returns The character at index position() + index
-         * @throws IndexOutOfBoundsException
+         *
+         * @returns The character at index position() + index.
+         *
+         * @throws IndexOutOfBoundsException if the index + the current position exceeds the
+         *         size of the buffer or the index is negative.
          */
-        char charAt( std::size_t index ) const
+        char charAt( int index ) const
             throw( decaf::lang::exceptions::IndexOutOfBoundsException );
 
         /**
          * 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 CharBuffer
+         *
+         * @returns a reference to this CharBuffer.
+         *
          * @throws ReadOnlyBufferException - If this buffer is read-only
          */
         virtual CharBuffer& compact() throw( ReadOnlyBufferException ) = 0;
 
         /**
          * Creates a new char 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 char Buffer which the caller owns.
          */
         virtual CharBuffer* duplicate() = 0;
@@ -214,75 +244,95 @@ namespace nio{
         /**
          * Relative get method. Reads the character at this buffer's current position,
          * and then increments the position.
-         * @returns the char at the current position
+         *
+         * @returns the char at the current position.
+         *
          * @throws BufferUnderflowException if there no more data to return
          */
         virtual char get() throw ( BufferUnderflowException ) = 0;
 
         /**
          * Absolute get method. Reads the char at the given index.
-         * @param index - the index in the Buffer where the char is to be read
-         * @returns the char 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 char is to be read.
+         *
+         * @returns the char that is located at the given index.
+         *
+         * @throws IndexOutOfBoundsException if index is not smaller than the
+         *         buffer's limit or is negative.
          */
-        virtual char get( std::size_t index ) const
-            throw ( lang::exceptions::IndexOutOfBoundsException ) = 0;
+        virtual char get( int index ) const
+            throw ( decaf::lang::exceptions::IndexOutOfBoundsException ) = 0;
 
         /**
          * Relative bulk get method.
-         * <p>
+         *
          * This method transfers chars 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 CharBuffer
-         * @throws BufferUnderflowException - If there are fewer than length chars
-         * remaining in this buffer
+         *
+         * @returns a reference to this CharBuffer.
+         *
+         * @throws BufferUnderflowException if there are fewer than length chars
+         *         remaining in this buffer.
          */
         CharBuffer& get( std::vector<char> buffer )
             throw ( BufferUnderflowException );
 
         /**
          * Relative bulk get method.
-         * <p>
+         *
          * This method transfers chars from this buffer into the given destination array.
          * If there are fewer chars 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 chars 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 chars
-         * remaining in this buffer
+         *
+         * @param buffer
+         *      The pointer to an allocated buffer to fill.
+         * @param size
+         *      The size of the buffer passed.
+         * @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 chars
+         *         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.
          */
-        CharBuffer& get( char* buffer, std::size_t offset, std::size_t length )
+        CharBuffer& get( char* buffer, int size, int offset, int length )
             throw( BufferUnderflowException,
-                   lang::exceptions::NullPointerException );
+                   decaf::lang::exceptions::NullPointerException,
+                   decaf::lang::exceptions::IndexOutOfBoundsException );
 
         /**
          * Tells whether or not this buffer is backed by an accessible char 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;
 
         /**
          * Returns the length of this character buffer.
+         *
          * @returns the length of this buffer from the position to the limit.
          */
-        std::size_t length() const {
+        int length() const {
             return this->remaining();
         }
 
@@ -291,49 +341,67 @@ namespace nio{
          * this buffer. If there are more chars remaining in the source buffer than in
          * this buffer, that is, if src.remaining() > remaining(), then no chars are
          * transferred and a BufferOverflowException is thrown.
-         * <p>
+         *
          * Otherwise, this method copies n = src.remaining() chars 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 chars 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 chars in the source buffer
-         * @throws IllegalArgumentException - If the source buffer is this buffer
-         * @throws ReadOnlyBufferException - If this buffer is read-only
+         *
+         * @returns a reference to this buffer.
+         *
+         * @throws BufferOverflowException if there is insufficient space in this buffer
+         *         for the remaining chars in the source buffer.
+         * @throws IllegalArgumentException if the source buffer is this buffer.
+         * @throws ReadOnlyBufferException if this buffer is read-only.
          */
         CharBuffer& put( CharBuffer& src )
             throw( BufferOverflowException, ReadOnlyBufferException,
-                   lang::exceptions::IllegalArgumentException );
+                   decaf::lang::exceptions::IllegalArgumentException );
 
         /**
          * This method transfers chars into this buffer from the given source array.
          * If there are more chars to be copied from the array than remain in this buffer,
          * that is, if length > remaining(), then no chars 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 chars are to be read
-         * @param offset- The offset within the array of the first char to be read;
-         * @param length - The number of chars 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 chars 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 chars 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.
          */
-        CharBuffer& put( const char* buffer, std::size_t offset, std::size_t length )
+        CharBuffer& put( const char* 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 char 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 CharBuffer
-         * @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 CharBuffer.
+         *
+         * @returns a reference to this buffer.
+         *
+         * @throws BufferOverflowException if there is insufficient space in this buffer.
+         * @throws ReadOnlyBufferException if this buffer is read-only.
          */
         CharBuffer& put( std::vector<char>& buffer )
             throw( BufferOverflowException, ReadOnlyBufferException );
@@ -341,63 +409,82 @@ namespace nio{
         /**
          * Writes the given char into this buffer at the current position, and then
          * increments the position.
-         * @param value - the char 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 char 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 CharBuffer& put( char value )
             throw( BufferOverflowException, ReadOnlyBufferException ) = 0;
 
         /**
          * Writes the given char into this buffer at the given index.
-         * @param index - position in the Buffer to write the data
-         * @param value - the char 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 char 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 CharBuffer& put( std::size_t index, char value )
-            throw( lang::exceptions::IndexOutOfBoundsException,
+        virtual CharBuffer& put( int index, char value )
+            throw( decaf::lang::exceptions::IndexOutOfBoundsException,
                    ReadOnlyBufferException ) = 0;
 
         /**
          * Relative bulk put method  (optional operation).
-         * <p>
+         *
          * This method transfers characters from the given string into this buffer. If
          * there are more characters to be copied from the string than remain in this
          * buffer, that is, if end - start > remaining(), then no characters are
          * transferred and a BufferOverflowException is thrown.
          * @returns a reference to this buffer
-         * <p>
+         *
          * Otherwise, this method copies n = end - start characters from the given string
          * into this buffer, starting at the given start index and at the current position
          * of this buffer. The position of this buffer is then incremented by n.
-         * @param src - the string to copy from
-         * @param start - position in src to start from
-         * @param end - the position in src to stop at
-         * @returns a reference to this CharBuffer
-         * @throws BufferOverflowException - If this buffer's current position is not
-         * @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 src
+         *      The string to copy from.
+         * @param start
+         *      The position in src to start from.
+         * @param end
+         *      The position in src to stop at.
+         *
+         * @returns a reference to this CharBuffer.
+         *
+         * @throws BufferOverflowException if this buffer's current position is not
+         * @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
          */
-        CharBuffer& put( const std::string& src, std::size_t start, std::size_t end )
+        CharBuffer& put( std::string& src, int start, int end )
             throw( BufferOverflowException, ReadOnlyBufferException,
                    decaf::lang::exceptions::IndexOutOfBoundsException );
 
         /**
          * Relative bulk put method  (optional operation).
-         * <p>
+         *
          * This method transfers the entire content of the given source string into this
          * buffer. An invocation of this method of the form dst.put(s) behaves in exactly
-         * the same way as the invocation
-         * @param src - the string to copy from
-         * @returns a reference to this CharBuffer
-         * @throws BufferOverflowException - If this buffer's current position is not
-         * @throws ReadOnlyBufferException - If this buffer is read-only
+         * the same way as the invocation.
+         *
+         * @param src
+         *      The string to copy from.
+         *
+         * @returns a reference to this CharBuffer.
+         *
+         * @throws BufferOverflowException if this buffer's current position is not.
+         * @throws ReadOnlyBufferException if this buffer is read-only.
          */
         CharBuffer& put( const std::string& src )
             throw( BufferOverflowException, ReadOnlyBufferException );
@@ -406,14 +493,18 @@ namespace nio{
          * Attempts to read characters into the specified character buffer. The buffer is
          * used as a repository of characters as-is: the only changes made are the results
          * of a put operation. No flipping or rewinding of the buffer is performed.
-         * @param target - the buffer to read characters into
+         *
+         * @param target
+         *      The buffer to read characters into
+         *
          * @returns The number of characters added to the buffer, or string::npos if this
-         * source of characters is at its end
-         * @throws NullPointerException - If target is Null
-         * @throws IllegalArgumentException - If target is this
-         * @throws ReadOnlyBufferException - If this buffer is read-only
+         *          source of characters is at its end
+         *
+         * @throws NullPointerException if target is Null.
+         * @throws IllegalArgumentException if target is this CharBuffer.
+         * @throws ReadOnlyBufferException if this buffer is in read-only mode.
          */
-        virtual std::size_t read( CharBuffer* target )
+        virtual int read( CharBuffer* target )
             throw ( decaf::lang::exceptions::NullPointerException,
                     decaf::lang::exceptions::IllegalArgumentException,
                     ReadOnlyBufferException );
@@ -421,22 +512,26 @@ namespace nio{
         /**
          * Creates a new character buffer that represents the specified subsequence of
          * this buffer, relative to the current position.
-         * <p>
+         *
          * The new buffer will share this buffer's content; that is, if the content of
          * this buffer is mutable then modifications to one buffer will cause the other
          * to be modified. The new buffer's capacity will be that of this buffer, its
          * position will be position() + start, and its limit will be position() + end.
          * The new Buffer will be read-only if, and only if, this buffer is read-only.
-         * @param start - The index, relative to the current position, of the first
-         * character in the subsequence; must be non-negative and no larger than
-         * remaining()
-         * @param end - The index, relative to the current position, of the character
-         * following the last character in the subsequence; must be no smaller than start
-         * and no larger than remaining()
-         * @return The new character buffer, caller owns
-         * @throws IndexOutOfBoundsException - If the preconditions on start and end fail
+         *
+         * @param start
+         *      The index, relative to the current position, of the first character in
+         *      the subsequence; must be non-negative and no larger than remaining().
+         * @param end
+         *      The index, relative to the current position, of the character following the
+         *      last character in the subsequence; must be no smaller than start and no
+         *      larger than remaining().
+         *
+         * @return The new character buffer, caller owns.
+         *
+         * @throws IndexOutOfBoundsException if the preconditions on start and end fail.
          */
-        virtual lang::CharSequence* subSequence( std::size_t start, std::size_t end ) const
+        virtual lang::CharSequence* subSequence( int start, int end ) const
             throw ( decaf::lang::exceptions::IndexOutOfBoundsException ) = 0;
 
         /**
@@ -445,10 +540,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 CharBuffer which the caller owns.
          */
         virtual CharBuffer* slice() const = 0;
@@ -456,32 +552,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 CharBuffer& value ) const;
 
         /**
-         * @return true if this value is considered equal to the passed value.
+         * {@inheritDoc}
          */
         virtual bool equals( const CharBuffer& 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 CharBuffer& 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 CharBuffer& value ) const;
 
@@ -489,75 +575,104 @@ namespace nio{
 
         /**
          * Allocates a new character 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 Char buffer in chars ( 1 byte ).
+         *
+         * @param capacity
+         *      The size of the Char buffer in chars ( 1 byte ).
+         *
          * @returns the CharBuffer that was allocated, caller owns.
+         *
+         * @throws IndexOutOfBoundsException if capacity is negative.
          */
-        static CharBuffer* allocate( std::size_t capacity );
+        static CharBuffer* allocate( int capacity )
+            throw( decaf::lang::exceptions::IndexOutOfBoundsException );
 
         /**
          * Wraps the passed buffer with a new CharBuffer.
-         * <p>
+         *
          * The new buffer will be backed by the given char 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 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 CharBuffer that is backed by buffer, caller owns.
+         *
+         * @throws NullPointerException if the array pointer is Null.
+         * @throws IndexOutOfBoundsException if capacity is negative.
          */
-        static CharBuffer* wrap( char* array, std::size_t offset, std::size_t length )
-            throw( lang::exceptions::NullPointerException );
+        static CharBuffer* wrap( char* array, int size, int offset, int length )
+            throw( decaf::lang::exceptions::NullPointerException,
+                   decaf::lang::exceptions::IndexOutOfBoundsException );
 
         /**
          * Wraps the passed STL char Vector in a CharBuffer.
-         * <p>
+         *
          * The new buffer will be backed by the given char 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 CharBuffer that is backed by buffer, caller owns.
          */
         static CharBuffer* wrap( std::vector<char>& buffer );
 
         /**
          * Wraps a character sequence into a buffer.
-         * <p>
+         *
          * The content of the new, read-only buffer will be the content of the given
          * character sequence. The buffer's capacity will be csq.length(), its position
          * will be start, its limit will be end, and its mark will be undefined.
-         * @param csq - The CharSequence that will back the new buffer
-         * @param start - The index of the first character to be used; must be non-
-         * negative and no larger than csq.length(). The new buffer's position will be
-         * set to this value.
-         * @param end - The index of the character following the last character to be
-         * used; must be no smaller than start and no larger than
-         * @returns a nre ReadOnly CharBuffer, caller owns
+         *
+         * @param csq
+         *      The CharSequence that will back the new buffer
+         * @param start
+         *      The index of the first character to be used; must be non-negative and no
+         *      larger than csq.length(). The new buffer's position will be set to this value.
+         * @param end
+         *      The index of the character following the last character to be used; must be
+         *      no smaller than start and no larger than the size of the sequence.
+         *
+         * @returns a ReadOnly CharBuffer, caller owns the returned pointer.
+         *
          * @throws NullPointerException if csq is null.
          * @throws IndexOutOfBoundsException if the preconditions on start and end fail
          */
 // TODO
-//        static CharBuffer* wrap( lang::CharSequence* csq, std::size_t start, std::size_t end )
-//            throw( lang::exceptions::NullPointerException );
+//        static CharBuffer* wrap( lang::CharSequence* csq, int start, int end )
+//            throw( decaf::lang::exceptions::NullPointerException,
+//                   decaf::lang::exceptions::IndexOutOfBoundsException );
 
         /**
          * Wraps a full CharSequence into a buffer.
-         * <p>
+         *
          * The content of the new, read-only buffer will be the content of the given
          * string. The new buffer's capacity and limit will be csq.length(), its position
          * will be zero, and its mark will be undefined.
-         * <p>
-         * @param csq - The character sequence from which the new character buffer is to
-         * be created, cannot be null
+         *
+         * @param csq
+         *      The character sequence from which the new character buffer is to
+         *      be created, cannot be null.
+         *
          * @returns the newly created CharBuffer, caller owns.
+         *
          * @throws NullPointerException if csq is null.
          */
 // TODO

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/nio/DoubleBuffer.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/nio/DoubleBuffer.cpp?rev=925692&r1=925691&r2=925692&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/nio/DoubleBuffer.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/nio/DoubleBuffer.cpp Sat Mar 20 21:57:20 2010
@@ -29,25 +29,26 @@ using namespace decaf::lang;
 using namespace decaf::lang::exceptions;
 
 ////////////////////////////////////////////////////////////////////////////////
-DoubleBuffer::DoubleBuffer( std::size_t capacity )
- :  Buffer( capacity ) {
+DoubleBuffer::DoubleBuffer( int capacity )
+    throw( decaf::lang::exceptions::IllegalArgumentException ) : Buffer( capacity ) {
 
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-DoubleBuffer* DoubleBuffer::allocate( std::size_t capacity ) {
+DoubleBuffer* DoubleBuffer::allocate( int capacity )
+    throw( decaf::lang::exceptions::IllegalArgumentException ) {
 
     try{
-
         return BufferFactory::createDoubleBuffer( capacity );
     }
-    DECAF_CATCH_RETHROW( Exception )
-    DECAF_CATCHALL_THROW( Exception )
+    DECAF_CATCH_RETHROW( IllegalArgumentException )
+    DECAF_CATCHALL_THROW( IllegalArgumentException )
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-DoubleBuffer* DoubleBuffer::wrap( double* buffer, std::size_t offset, std::size_t length )
-    throw( lang::exceptions::NullPointerException ) {
+DoubleBuffer* DoubleBuffer::wrap( double* buffer, int size, int offset, int length )
+    throw( decaf::lang::exceptions::NullPointerException,
+           decaf::lang::exceptions::IndexOutOfBoundsException ) {
 
     try{
 
@@ -57,9 +58,10 @@ DoubleBuffer* DoubleBuffer::wrap( double
                 "DoubleBuffer::wrap - Passed Buffer is Null.");
         }
 
-        return BufferFactory::createDoubleBuffer( buffer, offset, length );
+        return BufferFactory::createDoubleBuffer( buffer, size, offset, length );
     }
     DECAF_CATCH_RETHROW( NullPointerException )
+    DECAF_CATCH_RETHROW( IndexOutOfBoundsException )
     DECAF_CATCH_EXCEPTION_CONVERT( Exception, NullPointerException )
     DECAF_CATCHALL_THROW( NullPointerException )
 }
@@ -75,7 +77,7 @@ DoubleBuffer* DoubleBuffer::wrap( std::v
                 "DoubleBuffer::wrap - Passed Buffer is Empty.");
         }
 
-        return BufferFactory::createDoubleBuffer( &buffer[0], 0, buffer.size() );
+        return BufferFactory::createDoubleBuffer( &buffer[0], (int)buffer.size(), 0, (int)buffer.size() );
     }
     DECAF_CATCH_RETHROW( NullPointerException )
     DECAF_CATCH_EXCEPTION_CONVERT( Exception, NullPointerException )
@@ -102,7 +104,7 @@ DoubleBuffer& DoubleBuffer::get( std::ve
     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 +114,10 @@ DoubleBuffer& DoubleBuffer::get( std::ve
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-DoubleBuffer& DoubleBuffer::get( double* buffer, std::size_t offset, std::size_t length )
+DoubleBuffer& DoubleBuffer::get( double* buffer, int size, int offset, int length )
     throw( BufferUnderflowException,
-           lang::exceptions::NullPointerException ) {
+           decaf::lang::exceptions::IndexOutOfBoundsException,
+           decaf::lang::exceptions::NullPointerException ) {
 
     try{
 
@@ -128,19 +131,26 @@ DoubleBuffer& DoubleBuffer::get( double*
                 "DoubleBuffer::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__,
                 "DoubleBuffer::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 )
 }
@@ -148,7 +158,7 @@ DoubleBuffer& DoubleBuffer::get( double*
 ////////////////////////////////////////////////////////////////////////////////
 DoubleBuffer& DoubleBuffer::put( DoubleBuffer& src )
     throw( BufferOverflowException, ReadOnlyBufferException,
-           lang::exceptions::IllegalArgumentException ) {
+           decaf::lang::exceptions::IllegalArgumentException ) {
 
     try{
 
@@ -184,9 +194,10 @@ DoubleBuffer& DoubleBuffer::put( DoubleB
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-DoubleBuffer& DoubleBuffer::put( const double* buffer, std::size_t offset, std::size_t length )
+DoubleBuffer& DoubleBuffer::put( const double* buffer, int size, int offset, int length )
     throw( BufferOverflowException, ReadOnlyBufferException,
-           lang::exceptions::NullPointerException ) {
+           decaf::lang::exceptions::IndexOutOfBoundsException,
+           decaf::lang::exceptions::NullPointerException ) {
 
     try{
 
@@ -206,6 +217,11 @@ DoubleBuffer& DoubleBuffer::put( const d
                 "DoubleBuffer::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 +229,7 @@ DoubleBuffer& DoubleBuffer::put( const d
         }
 
         // 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 +238,7 @@ DoubleBuffer& DoubleBuffer::put( const d
     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 +250,7 @@ DoubleBuffer& DoubleBuffer::put( std::ve
     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 +266,8 @@ int DoubleBuffer::compareTo( const Doubl
 
     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();
     double thisByte, otherByte;
 
     while( compareRemaining > 0 ) {
@@ -281,8 +298,8 @@ bool DoubleBuffer::equals( const DoubleB
         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/DoubleBuffer.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/nio/DoubleBuffer.h?rev=925692&r1=925691&r2=925692&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/nio/DoubleBuffer.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/nio/DoubleBuffer.h Sat Mar 20 21:57:20 2010
@@ -46,18 +46,25 @@ namespace nio{
      * Methods in this class that do not otherwise have a value to return are specified
      * to return the buffer upon which they are invoked. This allows method invocations
      * to be chained.
+     *
+     * @since 1.0
      */
     class DECAF_API DoubleBuffer : public Buffer,
                                    public lang::Comparable<DoubleBuffer> {
     protected:
 
         /**
-        * Creates a DoubleBuffer 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
-        */
-        DoubleBuffer( std::size_t capacity );
+         * Creates a DoubleBuffer 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 doubles
+         *
+         * @throws IllegalArguementException if capacity is negative.
+         */
+        DoubleBuffer( int capacity )
+            throw( decaf::lang::exceptions::IllegalArgumentException );
 
     public:
 
@@ -70,13 +77,15 @@ namespace nio{
 
         /**
          * Returns the double 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 +96,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 double 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 double buffer which the caller then owns.
          */
         virtual DoubleBuffer* 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 DoubleBuffer
-         * @throws ReadOnlyBufferException - If this buffer is read-only
+         *
+         * @returns a reference to this DoubleBuffer.
+         *
+         * @throws ReadOnlyBufferException if this buffer is read-only.
          */
         virtual DoubleBuffer& compact() throw( ReadOnlyBufferException ) = 0;
 
         /**
          * Creates a new double 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 double Buffer which the caller owns.
          */
         virtual DoubleBuffer* duplicate() = 0;
@@ -151,67 +166,86 @@ namespace nio{
         /**
          * Relative get method. Reads the value at this buffer's current position,
          * and then increments the position.
-         * @returns the double at the current position
-         * @throws BufferUnderflowException if there no more data to return
+         *
+         * @returns the double at the current position.
+         *
+         * @throws BufferUnderflowException if there no more data to return.
          */
         virtual double get() throw ( BufferUnderflowException ) = 0;
 
         /**
          * Absolute get method. Reads the value at the given index.
-         * @param index - the index in the Buffer where the double is to be read
-         * @returns the double 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 double is to be read.
+         *
+         * @returns the double that is located at the given index.
+         *
+         * @throws IndexOutOfBoundsException if index is not smaller than the
+         *         buffer's limit
          */
-        virtual double get( std::size_t index ) const
+        virtual double get( int index ) const
             throw ( 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 doubles
-         * remaining in this buffer
+         *
+         * @returns a reference to this Buffer.
+         *
+         * @throws BufferUnderflowException iIf there are fewer than length doubles
+         *         remaining in this buffer
          */
         DoubleBuffer& get( std::vector<double> buffer )
             throw ( BufferUnderflowException );
 
         /**
          * Relative bulk get method.
-         * <p>
+         *
          * This method transfers doubles from this buffer into the given destination array.
          * If there are fewer doubles 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 doubles 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 doubles
-         * remaining in this buffer
+         *
+         * @param buffer
+         *      The pointer to an allocated buffer to fill.
+         * @param size
+         *      The size of the buffer passed.
+         * @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 doubles
+         *         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.
          */
-        DoubleBuffer& get( double* buffer, std::size_t offset, std::size_t length )
+        DoubleBuffer& get( double* 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 double 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 +254,68 @@ namespace nio{
          * this buffer. If there are more doubles remaining in the source buffer than in
          * this buffer, that is, if src.remaining() > remaining(), then no doubles are
          * transferred and a BufferOverflowException is thrown.
-         * <p>
+         *
          * Otherwise, this method copies n = src.remaining() doubles 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 doubles 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 doubles 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 doubles 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 doubles in the source buffer
+         * @throws IllegalArgumentException if the source buffer is this buffer.
+         * @throws ReadOnlyBufferException if this buffer is read-only.
          */
         DoubleBuffer& put( DoubleBuffer& src )
             throw( BufferOverflowException, ReadOnlyBufferException,
-                   lang::exceptions::IllegalArgumentException );
+                   decaf::lang::exceptions::IllegalArgumentException );
 
         /**
          * This method transfers doubles into this buffer from the given source array.
          * If there are more doubles to be copied from the array than remain in this buffer,
          * that is, if length > remaining(), then no doubles 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 doubles are to be read
-         * @param offset- The offset within the array of the first double to be read;
-         * @param length - The number of doubles 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 doubles 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 doubles 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.
          */
-        DoubleBuffer& put( const double* buffer, std::size_t offset, std::size_t length )
+        DoubleBuffer& put( const double* 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 doubles 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 DoubleBuffer
-         * @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 DoubleBuffer.
+         *
+         * @returns a reference to this buffer.
+         *
+         * @throws BufferOverflowException if there is insufficient space in this buffer.
+         * @throws ReadOnlyBufferException if this buffer is read-only.
          */
         DoubleBuffer& put( std::vector<double>& buffer )
             throw( BufferOverflowException, ReadOnlyBufferException );
@@ -270,26 +323,35 @@ namespace nio{
         /**
          * Writes the given doubles into this buffer at the current position, and then
          * increments the position.
-         * @param value - the doubles 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 doubles 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 DoubleBuffer& put( double value )
             throw( BufferOverflowException, ReadOnlyBufferException ) = 0;
 
         /**
          * Writes the given doubles into this buffer at the given index.
-         * @param index - position in the Buffer to write the data
-         * @param value - the doubles to write.
+         *
+         * @param index
+         *      The position in the Buffer to write the data.
+         * @param value
+         *      The doubles 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
+         *
+         * @throws IndexOutOfBoundsException if index greater than the buffer's limit
+         *         minus the size of the type being written, or the index is negative.
+         * @throws ReadOnlyBufferException if this buffer is read-only.
          */
-        virtual DoubleBuffer& put( std::size_t index, double value )
-            throw( lang::exceptions::IndexOutOfBoundsException,
+        virtual DoubleBuffer& put( int index, double value )
+            throw( decaf::lang::exceptions::IndexOutOfBoundsException,
                    ReadOnlyBufferException ) = 0;
 
         /**
@@ -298,10 +360,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 DoubleBuffer which the caller owns.
          */
         virtual DoubleBuffer* slice() const = 0;
@@ -309,74 +372,85 @@ 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 DoubleBuffer& value ) const;
 
         /**
-         * @return true if this value is considered equal to the passed value.
+         * {@inheritDoc}
          */
         virtual bool equals( const DoubleBuffer& 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 DoubleBuffer& 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 DoubleBuffer& value ) const;
 
     public:   // Statics
 
         /**
-         * Allocates a new Double buffer.
-         * <p>
+         * Allocates a new DoubleBuffer.
+         *
          * 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 doubles
+         *
+         * @param capacity
+         *      The size of the Double buffer in doubles.
+         *
          * @returns the DoubleBuffer that was allocated, caller owns.
+         *
+         * @throws IllegalArgumentException is the capacity value is negative.
          */
-        static DoubleBuffer* allocate( std::size_t capacity );
+        static DoubleBuffer* allocate( int capacity )
+            throw( decaf::lang::exceptions::IllegalArgumentException );
 
         /**
          * Wraps the passed buffer with a new DoubleBuffer.
-         * <p>
+         *
          * The new buffer will be backed by the given double 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 DoubleBuffer that is backed by buffer, caller owns.
-         */
-        static DoubleBuffer* wrap( double* 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 DoubleBuffer* wrap( double* array, int size, int offset, int length )
+            throw( decaf::lang::exceptions::NullPointerException,
+                   decaf::lang::exceptions::IndexOutOfBoundsException );
 
         /**
          * Wraps the passed STL double Vector in a DoubleBuffer.
-         * <p>
+         *
          * The new buffer will be backed by the given double 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 DoubleBuffer that is backed by buffer, caller owns.
          */
         static DoubleBuffer* wrap( std::vector<double>& buffer );

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/nio/FloatBuffer.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/nio/FloatBuffer.cpp?rev=925692&r1=925691&r2=925692&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/nio/FloatBuffer.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/nio/FloatBuffer.cpp Sat Mar 20 21:57:20 2010
@@ -29,16 +29,16 @@ using namespace decaf::lang;
 using namespace decaf::lang::exceptions;
 
 ////////////////////////////////////////////////////////////////////////////////
-FloatBuffer::FloatBuffer( std::size_t capacity )
- :  Buffer( capacity ) {
+FloatBuffer::FloatBuffer( int capacity )
+    throw( decaf::lang::exceptions::IllegalArgumentException ) :  Buffer( capacity ) {
 
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-FloatBuffer* FloatBuffer::allocate( std::size_t capacity ) {
+FloatBuffer* FloatBuffer::allocate( int capacity )
+    throw( decaf::lang::exceptions::IllegalArgumentException ) {
 
     try{
-
         return BufferFactory::createFloatBuffer( capacity );
     }
     DECAF_CATCH_RETHROW( Exception )
@@ -46,8 +46,9 @@ FloatBuffer* FloatBuffer::allocate( std:
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-FloatBuffer* FloatBuffer::wrap( float* buffer, std::size_t offset, std::size_t length )
-    throw( lang::exceptions::NullPointerException ) {
+FloatBuffer* FloatBuffer::wrap( float* buffer, int size, int offset, int length )
+    throw( decaf::lang::exceptions::IndexOutOfBoundsException,
+           decaf::lang::exceptions::NullPointerException ) {
 
     try{
 
@@ -57,7 +58,7 @@ FloatBuffer* FloatBuffer::wrap( float* b
                 "FloatBuffer::wrap - Passed Buffer is Null.");
         }
 
-        return BufferFactory::createFloatBuffer( buffer, offset, length );
+        return BufferFactory::createFloatBuffer( buffer, size, offset, length );
     }
     DECAF_CATCH_RETHROW( NullPointerException )
     DECAF_CATCH_EXCEPTION_CONVERT( Exception, NullPointerException )
@@ -75,7 +76,7 @@ FloatBuffer* FloatBuffer::wrap( std::vec
                 "FloatBuffer::wrap - Passed Buffer is Empty.");
         }
 
-        return BufferFactory::createFloatBuffer( &buffer[0], 0, buffer.size() );
+        return BufferFactory::createFloatBuffer( &buffer[0], (int)buffer.size(), 0, (int)buffer.size() );
     }
     DECAF_CATCH_RETHROW( NullPointerException )
     DECAF_CATCH_EXCEPTION_CONVERT( Exception, NullPointerException )
@@ -102,7 +103,7 @@ FloatBuffer& FloatBuffer::get( std::vect
     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 @@ FloatBuffer& FloatBuffer::get( std::vect
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-FloatBuffer& FloatBuffer::get( float* buffer, std::size_t offset, std::size_t length )
+FloatBuffer& FloatBuffer::get( float* 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 @@ FloatBuffer& FloatBuffer::get( float* bu
                 "FloatBuffer::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__,
                 "FloatBuffer::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 @@ FloatBuffer& FloatBuffer::put( FloatBuff
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-FloatBuffer& FloatBuffer::put( const float* buffer, std::size_t offset, std::size_t length )
+FloatBuffer& 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 ) {
 
     try{
 
@@ -206,6 +216,11 @@ FloatBuffer& FloatBuffer::put( const flo
                 "FloatBuffer::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 @@ FloatBuffer& FloatBuffer::put( const flo
         }
 
         // 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 @@ FloatBuffer& FloatBuffer::put( const flo
     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 @@ FloatBuffer& FloatBuffer::put( std::vect
     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 FloatBuffer::compareTo( const FloatB
 
     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();
     float thisVal, otherVal;
 
     while( compareRemaining > 0 ) {
@@ -281,8 +297,8 @@ bool FloatBuffer::equals( const FloatBuf
         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() ) ) {



Mime
View raw message