You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2007/12/05 16:19:46 UTC
svn commit: r601357 - in /activemq/activemq-cpp/decaf/trunk/src/main: ./
decaf/internal/nio/ decaf/internal/util/ decaf/lang/ decaf/nio/
Author: tabish
Date: Wed Dec 5 07:19:45 2007
New Revision: 601357
URL: http://svn.apache.org/viewvc?rev=601357&view=rev
Log:
http://issues.apache.org/activemq/browse/AMQCPP-153
Working on implementing the NIO package
Modified:
activemq/activemq-cpp/decaf/trunk/src/main/Makefile.am
activemq/activemq-cpp/decaf/trunk/src/main/decaf/internal/nio/ByteArrayBuffer.cpp
activemq/activemq-cpp/decaf/trunk/src/main/decaf/internal/nio/CharArrayBuffer.cpp
activemq/activemq-cpp/decaf/trunk/src/main/decaf/internal/nio/CharArrayBuffer.h
activemq/activemq-cpp/decaf/trunk/src/main/decaf/internal/util/ByteArrayAdapter.h
activemq/activemq-cpp/decaf/trunk/src/main/decaf/lang/CharSequence.h
activemq/activemq-cpp/decaf/trunk/src/main/decaf/nio/CharBuffer.cpp
activemq/activemq-cpp/decaf/trunk/src/main/decaf/nio/CharBuffer.h
Modified: activemq/activemq-cpp/decaf/trunk/src/main/Makefile.am
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/main/Makefile.am?rev=601357&r1=601356&r2=601357&view=diff
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/main/Makefile.am (original)
+++ activemq/activemq-cpp/decaf/trunk/src/main/Makefile.am Wed Dec 5 07:19:45 2007
@@ -27,6 +27,7 @@
decaf/internal/nio/BufferFactory.cpp \
decaf/internal/nio/ByteArrayPerspective.cpp \
decaf/internal/nio/ByteArrayBuffer.cpp \
+ decaf/internal/nio/CharArrayBuffer.cpp \
decaf/net/ServerSocket.cpp \
decaf/net/SocketOutputStream.cpp \
decaf/net/BufferedSocket.cpp \
@@ -199,6 +200,7 @@
decaf/internal/nio/BufferFactory.h \
decaf/internal/nio/ByteArrayPerspective.h \
decaf/internal/nio/ByteArrayBuffer.h \
+ decaf/internal/nio/CharArrayBuffer.h \
decaf/nio/Buffer.h \
decaf/nio/ByteBuffer.h \
decaf/nio/CharBuffer.h \
Modified: activemq/activemq-cpp/decaf/trunk/src/main/decaf/internal/nio/ByteArrayBuffer.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/main/decaf/internal/nio/ByteArrayBuffer.cpp?rev=601357&r1=601356&r2=601357&view=diff
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/main/decaf/internal/nio/ByteArrayBuffer.cpp (original)
+++ activemq/activemq-cpp/decaf/trunk/src/main/decaf/internal/nio/ByteArrayBuffer.cpp Wed Dec 5 07:19:45 2007
@@ -658,8 +658,6 @@
try{
- std::cout << "slicing: offset = " << this->offset + this->position()
- << ", capacity = " << this->remaining() << "\n";
return new ByteArrayBuffer( *(this->_array),
this->offset + this->position(),
this->remaining(),
Modified: activemq/activemq-cpp/decaf/trunk/src/main/decaf/internal/nio/CharArrayBuffer.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/main/decaf/internal/nio/CharArrayBuffer.cpp?rev=601357&r1=601356&r2=601357&view=diff
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/main/decaf/internal/nio/CharArrayBuffer.cpp (original)
+++ activemq/activemq-cpp/decaf/trunk/src/main/decaf/internal/nio/CharArrayBuffer.cpp Wed Dec 5 07:19:45 2007
@@ -18,13 +18,21 @@
#include "CharArrayBuffer.h"
using namespace decaf;
+using namespace decaf::lang;
+using namespace decaf::lang::exceptions;
using namespace decaf::internal;
using namespace decaf::internal::nio;
+using namespace decaf::internal::util;
+using namespace decaf::nio;
///////////////////////////////////////////////////////////////////////////////
-CharArrayBuffer::CharArrayBuffer( std::size_t capactiy, bool readOnly )
+CharArrayBuffer::CharArrayBuffer( std::size_t capacity, bool readOnly )
: CharBuffer( capacity ){
+ // Allocate using the ByteArray, not read-only initially. Take a reference to it.
+ this->_array = new ByteArrayPerspective( capacity );
+ this->offset = 0;
+ this->readOnly = readOnly;
}
///////////////////////////////////////////////////////////////////////////////
@@ -32,10 +40,264 @@
std::size_t capacity, bool readOnly )
throw( decaf::lang::exceptions::NullPointerException ) : CharBuffer( capacity ) {
+ try{
+
+ // Allocate using the ByteArray, not read-only initially.
+ this->_array = new ByteArrayPerspective( array, capacity, false );
+ this->offset = offset;
+ this->readOnly = readOnly;
+ }
+ DECAF_CATCH_RETHROW( NullPointerException )
+ 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 ) {
+
+ try{
+ if( offset > array.getCapacity() ) {
+ throw IndexOutOfBoundsException(
+ __FILE__, __LINE__,
+ "CharArrayBuffer::CharArrayBuffer - offset %d is greater than capacity %d",
+ offset, array.getCapacity() );
+ }
+
+ // Allocate using the ByteArray, not read-only initially.
+ this->_array = array.takeRef();
+ this->offset = offset;
+ this->readOnly = readOnly;
+ }
+ DECAF_CATCH_RETHROW( NullPointerException )
+ DECAF_CATCH_EXCEPTION_CONVERT( Exception, NullPointerException )
+ DECAF_CATCHALL_THROW( NullPointerException )
}
///////////////////////////////////////////////////////////////////////////////
CharArrayBuffer::CharArrayBuffer( const CharArrayBuffer& other )
- : CharBuffer( capacity ) {
+ : CharBuffer( other.capacity() ) {
+
+ // get the byte buffer of the caller and take a reference
+ this->_array = other._array->takeRef();
+ this->offset = other.offset;
+ this->readOnly = other.readOnly;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+char* CharArrayBuffer::array()
+ throw( decaf::lang::exceptions::UnsupportedOperationException,
+ decaf::nio::ReadOnlyBufferException ) {
+
+ try{
+
+ if( !this->hasArray() ) {
+ throw UnsupportedOperationException(
+ __FILE__, __LINE__,
+ "CharArrayBuffer::arrayOffset() - This Buffer has no backing array." );
+ }
+
+ if( this->isReadOnly() ) {
+ throw ReadOnlyBufferException(
+ __FILE__, __LINE__,
+ "CharArrayBuffer::array - Buffer is Read-Only" );
+ }
+
+ return this->_array->getCharArray();
+ }
+ DECAF_CATCH_RETHROW( ReadOnlyBufferException )
+ DECAF_CATCH_RETHROW( UnsupportedOperationException )
+ DECAF_CATCH_EXCEPTION_CONVERT( Exception, UnsupportedOperationException )
+ DECAF_CATCHALL_THROW( UnsupportedOperationException )
+}
+
+///////////////////////////////////////////////////////////////////////////////
+std::size_t CharArrayBuffer::arrayOffset()
+ throw( decaf::lang::exceptions::UnsupportedOperationException,
+ decaf::nio::ReadOnlyBufferException ) {
+
+ try{
+
+ if( !this->hasArray() ) {
+ throw UnsupportedOperationException(
+ __FILE__, __LINE__,
+ "CharArrayBuffer::arrayOffset() - This Buffer has no backing array." );
+ }
+
+ if( this->isReadOnly() ) {
+ throw decaf::nio::ReadOnlyBufferException(
+ __FILE__, __LINE__,
+ "CharArrayBuffer::arrayOffset() - Buffer is Read Only." );
+ }
+
+ return this->offset;
+ }
+ DECAF_CATCH_RETHROW( ReadOnlyBufferException )
+ DECAF_CATCH_RETHROW( UnsupportedOperationException )
+ DECAF_CATCH_EXCEPTION_CONVERT( Exception, UnsupportedOperationException )
+ DECAF_CATCHALL_THROW( UnsupportedOperationException )
+}
+
+///////////////////////////////////////////////////////////////////////////////
+CharBuffer* CharArrayBuffer::asReadOnlyBuffer() const {
+
+ try{
+
+ CharArrayBuffer* buffer = new CharArrayBuffer( *this );
+ buffer->setReadOnly( true );
+
+ return buffer;
+ }
+ DECAF_CATCH_RETHROW( Exception )
+ DECAF_CATCHALL_THROW( Exception )
+}
+
+///////////////////////////////////////////////////////////////////////////////
+CharBuffer& CharArrayBuffer::compact() throw( decaf::nio::ReadOnlyBufferException ) {
+
+ try{
+
+ if( this->isReadOnly() ) {
+ throw decaf::nio::ReadOnlyBufferException(
+ __FILE__, __LINE__,
+ "CharArrayBuffer::compact() - Buffer is Read Only." );
+ }
+
+ // copy from the current pos to the beginning all the remaining bytes
+ // the set pos to the
+ memcpy( this->array() + offset,
+ this->array() + offset + this->position(),
+ this->remaining() );
+
+ this->position( this->limit() - this->position() );
+ this->limit( this->capacity() );
+ this->_markSet = false;
+
+ return *this;
+ }
+ DECAF_CATCH_RETHROW( decaf::nio::ReadOnlyBufferException )
+ DECAF_CATCH_EXCEPTION_CONVERT( Exception, decaf::nio::ReadOnlyBufferException )
+ DECAF_CATCHALL_THROW( decaf::nio::ReadOnlyBufferException )
+}
+
+///////////////////////////////////////////////////////////////////////////////
+CharBuffer* CharArrayBuffer::duplicate() {
+
+ try{
+ return NULL; //new CharArrayBuffer( *this );
+ }
+ DECAF_CATCH_RETHROW( Exception )
+ DECAF_CATCHALL_THROW( Exception )
+}
+
+///////////////////////////////////////////////////////////////////////////////
+char CharArrayBuffer::get() throw ( decaf::nio::BufferUnderflowException ) {
+
+ try{
+ return this->get( this->_position++ );
+ }
+ DECAF_CATCH_RETHROW( BufferUnderflowException )
+ DECAF_CATCH_EXCEPTION_CONVERT( Exception, BufferUnderflowException )
+ DECAF_CATCHALL_THROW( BufferUnderflowException )
+}
+
+///////////////////////////////////////////////////////////////////////////////
+char CharArrayBuffer::get( std::size_t index ) const
+ throw ( lang::exceptions::IndexOutOfBoundsException ) {
+
+ try{
+
+ if( ( index ) >= this->limit() ) {
+ throw IndexOutOfBoundsException(
+ __FILE__, __LINE__,
+ "CharArrayBuffer::get - Not enough data to fill request." );
+ }
+
+ return this->_array->getChar( offset + index );
+ }
+ DECAF_CATCH_RETHROW( IndexOutOfBoundsException )
+ DECAF_CATCH_EXCEPTION_CONVERT( Exception, IndexOutOfBoundsException )
+ DECAF_CATCHALL_THROW( IndexOutOfBoundsException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+CharBuffer& CharArrayBuffer::put( char value )
+ throw( BufferOverflowException, ReadOnlyBufferException ) {
+
+ try{
+
+ this->put( this->_position++, value );
+ return *this;
+ }
+ DECAF_CATCH_RETHROW( decaf::nio::ReadOnlyBufferException )
+ DECAF_CATCH_RETHROW( decaf::nio::BufferOverflowException )
+ DECAF_CATCH_EXCEPTION_CONVERT( Exception, decaf::nio::BufferOverflowException )
+ DECAF_CATCHALL_THROW( decaf::nio::BufferOverflowException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+CharBuffer& CharArrayBuffer::put( std::size_t index, char value )
+ throw( decaf::lang::exceptions::IndexOutOfBoundsException,
+ decaf::nio::ReadOnlyBufferException ) {
+
+ try{
+
+ if( this->isReadOnly() ) {
+ throw decaf::nio::ReadOnlyBufferException(
+ __FILE__, __LINE__,
+ "CharArrayBuffer::put(i,i) - Buffer is Read Only." );
+ }
+
+ if( index >= this->limit() ) {
+ throw IndexOutOfBoundsException(
+ __FILE__, __LINE__,
+ "CharArrayBuffer::put(i,i) - Not enough data to fill request." );
+ }
+
+ this->_array->putChar( index + offset, value );
+
+ return *this;
+ }
+ DECAF_CATCH_RETHROW( decaf::nio::ReadOnlyBufferException )
+ DECAF_CATCH_RETHROW( IndexOutOfBoundsException )
+ DECAF_CATCH_EXCEPTION_CONVERT( Exception, IndexOutOfBoundsException )
+ DECAF_CATCHALL_THROW( IndexOutOfBoundsException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+CharBuffer* CharArrayBuffer::slice() const {
+
+ try{
+
+ return new CharArrayBuffer( *(this->_array),
+ this->offset + this->position(),
+ this->remaining(),
+ this->isReadOnly() );
+ }
+ DECAF_CATCH_RETHROW( Exception )
+ DECAF_CATCHALL_THROW( Exception )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+CharSequence* CharArrayBuffer::subSequence( std::size_t start, std::size_t end ) const
+ throw ( decaf::lang::exceptions::IndexOutOfBoundsException ) {
+
+ try{
+
+ CharArrayBuffer* buffer = new CharArrayBuffer(
+ *(this->_array),
+ this->offset + this->position() + start,
+ this->capacity(),
+ this->isReadOnly() );
+
+ buffer->limit( this->position() + end );
+ return buffer;
+ }
+ DECAF_CATCH_RETHROW( IndexOutOfBoundsException )
+ DECAF_CATCH_EXCEPTION_CONVERT( Exception, IndexOutOfBoundsException )
+ DECAF_CATCHALL_THROW( IndexOutOfBoundsException )
}
Modified: activemq/activemq-cpp/decaf/trunk/src/main/decaf/internal/nio/CharArrayBuffer.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/main/decaf/internal/nio/CharArrayBuffer.h?rev=601357&r1=601356&r2=601357&view=diff
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/main/decaf/internal/nio/CharArrayBuffer.h (original)
+++ activemq/activemq-cpp/decaf/trunk/src/main/decaf/internal/nio/CharArrayBuffer.h Wed Dec 5 07:19:45 2007
@@ -19,6 +19,12 @@
#define _DECAF_INTERNAL_NIO_CHARARRAYBUFFER_H_
#include <decaf/nio/CharBuffer.h>
+#include <decaf/lang/exceptions/NullPointerException.h>
+#include <decaf/lang/exceptions/IndexOutOfBoundsException.h>
+#include <decaf/nio/BufferUnderflowException.h>
+#include <decaf/nio/BufferOverflowException.h>
+#include <decaf/nio/ReadOnlyBufferException.h>
+#include <decaf/internal/nio/ByteArrayPerspective.h>
namespace decaf{
namespace internal{
@@ -27,7 +33,14 @@
class CharArrayBuffer : public decaf::nio::CharBuffer {
protected:
- // This is the store for all this objects char data
+ // Read / Write flag
+ bool readOnly;
+
+ // The reference array object that backs this buffer.
+ internal::nio::ByteArrayPerspective* _array;
+
+ // Offset into the array that we are to start from
+ std::size_t offset;
public:
@@ -54,6 +67,22 @@
throw( decaf::lang::exceptions::NullPointerException );
/**
+ * Creates a byte buffer that wraps the passed ByteArrayPerspective 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 NullPointerException if buffer is NULL
+ * @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 );
+
+ /**
* Create a CharArrayBuffer that mirros this one, meaning it shares a
* reference to this buffers ByteArrayPerspective and when changes
* are made to that data it is reflected in both.
@@ -63,6 +92,195 @@
CharArrayBuffer( const CharArrayBuffer& other );
virtual ~CharArrayBuffer() {}
+
+ 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.
+ */
+ 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.
+ */
+ virtual std::size_t 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.
+ */
+ 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
+ */
+ 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.
+ */
+ 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
+ */
+ 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
+ */
+ virtual char get( std::size_t 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
+ */
+ 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
+ */
+ 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
+ */
+ 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
+ */
+ virtual CharBuffer& put( std::size_t 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.
+ */
+ 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
+ */
+ virtual lang::CharSequence* subSequence( std::size_t start, std::size_t 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.
+ */
+ virtual void setReadOnly( bool value ) {
+ this->readOnly = value;
+ }
};
Modified: activemq/activemq-cpp/decaf/trunk/src/main/decaf/internal/util/ByteArrayAdapter.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/main/decaf/internal/util/ByteArrayAdapter.h?rev=601357&r1=601356&r2=601357&view=diff
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/main/decaf/internal/util/ByteArrayAdapter.h (original)
+++ activemq/activemq-cpp/decaf/trunk/src/main/decaf/internal/util/ByteArrayAdapter.h Wed Dec 5 07:19:45 2007
@@ -156,6 +156,60 @@
}
/**
+ * Gets the pointer to the array we are wrapping. Changes to the data in this
+ * array are reflected by all ByteArrayAdapter objects that point to this array.
+ * @returns an char* pointer to the array this object wraps.
+ */
+ virtual char* getCharArray() {
+ return reinterpret_cast<char*>( this->array );
+ }
+
+ /**
+ * Gets the pointer to the array we are wrapping. Changes to the data in this
+ * array are reflected by all ByteArrayAdapter objects that point to this array.
+ * @returns an short* pointer to the array this object wraps.
+ */
+ virtual short* getShortArray() {
+ return reinterpret_cast<short*>( this->array );
+ }
+
+ /**
+ * Gets the pointer to the array we are wrapping. Changes to the data in this
+ * array are reflected by all ByteArrayAdapter objects that point to this array.
+ * @returns an int* pointer to the array this object wraps.
+ */
+ virtual int* getIntArray() {
+ return reinterpret_cast<int*>( this->array );
+ }
+
+ /**
+ * Gets the pointer to the array we are wrapping. Changes to the data in this
+ * array are reflected by all ByteArrayAdapter objects that point to this array.
+ * @returns an long long* pointer to the array this object wraps.
+ */
+ virtual long long* getLongArray() {
+ return reinterpret_cast<long long*>( this->array );
+ }
+
+ /**
+ * Gets the pointer to the array we are wrapping. Changes to the data in this
+ * array are reflected by all ByteArrayAdapter objects that point to this array.
+ * @returns an double* pointer to the array this object wraps.
+ */
+ virtual double* getDoubleArray() {
+ return reinterpret_cast<double*>( this->array );
+ }
+
+ /**
+ * Gets the pointer to the array we are wrapping. Changes to the data in this
+ * array are reflected by all ByteArrayAdapter objects that point to this array.
+ * @returns an float* pointer to the array this object wraps.
+ */
+ virtual float* getFloatArray() {
+ return reinterpret_cast<float*>( this->array );
+ }
+
+ /**
* Reads from the Byte array starting at the specified offset and reading
* the specified length. If the length is greater than the capacity of this
* underlying byte array then an BufferUnderflowException is thrown.
Modified: activemq/activemq-cpp/decaf/trunk/src/main/decaf/lang/CharSequence.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/main/decaf/lang/CharSequence.h?rev=601357&r1=601356&r2=601357&view=diff
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/main/decaf/lang/CharSequence.h (original)
+++ activemq/activemq-cpp/decaf/trunk/src/main/decaf/lang/CharSequence.h Wed Dec 5 07:19:45 2007
@@ -50,7 +50,7 @@
* @throws IndexOutOfBoundsException if index is > than length()
*/
virtual char charAt( std::size_t index ) const
- throw( lang::exceptions::IndexOutOfBoundsException )= 0;
+ throw( lang::exceptions::IndexOutOfBoundsException ) = 0;
/**
* Returns a new CharSequence that is a subsequence of this sequence. The
Modified: activemq/activemq-cpp/decaf/trunk/src/main/decaf/nio/CharBuffer.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/main/decaf/nio/CharBuffer.cpp?rev=601357&r1=601356&r2=601357&view=diff
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/main/decaf/nio/CharBuffer.cpp (original)
+++ activemq/activemq-cpp/decaf/trunk/src/main/decaf/nio/CharBuffer.cpp Wed Dec 5 07:19:45 2007
@@ -101,7 +101,7 @@
}
////////////////////////////////////////////////////////////////////////////////
-char CharBuffer::charAt( std::size_t index )
+char CharBuffer::charAt( std::size_t index ) const
throw( decaf::lang::exceptions::IndexOutOfBoundsException ) {
try{
Modified: activemq/activemq-cpp/decaf/trunk/src/main/decaf/nio/CharBuffer.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/main/decaf/nio/CharBuffer.h?rev=601357&r1=601356&r2=601357&view=diff
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/main/decaf/nio/CharBuffer.h (original)
+++ activemq/activemq-cpp/decaf/trunk/src/main/decaf/nio/CharBuffer.h Wed Dec 5 07:19:45 2007
@@ -176,7 +176,7 @@
* @returns The character at index position() + index
* @throws IndexOutOfBoundsException
*/
- char charAt( std::size_t index )
+ char charAt( std::size_t index ) const
throw( decaf::lang::exceptions::IndexOutOfBoundsException );
/**
@@ -282,7 +282,7 @@
* Returns the length of this character buffer.
* @returns the length of this buffer from the position to the limit.
*/
- int length() {
+ std::size_t length() const {
return this->remaining();
}
@@ -436,7 +436,7 @@
* @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 )
+ virtual lang::CharSequence* subSequence( std::size_t start, std::size_t end ) const
throw ( decaf::lang::exceptions::IndexOutOfBoundsException ) = 0;
/**