activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r925692 [2/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/internal/nio/ByteArrayBuffer.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/nio/ByteArrayBuffer.h?rev=925692&r1=925691&r2=925692&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/nio/ByteArrayBuffer.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/nio/ByteArrayBuffer.h Sat Mar 20 21:57:20 2010
@@ -21,10 +21,11 @@
 #include <decaf/nio/ByteBuffer.h>
 #include <decaf/lang/exceptions/NullPointerException.h>
 #include <decaf/lang/exceptions/IndexOutOfBoundsException.h>
+#include <decaf/lang/exceptions/IllegalArgumentException.h>
 #include <decaf/nio/BufferUnderflowException.h>
 #include <decaf/nio/BufferOverflowException.h>
 #include <decaf/nio/ReadOnlyBufferException.h>
-#include <decaf/internal/nio/ByteArrayPerspective.h>
+#include <decaf/internal/util/ByteArrayAdapter.h>
 
 #include <decaf/nio/CharBuffer.h>
 #include <decaf/nio/DoubleBuffer.h>
@@ -33,10 +34,14 @@
 #include <decaf/nio/IntBuffer.h>
 #include <decaf/nio/LongBuffer.h>
 
+#include <decaf/lang/Pointer.h>
+
 namespace decaf{
 namespace internal{
 namespace nio{
 
+    using decaf::internal::util::ByteArrayAdapter;
+
     /**
      * This class defines six categories of operations upon byte buffers:
      *
@@ -94,6 +99,7 @@ namespace nio{
      *   contiguous sequences of values between a buffer and an array or some other
      *   buffer of the same type; and
      *
+     * @since 1.0
      */
     class DECAF_API ByteArrayBuffer : public decaf::nio::ByteBuffer {
     private:
@@ -102,10 +108,13 @@ namespace nio{
         bool readOnly;
 
         // The reference array object that backs this buffer.
-        internal::nio::ByteArrayPerspective* _array;
+        decaf::lang::Pointer<ByteArrayAdapter> _array;
 
         // Offset into the array that we are to start from
-        std::size_t offset;
+        int offset;
+
+        // The number of bytes we are limited to.
+        int length;
 
     public:
 
@@ -113,591 +122,341 @@ namespace nio{
          * Creates a ByteArrayBuffer 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 readOnly - should this buffer be read-only, default as false
-         */
-        ByteArrayBuffer( std::size_t capacity, bool readOnly = false );
-
-        /**
-         * Creates a ByteArrayBuffer object that wraps the given array.  If the own flag
-         * is set then it will delete this array when this object is deleted.
-         * @param array - array to wrap
-         * @param offset - the position that is this buffers start pos.
-         * @param capacity - size of the array, this is the limit we read and write to.
-         * @param readOnly - should this buffer be read-only, default as false
+         *
+         * @param capacity
+         *      The size of the array, this is the limit we read and write to.
+         * @param readOnly
+         *      Should this buffer be read-only, default as false
+         *
+         * @throws IllegalArguementException if the capacity value is negative.
+         */
+        ByteArrayBuffer( int capacity, bool readOnly = false )
+            throw( decaf::lang::exceptions::IllegalArgumentException );
+
+        /**
+         * Creates a ByteArrayBuffer object that wraps the given array.
+         *
+         * @param array
+         *      The array to wrap.
+         * @param size
+         *      The size of the array passed.
+         * @param offset
+         *      The position that is this buffers start position.
+         * @param length
+         *      The size of the sub-array, this is the limit we read and write to.
+         * @param readOnly
+         *      Should this buffer be read-only, default as false.
+         *
          * @throws NullPointerException if buffer is NULL
+         * @throws IndexOutOfBoundsException if the preconditions of size, offset and
+         *         length are violated.
          */
-        ByteArrayBuffer( unsigned char* array, std::size_t offset,
-                         std::size_t capacity, bool readOnly = false )
-            throw( decaf::lang::exceptions::NullPointerException );
+        ByteArrayBuffer( unsigned char* array, int size, int offset, int length,
+                         bool readOnly = false )
+            throw( decaf::lang::exceptions::NullPointerException,
+                   decaf::lang::exceptions::IndexOutOfBoundsException );
 
         /**
-         * Creates a byte buffer that wraps the passed ByteArrayPerspective and
+         * Creates a byte buffer that wraps the passed ByteArrayAdapter and
          * start at the given offset.  The capacity and limit of the new ByteArrayBuffer
          * will be that of the remaining capacity of the passed buffer.
-         * @param array - the ByteArrayPerspective to wrap
-         * @param offset - the offset into array where the buffer starts
-         * @param length - the length of the array we are wrapping or limit.
-         * @param readOnly - is this a readOnly buffer.
+         *
+         * @param array
+         *      The ByteArrayAdapter to wrap
+         * @param offset
+         *      The offset into array where the buffer starts
+         * @param length
+         *      The length of the array we are wrapping or limit.
+         * @param readOnly
+         *      Boolean indicating if this a readOnly buffer.
+         *
+         * @throws NullPointerException if array is NULL
          * @throws IndexOutOfBoundsException if offset is greater than array capacity.
          */
-        ByteArrayBuffer( ByteArrayPerspective& array,
-                         std::size_t offset, std::size_t length,
-                         bool readOnly = false )
-            throw( decaf::lang::exceptions::IndexOutOfBoundsException );
+        ByteArrayBuffer( const decaf::lang::Pointer<ByteArrayAdapter>& array,
+                         int offset, int length, bool readOnly = false )
+            throw( decaf::lang::exceptions::NullPointerException,
+                   decaf::lang::exceptions::IndexOutOfBoundsException );
 
         /**
          * Create a ByteArrayBuffer that mirrors this one, meaning it shares a
-         * reference to this buffers ByteArrayPerspective and when changes
+         * reference to this buffers ByteArrayAdapter and when changes
          * are made to that data it is reflected in both.
-         * @param other - the ByteArrayBuffer this one is to mirror.
+         *
+         * @param other
+         *      The ByteArrayBuffer this one is to mirror.
          */
         ByteArrayBuffer( const ByteArrayBuffer& other );
 
         virtual ~ByteArrayBuffer();
 
+    public:
+
         /**
-         * Tells whether or not this buffer is read-only.
-         * @returns true if, and only if, this buffer is read-only
+         * {@inheritDoc}
          */
         virtual bool isReadOnly() const {
             return this->readOnly;
         }
 
         /**
-         * Returns the byte array that backs this buffer
-         * <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
-         * @throws ReadOnlyBufferException - If this buffer is backed by an array but
-         * is read-only
-         * @throws UnsupportedOperationException - If this buffer is not backed by an
-         * accessible array
+         * {@inheritDoc}
          */
         virtual unsigned char* array()
             throw( decaf::nio::ReadOnlyBufferException,
                    decaf::lang::exceptions::UnsupportedOperationException );
 
         /**
-         * Returns the offset within this buffer's backing array of the first element
-         * of the buffer.
-         * <p>
-         * If this buffer is backed by an array then buffer position p corresponds to
-         * array index p + arrayOffset().
-         * <p>
-         * Invoke the hasArray method before invoking this method in order to ensure
-         * that this buffer has an accessible backing array.
-         * @returns The offset within this buffer's array of the first element of
-         * the buffer
-         * @throws ReadOnlyBufferException - If this buffer is backed by an array but
-         * is read-only
-         * @throws UnsupportedOperationException - If this buffer is not backed by an
-         * accessible array
+         * {@inheritDoc}
          */
-        virtual std::size_t arrayOffset() const
+        virtual int arrayOffset() const
             throw( decaf::nio::ReadOnlyBufferException,
-                   lang::exceptions::UnsupportedOperationException );
+                   decaf::lang::exceptions::UnsupportedOperationException );
 
         /**
-         * Tells whether or not this buffer is backed by an accessible byte 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
+         * {@inheritDoc}
          */
         virtual bool hasArray() const { return true; }
 
     public:   // Abstract Methods
 
         /**
-         * Creates a view of this byte buffer as a char buffer.
-         * <p>
-         * The content of the new buffer will start at this buffer's 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 new Char Buffer, which the caller then owns.
+         * {@inheritDoc}
          */
         virtual decaf::nio::CharBuffer* asCharBuffer() const { return NULL; } //TODO
 
         /**
-         * Creates a view of this byte buffer as a double buffer.
-         * <p>
-         * The content of the new buffer will start at this buffer's 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 divided by eight, and its mark
-         * will be undefined. The new buffer will be read-only if, and only if, this
-         * buffer is read-only.
-         * @returns the new double Buffer, which the caller then owns.
+         * {@inheritDoc}
          */
         virtual decaf::nio::DoubleBuffer* asDoubleBuffer() const { return NULL; } //TODO
 
         /**
-         * Creates a view of this byte buffer as a float buffer.
-         * <p>
-         * The content of the new buffer will start at this buffer's 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 divided by four, and its mark
-         * will be undefined. The new buffer will be read-only if, and only if, this
-         * buffer is read-only.
-         * @returns the new float Buffer, which the caller then owns.
+         * {@inheritDoc}
          */
         virtual decaf::nio::FloatBuffer* asFloatBuffer() const { return NULL; } //TODO
 
         /**
-         * Creates a view of this byte buffer as a int buffer.
-         * <p>
-         * The content of the new buffer will start at this buffer's 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 divided by four, and its mark
-         * will be undefined. The new buffer will be read-only if, and only if, this
-         * buffer is read-only.
-         * @returns the new int Buffer, which the caller then owns.
+         * {@inheritDoc}
          */
         virtual decaf::nio::IntBuffer* asIntBuffer() const { return NULL; } //TODO
 
         /**
-         * Creates a view of this byte buffer as a long buffer.
-         * <p>
-         * The content of the new buffer will start at this buffer's 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 divided by eight, and its mark
-         * will be undefined. The new buffer will be read-only if, and only if, this
-         * buffer is read-only.
-         * @returns the new long Buffer, which the caller then owns.
+         * {@inheritDoc}
          */
         virtual decaf::nio::LongBuffer* asLongBuffer() const { return NULL; } //TODO
 
         /**
-         * Creates a view of this byte buffer as a short buffer.
-         * <p>
-         * The content of the new buffer will start at this buffer's 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 divided by two, and its mark
-         * will be undefined. The new buffer will be read-only if, and only if, this
-         * buffer is read-only.
-         * @returns the new short Buffer, which the caller then owns.
+         * {@inheritDoc}
          */
         virtual decaf::nio::ShortBuffer* asShortBuffer() const { return NULL; } //TODO
 
         /**
-         * Creates a new, read-only byte 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 byte buffer which the caller then owns.
+         * {@inheritDoc}
          */
         virtual ByteArrayBuffer* asReadOnlyBuffer() const;
 
         /**
-         * 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 ByteArrayBuffer
-         * @throws ReadOnlyBufferException - If this buffer is read-only
+         * {@inheritDoc}
          */
         virtual ByteArrayBuffer& compact() throw( decaf::nio::ReadOnlyBufferException );
 
         /**
-         * Creates a new byte 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 Byte Buffer which the caller owns.
+         * {@inheritDoc}
          */
         virtual ByteArrayBuffer* duplicate();
 
         /**
-         * Relative get method. Reads the byte at this buffer's current position, and
-         * then increments the position.
-         * @returns The byte at the buffer's current position
-         * @throws BufferUnderflowException - If the buffer's current position is not
-         * smaller than its limit
+         * {@inheritDoc}
          */
         virtual unsigned char get() const throw( decaf::nio::BufferUnderflowException );
 
         /**
-         * Absolute get method. Reads the byte at the given index.
-         * @param index - the index in the Buffer where the byte is to be read
-         * @returns the byte that is located at the given index
-         * @throws IndexOutOfBoundsException - If index is not smaller than the
-         * buffer's limit
-         */
-        virtual unsigned char get( std::size_t index ) const
-            throw ( lang::exceptions::IndexOutOfBoundsException );
+         * {@inheritDoc}
+         */
+        virtual unsigned char get( int index ) const
+            throw ( decaf::lang::exceptions::IndexOutOfBoundsException );
 
         /**
-         * Reads the next byte at this buffer's current position, and then increments
-         * the position by one
-         * @returns the next char in the buffer..
-         * @throws BufferUnderflowException - If there are no more bytes remaining in
-         * this buffer, meaning we have reached the set limit.
+         * {@inheritDoc}
          */
         virtual char getChar() throw( decaf::nio::BufferUnderflowException ) {
             return (char)this->get();
         }
 
         /**
-         * Reads one byte at the given index and returns it
-         * @param index - the index in the Buffer where the byte is to be read
-         * @returns the char at the given index in the buffer
-         * @throws IndexOutOfBoundsException - If index is not smaller than the
-         * buffer's limit
+         * {@inheritDoc}
          */
-        virtual char getChar( std::size_t index ) const
-            throw ( lang::exceptions::IndexOutOfBoundsException ) {
+        virtual char getChar( int index ) const
+            throw ( decaf::lang::exceptions::IndexOutOfBoundsException ) {
 
             return (char)this->get( index );
         }
 
         /**
-         * Reads the next eight bytes at this buffer's current position, and then
-         * increments the position by that amount.
-         * @returns the next double in the buffer..
-         * @throws BufferUnderflowException - If there are no more bytes remaining in
-         * this buffer, meaning we have reached the set limit.
+         * {@inheritDoc}
          */
         virtual double getDouble() throw( decaf::nio::BufferUnderflowException );
 
         /**
-         * Reads eight bytes at the given index and returns it
-         * @param index - the index in the Buffer where the bytes are to be read
-         * @returns the double at the given index in the buffer
-         * @throws IndexOutOfBoundsException - If there are not enough bytes
-         * remaining to fill the requested Data Type
-         */
-        virtual double getDouble( std::size_t index ) const
-            throw ( lang::exceptions::IndexOutOfBoundsException );
+         * {@inheritDoc}
+         */
+        virtual double getDouble( int index ) const
+            throw ( decaf::lang::exceptions::IndexOutOfBoundsException );
 
         /**
-         * Reads the next four bytes at this buffer's current position, and then
-         * increments the position by that amount.
-         * @returns the next float in the buffer..
-         * @throws BufferUnderflowException - If there are no more bytes remaining in
-         * this buffer, meaning we have reached the set limit.
+         * {@inheritDoc}
          */
         virtual float getFloat() throw( decaf::nio::BufferUnderflowException );
 
         /**
-         * Reads four bytes at the given index and returns it
-         * @param index - the index in the Buffer where the bytes are to be read
-         * @returns the float at the given index in the buffer
-         * @throws IndexOutOfBoundsException - If there are not enough bytes
-         * remaining to fill the requested Data Type
-         */
-        virtual float getFloat( std::size_t index ) const
-            throw ( lang::exceptions::IndexOutOfBoundsException );
+         * {@inheritDoc}
+         */
+        virtual float getFloat( int index ) const
+            throw ( decaf::lang::exceptions::IndexOutOfBoundsException );
 
         /**
-         * Reads the next eight bytes at this buffer's current position, and then
-         * increments the position by that amount.
-         * @returns the next long long in the buffer..
-         * @throws BufferUnderflowException - If there are no more bytes remaining in
-         * this buffer, meaning we have reached the set limit.
+         * {@inheritDoc}
          */
         virtual long long getLong() throw( decaf::nio::BufferUnderflowException );
 
         /**
-         * Reads eight bytes at the given index and returns it
-         * @param index - the index in the Buffer where the bytes are to be read
-         * @returns the long long at the given index in the buffer
-         * @throws IndexOutOfBoundsException - If there are not enough bytes
-         * remaining to fill the requested Data Type
-         */
-        virtual long long getLong( std::size_t index ) const
-            throw ( lang::exceptions::IndexOutOfBoundsException );
+         * {@inheritDoc}
+         */
+        virtual long long getLong( int index ) const
+            throw ( decaf::lang::exceptions::IndexOutOfBoundsException );
 
         /**
-         * Reads the next four bytes at this buffer's current position, and then
-         * increments the position by that amount.
-         * @returns the next int in the buffer..
-         * @throws BufferUnderflowException - If there are no more bytes remaining in
-         * this buffer, meaning we have reached the set limit.
+         * {@inheritDoc}
          */
         virtual int getInt() throw( decaf::nio::BufferUnderflowException );
 
         /**
-         * Reads four bytes at the given index and returns it
-         * @param index - the index in the Buffer where the bytes are to be read
-         * @returns the int at the given index in the buffer
-         * @throws IndexOutOfBoundsException - If there are not enough bytes
-         * remaining to fill the requested Data Type
-         */
-        virtual int getInt( std::size_t index ) const
-            throw ( lang::exceptions::IndexOutOfBoundsException );
+         * {@inheritDoc}
+         */
+        virtual int getInt( int index ) const
+            throw ( decaf::lang::exceptions::IndexOutOfBoundsException );
 
         /**
-         * Reads the next two bytes at this buffer's current position, and then
-         * increments the position by that amount.
-         * @returns the next short in the buffer..
-         * @throws BufferUnderflowException - If there are no more bytes remaining in
-         * this buffer, meaning we have reached the set limit.
+         * {@inheritDoc}
          */
         virtual short getShort() throw( decaf::nio::BufferUnderflowException );
 
         /**
-         * Reads two bytes at the given index and returns it
-         * @param index - the index in the Buffer where the bytes are to be read
-         * @returns the short at the given index in the buffer
-         * @throws IndexOutOfBoundsException - If there are not enough bytes
-         * remaining to fill the requested Data Type
-         */
-        virtual short getShort( std::size_t index ) const
-            throw ( lang::exceptions::IndexOutOfBoundsException );
-
-        /**
-         * Writes the given byte into this buffer at the current position, and then
-         * increments the position.
-         * @param value - the byte 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
+         * {@inheritDoc}
+         */
+        virtual short getShort( int index ) const
+            throw ( decaf::lang::exceptions::IndexOutOfBoundsException );
+
+        /**
+         * {@inheritDoc}
          */
         virtual ByteArrayBuffer& put( unsigned char value )
             throw( decaf::nio::BufferOverflowException,
                    decaf::nio::ReadOnlyBufferException );
 
         /**
-         * Writes the given byte into this buffer at the given index.
-         * @param index - position in the Buffer to write the data
-         * @param value - the byte to write.
-         * @returns a reference to this buffer
-         * @throw IndexOutOfBoundsException - If index greater than the buffer's limit
-         * minus the size of the type being written.
-         * @throw ReadOnlyBufferException - If this buffer is read-only
-         */
-        virtual ByteArrayBuffer& put( std::size_t index, unsigned char value )
-            throw( lang::exceptions::IndexOutOfBoundsException,
-                    decaf::nio::ReadOnlyBufferException );
-
-        /**
-         * Writes one byte containing the given value, into this buffer at the
-         * current position, and then increments the position by one.
-         * @param value - The value to be written
-         * @returns a reference to this buffer
-         * @throw BufferOverflowException - If there are fewer than bytes remaining
-         * in this buffer than the size of the data to be written
-         * @throw ReadOnlyBufferException - If this buffer is read-only
+         * {@inheritDoc}
+         */
+        virtual ByteArrayBuffer& put( int index, unsigned char value )
+            throw( decaf::lang::exceptions::IndexOutOfBoundsException,
+                   decaf::nio::ReadOnlyBufferException );
+
+        /**
+         * {@inheritDoc}
          */
         virtual ByteArrayBuffer& putChar( char value )
             throw( decaf::nio::BufferOverflowException,
                    decaf::nio::ReadOnlyBufferException );
 
         /**
-         * Writes one byte containing the given value, into this buffer at the
-         * given index.
-         * @param index - position in the Buffer to write the data
-         * @param value - the value to write.
-         * @returns a reference to this buffer
-         * @throw IndexOutOfBoundsException - If index greater than the buffer's limit
-         * minus the size of the type being written.
-         * @throw ReadOnlyBufferException - If this buffer is read-only
-         */
-        virtual ByteArrayBuffer& putChar( std::size_t index, char value )
-            throw( lang::exceptions::IndexOutOfBoundsException,
+         * {@inheritDoc}
+         */
+        virtual ByteArrayBuffer& putChar( int index, char value )
+            throw( decaf::lang::exceptions::IndexOutOfBoundsException,
                    decaf::nio::ReadOnlyBufferException );
 
         /**
-         * Writes eight bytes containing the given value, into this buffer at the
-         * current position, and then increments the position by eight.
-         * @param value - The value to be written
-         * @returns a reference to this buffer
-         * @throw BufferOverflowException - If there are fewer than bytes remaining
-         * in this buffer than the size of the data to be written
-         * @throw ReadOnlyBufferException - If this buffer is read-only
+         * {@inheritDoc}
          */
         virtual ByteArrayBuffer& putDouble( double value )
             throw( decaf::nio::BufferOverflowException,
                    decaf::nio::ReadOnlyBufferException );
 
         /**
-         * Writes eight bytes containing the given value, into this buffer at the
-         * given index.
-         * @param index - position in the Buffer to write the data
-         * @param value - the value to write.
-         * @returns a reference to this buffer
-         * @throw IndexOutOfBoundsException - If index greater than the buffer's limit
-         * minus the size of the type being written.
-         * @throw ReadOnlyBufferException - If this buffer is read-only
-         */
-        virtual ByteArrayBuffer& putDouble( std::size_t index, double value )
-            throw( lang::exceptions::IndexOutOfBoundsException,
+         * {@inheritDoc}
+         */
+        virtual ByteArrayBuffer& putDouble( int index, double value )
+            throw( decaf::lang::exceptions::IndexOutOfBoundsException,
                    decaf::nio::ReadOnlyBufferException );
 
         /**
-         * Writes four bytes containing the given value, into this buffer at the
-         * current position, and then increments the position by eight.
-         * @param value - The value to be written
-         * @returns a reference to this buffer
-         * @throw BufferOverflowException - If there are fewer than bytes remaining
-         * in this buffer than the size of the data to be written
-         * @throw ReadOnlyBufferException - If this buffer is read-only
+         * {@inheritDoc}
          */
         virtual ByteArrayBuffer& putFloat( float value )
             throw( decaf::nio::BufferOverflowException,
                    decaf::nio::ReadOnlyBufferException );
 
         /**
-         * Writes four bytes containing the given value, into this buffer at the
-         * given index.
-         * @param index - position in the Buffer to write the data
-         * @param value - the value to write.
-         * @returns a reference to this buffer
-         * @throw IndexOutOfBoundsException - If index greater than the buffer's limit
-         * minus the size of the type being written.
-         * @throw ReadOnlyBufferException - If this buffer is read-only
-         */
-        virtual ByteArrayBuffer& putFloat( std::size_t index, float value )
-            throw( lang::exceptions::IndexOutOfBoundsException,
+         * {@inheritDoc}
+         */
+        virtual ByteArrayBuffer& putFloat( int index, float value )
+            throw( decaf::lang::exceptions::IndexOutOfBoundsException,
                    decaf::nio::ReadOnlyBufferException );
 
         /**
-         * Writes eight bytes containing the given value, into this buffer at the
-         * current position, and then increments the position by eight.
-         * @param value - The value to be written
-         * @returns a reference to this buffer
-         * @throw BufferOverflowException - If there are fewer than bytes remaining
-         * in this buffer than the size of the data to be written
-         * @throw ReadOnlyBufferException - If this buffer is read-only
+         * {@inheritDoc}
          */
         virtual ByteArrayBuffer& putLong( long long value )
             throw( decaf::nio::BufferOverflowException,
                    decaf::nio::ReadOnlyBufferException );
 
         /**
-         * Writes eight bytes containing the given value, into this buffer at the
-         * given index.
-         * @param index - position in the Buffer to write the data
-         * @param value - the value to write.
-         * @returns a reference to this buffer
-         * @throw IndexOutOfBoundsException - If index greater than the buffer's limit
-         * minus the size of the type being written.
-         * @throw ReadOnlyBufferException - If this buffer is read-only
-         */
-        virtual ByteArrayBuffer& putLong( std::size_t index, long long value )
-            throw( lang::exceptions::IndexOutOfBoundsException,
+         * {@inheritDoc}
+         */
+        virtual ByteArrayBuffer& putLong( int index, long long value )
+            throw( decaf::lang::exceptions::IndexOutOfBoundsException,
                    decaf::nio::ReadOnlyBufferException );
 
         /**
-         * Writes four bytes containing the given value, into this buffer at the
-         * current position, and then increments the position by eight.
-         * @param value - The value to be written
-         * @returns a reference to this buffer
-         * @throw BufferOverflowException - If there are fewer than bytes remaining
-         * in this buffer than the size of the data to be written
-         * @throw ReadOnlyBufferException - If this buffer is read-only
+         * {@inheritDoc}
          */
         virtual ByteArrayBuffer& putInt( int value )
             throw( decaf::nio::BufferOverflowException,
                    decaf::nio::ReadOnlyBufferException );
 
         /**
-         * Writes four bytes containing the given value, into this buffer at the
-         * given index.
-         * @param index - position in the Buffer to write the data
-         * @param value - the value to write.
-         * @returns a reference to this buffer
-         * @throw IndexOutOfBoundsException - If index greater than the buffer's limit
-         * minus the size of the type being written.
-         * @throw ReadOnlyBufferException - If this buffer is read-only
-         */
-        virtual ByteArrayBuffer& putInt( std::size_t index, int value )
-            throw( lang::exceptions::IndexOutOfBoundsException,
+         * {@inheritDoc}
+         */
+        virtual ByteArrayBuffer& putInt( int index, int value )
+            throw( decaf::lang::exceptions::IndexOutOfBoundsException,
                    decaf::nio::ReadOnlyBufferException );
 
         /**
-         * Writes two bytes containing the given value, into this buffer at the
-         * current position, and then increments the position by eight.
-         * @param value - The value to be written
-         * @returns a reference to this buffer
-         * @throw BufferOverflowException - If there are fewer than bytes remaining
-         * in this buffer than the size of the data to be written
-         * @throw ReadOnlyBufferException - If this buffer is read-only
+         * {@inheritDoc}
          */
         virtual ByteArrayBuffer& putShort( short value )
             throw( decaf::nio::BufferOverflowException,
                    decaf::nio::ReadOnlyBufferException );
 
         /**
-         * Writes two bytes containing the given value, into this buffer at the
-         * given index.
-         * @param index - position in the Buffer to write the data
-         * @param value - the value to write.
-         * @returns a reference to this buffer
-         * @throw IndexOutOfBoundsException - If index greater than the buffer's limit
-         * minus the size of the type being written.
-         * @throw ReadOnlyBufferException - If this buffer is read-only
-         */
-        virtual ByteArrayBuffer& putShort( std::size_t index, short value )
-            throw( lang::exceptions::IndexOutOfBoundsException,
+         * {@inheritDoc}
+         */
+        virtual ByteArrayBuffer& putShort( int index, short value )
+            throw( decaf::lang::exceptions::IndexOutOfBoundsException,
                    decaf::nio::ReadOnlyBufferException );
 
         /**
-         * Creates a new byte buffer whose content is a shared subsequence of this
-         * buffer's content.  The content of the new buffer will start at this buffer's
-         * 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 ByteArrayBuffer which the caller owns.
+         * {@inheritDoc}
          */
         virtual ByteArrayBuffer* slice() const;
 
     protected:
 
         /**
-         * Sets this ByteArrayBuffer as Read-Only.
-         * @param value - true if this buffer is to be read-only.
+         * Sets this ByteArrayBuffer as Read-Only or not Read-Only.
+         *
+         * @param value
+         *      Boolean value, true if this buffer is to be read-only, false otherwise.
          */
         virtual void setReadOnly( bool value ) {
             this->readOnly = value;

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/nio/CharArrayBuffer.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/nio/CharArrayBuffer.cpp?rev=925692&r1=925691&r2=925692&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/nio/CharArrayBuffer.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/nio/CharArrayBuffer.cpp Sat Mar 20 21:57:20 2010
@@ -28,55 +28,72 @@ using namespace decaf::internal::util;
 using namespace decaf::nio;
 
 ///////////////////////////////////////////////////////////////////////////////
-CharArrayBuffer::CharArrayBuffer( std::size_t capacity, bool readOnly )
-    : CharBuffer( capacity ){
+CharArrayBuffer::CharArrayBuffer( int size, bool readOnly )
+    throw( decaf::lang::exceptions::IllegalArgumentException ) : CharBuffer( size ){
 
     // Allocate using the ByteArray, not read-only initially.  Take a reference to it.
-    this->_array = new ByteArrayPerspective( capacity );
+    this->_array.reset( new ByteArrayAdapter( size ) );
     this->offset = 0;
+    this->length = size;
     this->readOnly = readOnly;
 }
 
 ///////////////////////////////////////////////////////////////////////////////
-CharArrayBuffer::CharArrayBuffer( char* array, std::size_t offset,
-                                  std::size_t capacity, bool readOnly )
-    throw( decaf::lang::exceptions::NullPointerException ) : CharBuffer( capacity ) {
+CharArrayBuffer::CharArrayBuffer( char* array, int size, int offset, int length, bool readOnly )
+    throw( decaf::lang::exceptions::NullPointerException,
+           decaf::lang::exceptions::IndexOutOfBoundsException ) : CharBuffer( length ) {
 
     try{
 
+        if( offset < 0 || offset > size ) {
+            throw IndexOutOfBoundsException(
+                __FILE__, __LINE__, "Offset parameter if out of bounds, %d", offset );
+        }
+
+        if( length < 0 || offset + length > size ) {
+            throw IndexOutOfBoundsException(
+                __FILE__, __LINE__, "length parameter if out of bounds, %d", length );
+        }
+
         // Allocate using the ByteArray, not read-only initially.
-        this->_array = new ByteArrayPerspective( array, capacity, false );
+        this->_array.reset( new ByteArrayAdapter( array, size, false ) );
         this->offset = offset;
+        this->length = length;
         this->readOnly = readOnly;
     }
     DECAF_CATCH_RETHROW( NullPointerException )
+    DECAF_CATCH_RETHROW( IndexOutOfBoundsException )
     DECAF_CATCH_EXCEPTION_CONVERT( Exception, NullPointerException )
     DECAF_CATCHALL_THROW( NullPointerException )
 }
 
 ///////////////////////////////////////////////////////////////////////////////
-CharArrayBuffer::CharArrayBuffer( ByteArrayPerspective& array,
-                                  std::size_t offset, std::size_t length,
-                                  bool readOnly )
-    throw( decaf::lang::exceptions::IndexOutOfBoundsException )
-    : CharBuffer( length ) {
+CharArrayBuffer::CharArrayBuffer( const Pointer<ByteArrayAdapter>& array, int offset, int length, bool readOnly )
+    throw( decaf::lang::exceptions::IndexOutOfBoundsException,
+           decaf::lang::exceptions::NullPointerException ) : CharBuffer( length ) {
 
     try{
-        if( offset > array.getCapacity() ) {
+
+        if( offset < 0 || offset > array->getCapacity() ) {
             throw IndexOutOfBoundsException(
-                __FILE__, __LINE__,
-                "CharArrayBuffer::CharArrayBuffer - offset %d is greater than capacity %d",
-                offset, array.getCapacity() );
+                __FILE__, __LINE__, "Offset parameter if out of bounds, %d", offset );
+        }
+
+        if( length < 0 || offset + length > array->getCapacity() ) {
+            throw IndexOutOfBoundsException(
+                __FILE__, __LINE__, "length parameter if out of bounds, %d", length );
         }
 
         // Allocate using the ByteArray, not read-only initially.
-        this->_array = array.takeRef();
+        this->_array = array;
         this->offset = offset;
+        this->length = length;
         this->readOnly = readOnly;
     }
     DECAF_CATCH_RETHROW( NullPointerException )
-    DECAF_CATCH_EXCEPTION_CONVERT( Exception, NullPointerException )
-    DECAF_CATCHALL_THROW( NullPointerException )
+    DECAF_CATCH_RETHROW( IndexOutOfBoundsException )
+    DECAF_CATCH_EXCEPTION_CONVERT( Exception, IndexOutOfBoundsException )
+    DECAF_CATCHALL_THROW( IndexOutOfBoundsException )
 }
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -84,8 +101,9 @@ CharArrayBuffer::CharArrayBuffer( const 
     : CharBuffer( other ) {
 
     // get the byte buffer of the caller and take a reference
-    this->_array = other._array->takeRef();
+    this->_array = other._array;
     this->offset = other.offset;
+    this->length = other.length;
     this->readOnly = other.readOnly;
 }
 
@@ -93,16 +111,6 @@ CharArrayBuffer::CharArrayBuffer( const 
 CharArrayBuffer::~CharArrayBuffer() {
 
     try{
-
-        // Return this object's reference to the buffer.
-        this->_array->returnRef();
-
-        // If there are no other Buffers out there that reference it then we
-        // delete it now, the internal unsigned char* array will be deleted
-        // if we where the owner.
-        if( this->_array->getReferences() == 0 ) {
-            delete this->_array;
-        }
     }
     DECAF_CATCH_NOTHROW( Exception )
     DECAF_CATCHALL_NOTHROW()
@@ -136,7 +144,7 @@ char* CharArrayBuffer::array()
 }
 
 ///////////////////////////////////////////////////////////////////////////////
-std::size_t CharArrayBuffer::arrayOffset()
+int CharArrayBuffer::arrayOffset()
     throw( decaf::lang::exceptions::UnsupportedOperationException,
            decaf::nio::ReadOnlyBufferException ) {
 
@@ -189,7 +197,7 @@ CharBuffer& CharArrayBuffer::compact()  
 
         // copy from the current pos to the beginning all the remaining bytes
         // the set pos to the
-        for( std::size_t ix = 0; ix < this->remaining(); ++ix ) {
+        for( int ix = 0; ix < this->remaining(); ++ix ) {
             this->put( ix, this->get( this->position() + ix ) );
         }
 
@@ -226,12 +234,17 @@ char CharArrayBuffer::get() throw ( deca
 }
 
 ///////////////////////////////////////////////////////////////////////////////
-char CharArrayBuffer::get( std::size_t index ) const
+char CharArrayBuffer::get( int index ) const
     throw ( lang::exceptions::IndexOutOfBoundsException ) {
 
     try{
 
-        if( ( index ) >= this->limit() ) {
+        if( index < 0 ) {
+            throw IndexOutOfBoundsException(
+                __FILE__, __LINE__, "index < 0" );
+        }
+
+        if( index >= this->limit() ) {
             throw IndexOutOfBoundsException(
                 __FILE__, __LINE__,
                 "CharArrayBuffer::get - Not enough data to fill request." );
@@ -260,7 +273,7 @@ CharBuffer& CharArrayBuffer::put( char v
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-CharBuffer& CharArrayBuffer::put( std::size_t index, char value )
+CharBuffer& CharArrayBuffer::put( int index, char value )
     throw( decaf::lang::exceptions::IndexOutOfBoundsException,
            decaf::nio::ReadOnlyBufferException ) {
 
@@ -272,6 +285,11 @@ CharBuffer& CharArrayBuffer::put( std::s
                 "CharArrayBuffer::put(i,i) - Buffer is Read Only." );
         }
 
+        if( index < 0 ) {
+            throw IndexOutOfBoundsException(
+                __FILE__, __LINE__, "index < 0" );
+        }
+
         if( index >= this->limit() ) {
             throw IndexOutOfBoundsException(
                 __FILE__, __LINE__,
@@ -293,7 +311,7 @@ CharBuffer* CharArrayBuffer::slice() con
 
     try{
 
-        return new CharArrayBuffer( *(this->_array),
+        return new CharArrayBuffer( this->_array,
                                     this->offset + this->position(),
                                     this->remaining(),
                                     this->isReadOnly() );
@@ -303,11 +321,21 @@ CharBuffer* CharArrayBuffer::slice() con
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-CharSequence* CharArrayBuffer::subSequence( std::size_t start, std::size_t end ) const
+CharSequence* CharArrayBuffer::subSequence( int start, int end ) const
     throw ( decaf::lang::exceptions::IndexOutOfBoundsException ) {
 
     try{
 
+        if( start < 0 ) {
+            throw IndexOutOfBoundsException(
+                __FILE__, __LINE__, "start index < 0" );
+        }
+
+        if( end < 0 ) {
+            throw IndexOutOfBoundsException(
+                __FILE__, __LINE__, "end index < 0" );
+        }
+
         if( start > end ) {
             throw IndexOutOfBoundsException(
                 __FILE__, __LINE__,

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/nio/CharArrayBuffer.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/nio/CharArrayBuffer.h?rev=925692&r1=925691&r2=925692&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/nio/CharArrayBuffer.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/nio/CharArrayBuffer.h Sat Mar 20 21:57:20 2010
@@ -24,12 +24,16 @@
 #include <decaf/nio/BufferUnderflowException.h>
 #include <decaf/nio/BufferOverflowException.h>
 #include <decaf/nio/ReadOnlyBufferException.h>
-#include <decaf/internal/nio/ByteArrayPerspective.h>
+#include <decaf/internal/util/ByteArrayAdapter.h>
+
+#include <decaf/lang/Pointer.h>
 
 namespace decaf{
 namespace internal{
 namespace nio{
 
+    using decaf::internal::util::ByteArrayAdapter;
+
     class DECAF_API CharArrayBuffer : public decaf::nio::CharBuffer {
     protected:
 
@@ -37,10 +41,13 @@ namespace nio{
         bool readOnly;
 
         // The reference array object that backs this buffer.
-        internal::nio::ByteArrayPerspective* _array;
+        decaf::lang::Pointer<ByteArrayAdapter> _array;
 
         // Offset into the array that we are to start from
-        std::size_t offset;
+        int offset;
+
+        // The length of the sub-array, or limit
+        int length;
 
     public:
 
@@ -48,44 +55,68 @@ namespace nio{
          * Creates a CharArrayBuffer 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 readOnly - should this buffer be read-only, default as false
+         *
+         * @param size
+         *      The size of the array, this is the limit we read and write to.
+         * @param readOnly
+         *      Boolean indicating if this buffer should be read-only, default as false.
+         *
+         * @throws IllegalArguementException if the capacity value is negative.
          */
-        CharArrayBuffer( std::size_t capacity, bool readOnly = false );
+        CharArrayBuffer( int size, bool readOnly = false )
+            throw( decaf::lang::exceptions::IllegalArgumentException );
 
         /**
          * Creates a CharArrayBuffer object that wraps the given array.  If the own flag
          * is set then it will delete this array when this object is deleted.
-         * @param array - array to wrap
-         * @param offset - the position that is this buffers start pos.
-         * @param capacity - size of the array, this is the limit we read and write to.
-         * @param readOnly - should this buffer be read-only, default as false
+         *
+         * @param array
+         *      The actual array to wrap.
+         * @param size
+         *      The size of the given array.
+         * @param offset
+         *      The position that is this buffers start position.
+         * @param length
+         *      The limit of how many bytes into the array this Buffer can write.
+         * @param readOnly
+         *      Boolean indicating if this buffer should be read-only, default as false.
+         *
          * @throws NullPointerException if buffer is NULL
+         * @throws IndexOutOfBoundsException if offset is greater than array capacity.
          */
-        CharArrayBuffer( char* array, std::size_t offset,
-                         std::size_t capacity, bool readOnly = false )
-            throw( decaf::lang::exceptions::NullPointerException );
+        CharArrayBuffer( char* array, int size, int offset, int length, bool readOnly = false )
+            throw( decaf::lang::exceptions::NullPointerException,
+                   decaf::lang::exceptions::IndexOutOfBoundsException );
 
         /**
-         * Creates a byte buffer that wraps the passed ByteArrayPerspective and
+         * Creates a byte buffer that wraps the passed ByteArrayAdapter and
          * start at the given offset.  The capacity and limit of the new CharArrayBuffer
          * will be that of the remaining capacity of the passed buffer.
-         * @param array - the ByteArrayPerspective to wrap
-         * @param offset - the offset into array where the buffer starts
-         * @param length - the length of the array we are wrapping or limit.
-         * @param readOnly - is this a readOnly buffer.
-         * @throws IndexOutOfBoundsException if offset is greater than array capacity.
-         */
-        CharArrayBuffer( ByteArrayPerspective& array,
-                         std::size_t offset, std::size_t length,
-                         bool readOnly = false )
-            throw( decaf::lang::exceptions::IndexOutOfBoundsException );
+         *
+         * @param array
+         *      The ByteArrayAdapter to wrap.
+         * @param offset
+         *      The position that is this buffers start position.
+         * @param length
+         *      The limit of how many bytes into the array this Buffer can write.
+         * @param readOnly
+         *      Boolean indicating if this buffer should be read-only, default as false.
+         *
+         * @throws NullPointerException if array is NULL
+         * @throws IndexOutOfBoundsException if offset + length is greater than array size.
+         */
+        CharArrayBuffer( const decaf::lang::Pointer<ByteArrayAdapter>& array,
+                         int offset, int length, bool readOnly = false )
+            throw( decaf::lang::exceptions::NullPointerException,
+                   decaf::lang::exceptions::IndexOutOfBoundsException );
 
         /**
          * Create a CharArrayBuffer that mirrors this one, meaning it shares a
-         * reference to this buffers ByteArrayPerspective and when changes
+         * reference to this buffers ByteArrayAdapter and when changes
          * are made to that data it is reflected in both.
-         * @param other - the CharArrayBuffer this one is to mirror.
+         *
+         * @param other
+         *      The CharArrayBuffer this one is to mirror.
          */
         CharArrayBuffer( const CharArrayBuffer& other );
 
@@ -94,187 +125,89 @@ namespace nio{
     public:  // Overrides
 
         /**
-         * 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
-         * @throws ReadOnlyBufferException if this Buffer is read only.
-         * @throws UnsupportedOperationException if the underlying store has no array.
+         * {@inheritDoc}
          */
         virtual char* array()
             throw( decaf::lang::exceptions::UnsupportedOperationException,
                    decaf::nio::ReadOnlyBufferException );
 
         /**
-         * 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.
+         * {@inheritDoc}
          */
-        virtual std::size_t arrayOffset()
+        virtual int arrayOffset()
             throw( decaf::lang::exceptions::UnsupportedOperationException,
                    decaf::nio::ReadOnlyBufferException );
 
         /**
-         * 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.
+         * {@inheritDoc}
          */
         virtual CharBuffer* asReadOnlyBuffer() const;
 
         /**
-         * 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
-         * @throws ReadOnlyBufferException - If this buffer is read-only
+         * {@inheritDoc}
          */
         virtual CharBuffer& compact() throw( decaf::nio::ReadOnlyBufferException );
 
         /**
-         * 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.
+         * {@inheritDoc}
          */
         virtual CharBuffer* duplicate();
 
         /**
-         * Relative get method. Reads the character at this buffer's current position,
-         * and then increments the position.
-         * @returns the char at the current position
-         * @throws BufferUnderflowException if there no more data to return
+         * {@inheritDoc}
          */
         virtual char get() throw ( decaf::nio::BufferUnderflowException );
 
         /**
-         * 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
+         * {@inheritDoc}
          */
-        virtual char get( std::size_t index ) const
+        virtual char get( int index ) const
             throw ( 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
+         * {@inheritDoc}
          */
         virtual bool hasArray() const { return true; }
 
         /**
-         * Tells whether or not this buffer is read-only.
-         * @returns true if, and only if, this buffer is read-only
+         * {@inheritDoc}
          */
         virtual bool isReadOnly() const {
             return this->readOnly;
         }
 
         /**
-         * 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
+         * {@inheritDoc}
          */
         virtual CharBuffer& put( char value )
             throw( decaf::nio::BufferOverflowException,
                    decaf::nio::ReadOnlyBufferException );
 
         /**
-         * 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
+         * {@inheritDoc}
          */
-        virtual CharBuffer& put( std::size_t index, char value )
+        virtual CharBuffer& put( int index, char value )
             throw( decaf::lang::exceptions::IndexOutOfBoundsException,
                    decaf::nio::ReadOnlyBufferException );
 
         /**
-         * Creates a new CharBuffer whose content is a shared subsequence of this
-         * buffer's content.  The content of the new buffer will start at this buffer's
-         * 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.
+         * {@inheritDoc}
          */
         virtual CharBuffer* slice() const;
 
         /**
-         * 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
+         * {@inheritDoc}
          */
-        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 );
 
     protected:
 
         /**
-         * Sets this ByteArrayBuffer as Read-Only.
-         * @param value - true if this buffer is to be read-only.
+         * Sets this CharArrayBuffer as Read-Only.
+         *
+         * @param value
+         *      Boolean value, true if this buffer is to be read-only, false otherwise.
          */
         virtual void setReadOnly( bool value ) {
             this->readOnly = value;

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/nio/DoubleArrayBuffer.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/nio/DoubleArrayBuffer.cpp?rev=925692&r1=925691&r2=925692&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/nio/DoubleArrayBuffer.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/nio/DoubleArrayBuffer.cpp Sat Mar 20 21:57:20 2010
@@ -26,54 +26,72 @@ using namespace decaf::internal::util;
 using namespace decaf::nio;
 
 ///////////////////////////////////////////////////////////////////////////////
-DoubleArrayBuffer::DoubleArrayBuffer( std::size_t capacity, bool readOnly )
-    : DoubleBuffer( capacity ){
+DoubleArrayBuffer::DoubleArrayBuffer( int size, bool readOnly )
+    throw( decaf::lang::exceptions::IllegalArgumentException ) : DoubleBuffer( size ){
 
     // Allocate using the ByteArray, not read-only initially.  Take a reference to it.
     // The capacity is the given capacity times the size of the stored datatype
-    this->_array = new ByteArrayPerspective( capacity * sizeof(double) );
+    this->_array.reset( new ByteArrayAdapter( size * sizeof(double) ) );
     this->offset = 0;
+    this->length = size;
     this->readOnly = readOnly;
 }
 
 ///////////////////////////////////////////////////////////////////////////////
-DoubleArrayBuffer::DoubleArrayBuffer( double* array, std::size_t offset,
-                                      std::size_t capacity, bool readOnly )
-    throw( decaf::lang::exceptions::NullPointerException ) : DoubleBuffer( capacity ) {
+DoubleArrayBuffer::DoubleArrayBuffer( double* array, int size, int offset, int length, bool readOnly )
+    throw( decaf::lang::exceptions::IndexOutOfBoundsException,
+           decaf::lang::exceptions::NullPointerException ) : DoubleBuffer( length ) {
 
     try{
 
+        if( offset < 0 || offset > size ) {
+            throw IndexOutOfBoundsException(
+                __FILE__, __LINE__, "Offset parameter if out of bounds, %d", offset );
+        }
+
+        if( length < 0 || offset + length > size ) {
+            throw IndexOutOfBoundsException(
+                __FILE__, __LINE__, "length parameter if out of bounds, %d", length );
+        }
+
         // Allocate using the ByteArray, not read-only initially.
-        this->_array = new ByteArrayPerspective( array, capacity, false );
+        this->_array.reset( new ByteArrayAdapter( array, size, false ) );
         this->offset = offset;
+        this->length = length;
         this->readOnly = readOnly;
     }
     DECAF_CATCH_RETHROW( NullPointerException )
+    DECAF_CATCH_RETHROW( IndexOutOfBoundsException )
     DECAF_CATCH_EXCEPTION_CONVERT( Exception, NullPointerException )
     DECAF_CATCHALL_THROW( NullPointerException )
 }
 
 ///////////////////////////////////////////////////////////////////////////////
-DoubleArrayBuffer::DoubleArrayBuffer( ByteArrayPerspective& array,
-                                      std::size_t offset, std::size_t capacity,
-                                      bool readOnly )
-    throw( decaf::lang::exceptions::IndexOutOfBoundsException )
-    : DoubleBuffer( capacity ) {
+DoubleArrayBuffer::DoubleArrayBuffer( const Pointer<ByteArrayAdapter>& array,
+                                      int offset, int length, bool readOnly )
+    throw( decaf::lang::exceptions::IndexOutOfBoundsException,
+           decaf::lang::exceptions::NullPointerException ) : DoubleBuffer( length ) {
 
     try{
-        if( offset > array.getCapacity() ) {
+
+        if( offset < 0 || offset > array->getCapacity() ) {
             throw IndexOutOfBoundsException(
-                __FILE__, __LINE__,
-                "DoubleArrayBuffer::DoubleArrayBuffer - offset %d is greater than capacity %d",
-                offset, array.getCapacity() );
+                __FILE__, __LINE__, "Offset parameter if out of bounds, %d", offset );
+        }
+
+        if( length < 0 || offset + length > array->getCapacity() ) {
+            throw IndexOutOfBoundsException(
+                __FILE__, __LINE__, "length parameter if out of bounds, %d", length );
         }
 
         // Allocate using the ByteArray, not read-only initially.
-        this->_array = array.takeRef();
+        this->_array = array;
         this->offset = offset;
+        this->length = length;
         this->readOnly = readOnly;
     }
     DECAF_CATCH_RETHROW( NullPointerException )
+    DECAF_CATCH_RETHROW( IndexOutOfBoundsException )
     DECAF_CATCH_EXCEPTION_CONVERT( Exception, NullPointerException )
     DECAF_CATCHALL_THROW( NullPointerException )
 }
@@ -83,8 +101,9 @@ DoubleArrayBuffer::DoubleArrayBuffer( co
     : DoubleBuffer( other ) {
 
     // get the byte buffer of the caller and take a reference
-    this->_array = other._array->takeRef();
+    this->_array = other._array;
     this->offset = other.offset;
+    this->length = other.length;
     this->readOnly = other.readOnly;
 }
 
@@ -92,16 +111,6 @@ DoubleArrayBuffer::DoubleArrayBuffer( co
 DoubleArrayBuffer::~DoubleArrayBuffer() {
 
     try{
-
-        // Return this object's reference to the buffer.
-        this->_array->returnRef();
-
-        // If there are no other Buffers out there that reference it then we
-        // delete it now, the internal unsigned char* array will be deleted
-        // if we where the owner.
-        if( this->_array->getReferences() == 0 ) {
-            delete this->_array;
-        }
     }
     DECAF_CATCH_NOTHROW( Exception )
     DECAF_CATCHALL_NOTHROW()
@@ -135,7 +144,7 @@ double* DoubleArrayBuffer::array()
 }
 
 ///////////////////////////////////////////////////////////////////////////////
-std::size_t DoubleArrayBuffer::arrayOffset()
+int DoubleArrayBuffer::arrayOffset()
     throw( decaf::lang::exceptions::UnsupportedOperationException,
            decaf::nio::ReadOnlyBufferException ) {
 
@@ -188,7 +197,7 @@ DoubleBuffer& DoubleArrayBuffer::compact
 
         // copy from the current pos to the beginning all the remaining bytes
         // the set pos to the
-        for( std::size_t ix = 0; ix < this->remaining(); ++ix ) {
+        for( int ix = 0; ix < this->remaining(); ++ix ) {
             this->put( ix, this->get( this->position() + ix ) );
         }
 
@@ -225,7 +234,7 @@ double DoubleArrayBuffer::get() throw ( 
 }
 
 ///////////////////////////////////////////////////////////////////////////////
-double DoubleArrayBuffer::get( std::size_t index ) const
+double DoubleArrayBuffer::get( int index ) const
     throw ( lang::exceptions::IndexOutOfBoundsException ) {
 
     try{
@@ -259,7 +268,7 @@ DoubleBuffer& DoubleArrayBuffer::put( do
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-DoubleBuffer& DoubleArrayBuffer::put( std::size_t index, double value )
+DoubleBuffer& DoubleArrayBuffer::put( int index, double value )
     throw( decaf::lang::exceptions::IndexOutOfBoundsException,
            decaf::nio::ReadOnlyBufferException ) {
 
@@ -292,10 +301,10 @@ DoubleBuffer* DoubleArrayBuffer::slice()
 
     try{
 
-        return new DoubleArrayBuffer( *(this->_array),
-                                       this->offset + this->position(),
-                                       this->remaining(),
-                                       this->isReadOnly() );
+        return new DoubleArrayBuffer( this->_array,
+                                      this->offset + this->position(),
+                                      this->remaining(),
+                                      this->isReadOnly() );
     }
     DECAF_CATCH_RETHROW( Exception )
     DECAF_CATCHALL_THROW( Exception )

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/nio/DoubleArrayBuffer.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/nio/DoubleArrayBuffer.h?rev=925692&r1=925691&r2=925692&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/nio/DoubleArrayBuffer.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/nio/DoubleArrayBuffer.h Sat Mar 20 21:57:20 2010
@@ -24,12 +24,16 @@
 #include <decaf/nio/BufferUnderflowException.h>
 #include <decaf/nio/BufferOverflowException.h>
 #include <decaf/nio/ReadOnlyBufferException.h>
-#include <decaf/internal/nio/ByteArrayPerspective.h>
+#include <decaf/internal/util/ByteArrayAdapter.h>
+
+#include <decaf/lang/Pointer.h>
 
 namespace decaf{
 namespace internal{
 namespace nio{
 
+    using decaf::internal::util::ByteArrayAdapter;
+
     class DECAF_API DoubleArrayBuffer : public decaf::nio::DoubleBuffer{
     private:
 
@@ -37,10 +41,13 @@ namespace nio{
         bool readOnly;
 
         // The reference array object that backs this buffer.
-        internal::nio::ByteArrayPerspective* _array;
+        decaf::lang::Pointer<ByteArrayAdapter> _array;
 
         // Offset into the array that we are to start from
-        std::size_t offset;
+        int offset;
+
+        // Number of bytes past offset to read to, or Limit.
+        int length;
 
     public:
 
@@ -48,44 +55,68 @@ namespace nio{
          * Creates a DoubleArrayBuffer 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 readOnly - should this buffer be read-only, default as false
+         *
+         * @param size
+         *      The size of the array, this is the limit we read and write to.
+         * @param readOnly
+         *      Boolean indicating if this buffer should be read-only, default as false.
+         *
+         * @throws IllegalArguementException if the capacity value is negative.
          */
-        DoubleArrayBuffer( std::size_t capacity, bool readOnly = false );
+        DoubleArrayBuffer( int capacity, bool readOnly = false )
+            throw( decaf::lang::exceptions::IllegalArgumentException );
 
         /**
          * Creates a DoubleArrayBuffer object that wraps the given array.  If the own flag
          * is set then it will delete this array when this object is deleted.
-         * @param array - array to wrap
-         * @param offset - the position that is this buffers start pos.
-         * @param capacity - size of the array, this is the limit we read and write to.
-         * @param readOnly - should this buffer be read-only, default as false
+         *
+         * @param array
+         *      The actual array to wrap.
+         * @param size
+         *      The size of the given array.
+         * @param offset
+         *      The position that is this buffers start position.
+         * @param length
+         *      The limit of how many bytes into the array this Buffer can write.
+         * @param readOnly
+         *      Boolean indicating if this buffer should be read-only, default as false.
+         *
          * @throws NullPointerException if buffer is NULL
+         * @throws IndexOutOfBoundsException if offset is greater than array capacity.
          */
-        DoubleArrayBuffer( double* array, std::size_t offset,
-                           std::size_t capacity, bool readOnly = false )
-            throw( decaf::lang::exceptions::NullPointerException );
+        DoubleArrayBuffer( double* array, int size, int offset, int length, bool readOnly = false )
+            throw( decaf::lang::exceptions::NullPointerException,
+                   decaf::lang::exceptions::IndexOutOfBoundsException );
 
         /**
-         * Creates a byte buffer that wraps the passed ByteArrayPerspective and
+         * Creates a byte buffer that wraps the passed ByteArrayAdapter and
          * start at the given offset.  The capacity and limit of the new DoubleArrayBuffer
          * will be that of the remaining capacity of the passed buffer.
-         * @param array - the ByteArrayPerspective to wrap
-         * @param offset - the offset into array where the buffer starts
-         * @param length - the length of the array we are wrapping or limit.
-         * @param readOnly - is this a readOnly buffer.
-         * @throws IndexOutOfBoundsException if offset is greater than array capacity.
-         */
-        DoubleArrayBuffer( ByteArrayPerspective& array,
-                           std::size_t offset, std::size_t length,
-                           bool readOnly = false )
-            throw( decaf::lang::exceptions::IndexOutOfBoundsException );
+         *
+         * @param array
+         *      The ByteArrayAdapter to wrap.
+         * @param offset
+         *      The position that is this buffers start position.
+         * @param length
+         *      The limit of how many bytes into the array this Buffer can write.
+         * @param readOnly
+         *      Boolean indicating if this buffer should be read-only, default as false.
+         *
+         * @throws NullPointerException if array is NULL
+         * @throws IndexOutOfBoundsException if offset + length is greater than array size.
+         */
+        DoubleArrayBuffer( const decaf::lang::Pointer<ByteArrayAdapter>& array,
+                           int offset, int length, bool readOnly = false )
+            throw( decaf::lang::exceptions::NullPointerException,
+                   decaf::lang::exceptions::IndexOutOfBoundsException );
 
         /**
          * Create a DoubleArrayBuffer that mirrors this one, meaning it shares a
-         * reference to this buffers ByteArrayPerspective and when changes
+         * reference to this buffers ByteArrayAdapter and when changes
          * are made to that data it is reflected in both.
-         * @param other - the DoubleArrayBuffer this one is to mirror.
+         *
+         * @param other
+         *      The DoubleArrayBuffer this one is to mirror.
          */
         DoubleArrayBuffer( const DoubleArrayBuffer& other );
 
@@ -94,166 +125,83 @@ namespace nio{
     public:
 
         /**
-         * 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
-         * @throws ReadOnlyBufferException if this Buffer is read only.
-         * @throws UnsupportedOperationException if the underlying store has no array.
+         * {@inheritDoc}
          */
         virtual double* array()
             throw( decaf::lang::exceptions::UnsupportedOperationException,
                    decaf::nio::ReadOnlyBufferException );
 
         /**
-         * 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.
+         * {@inheritDoc}
          */
-        virtual std::size_t arrayOffset()
+        virtual int arrayOffset()
             throw( decaf::lang::exceptions::UnsupportedOperationException,
                    decaf::nio::ReadOnlyBufferException );
 
         /**
-         * 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.
+         * {@inheritDoc}
          */
         virtual DoubleBuffer* asReadOnlyBuffer() const;
 
         /**
-         * 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
+         * {@inheritDoc}
          */
         virtual DoubleBuffer& compact() throw( decaf::nio::ReadOnlyBufferException );
 
         /**
-         * 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.
+         * {@inheritDoc}
          */
         virtual DoubleBuffer* duplicate();
 
         /**
-         * 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
+         * {@inheritDoc}
          */
         virtual double get() throw ( decaf::nio::BufferUnderflowException );
 
         /**
-         * 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
-         */
-        virtual double get( std::size_t index ) const
-            throw ( lang::exceptions::IndexOutOfBoundsException );
-
-        /**
-         * 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
+         * {@inheritDoc}
+         */
+        virtual double get( int index ) const
+            throw ( decaf::lang::exceptions::IndexOutOfBoundsException );
+
+        /**
+         * {@inheritDoc}
          */
         virtual bool hasArray() const { return true; }
 
         /**
-         * Tells whether or not this buffer is read-only.
-         * @returns true if, and only if, this buffer is read-only
+         * {@inheritDoc}
          */
         virtual bool isReadOnly() const {
             return this->readOnly;
         }
 
         /**
-         * 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
+         * {@inheritDoc}
          */
         virtual DoubleBuffer& put( double value )
             throw( decaf::nio::BufferOverflowException,
                    decaf::nio::ReadOnlyBufferException );
 
         /**
-         * 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.
-         * @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
+         * {@inheritDoc}
          */
-        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,
                    decaf::nio::ReadOnlyBufferException );
 
         /**
-         * Creates a new DoubleBuffer whose content is a shared subsequence of this
-         * buffer's content.  The content of the new buffer will start at this buffer's
-         * 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.
+         * {@inheritDoc}
          */
         virtual DoubleBuffer* slice() const;
 
     protected:
 
         /**
-         * Sets this ByteArrayBuffer as Read-Only.
-         * @param value - true if this buffer is to be read-only.
+         * Sets this DoubleArrayBuffer as Read-Only or not Read-Only.
+         *
+         * @param value
+         *      Boolean value, true if this buffer is to be read-only, false otherwise.
          */
         virtual void setReadOnly( bool value ) {
             this->readOnly = value;



Mime
View raw message