decaf::internal::nio::CharArrayBuffer Class Reference

#include <src/main/decaf/internal/nio/CharArrayBuffer.h>

Inheritance diagram for decaf::internal::nio::CharArrayBuffer:
Inheritance graph
[legend]

Public Member Functions

 CharArrayBuffer (int size, bool readOnly=false)
 Creates a CharArrayBuffer object that has its backing array allocated internally and is then owned and deleted when this object is deleted.
 CharArrayBuffer (char *array, int size, int offset, int length, bool readOnly=false)
 Creates a CharArrayBuffer object that wraps the given array.
 CharArrayBuffer (const decaf::lang::Pointer< ByteArrayAdapter > &array, int offset, int length, bool readOnly=false)
 Creates a byte buffer that wraps the passed ByteArrayAdapter and start at the given offset.
 CharArrayBuffer (const CharArrayBuffer &other)
 Create a CharArrayBuffer that mirrors this one, meaning it shares a reference to this buffers ByteArrayAdapter and when changes are made to that data it is reflected in both.
virtual ~CharArrayBuffer ()
virtual char * array ()
 Returns the character array that backs this buffer (optional operation).Modifications to this buffer's content will cause the returned array's content to be modified, and vice versa.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.
Exceptions:
ReadOnlyBufferException if this Buffer is read only.
UnsupportedOperationException if the underlying store has no array.

virtual int arrayOffset ()
 Returns the offset within this buffer's backing array of the first element of the buffer (optional operation).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.
Exceptions:
ReadOnlyBufferException if this Buffer is read only.
UnsupportedOperationException if the underlying store has no array.

virtual CharBuffer * asReadOnlyBuffer () const
 Creates a new, read-only char buffer that shares this buffer's content.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.If this buffer is itself read-only then this method behaves in exactly the same way as the duplicate method.The new buffer's capacity, limit, position, and mark values will be identical to those of this buffer.
Returns:
The new, read-only char buffer which the caller then owns.

virtual CharBuffer & compact ()
 Compacts this buffer.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.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.
Exceptions:
ReadOnlyBufferException - If this buffer is read-only

virtual CharBuffer * duplicate ()
 Creates a new char buffer that shares this buffer's content.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.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 char get ()
 Relative get method.Reads the character at this buffer's current position, and then increments the position.
Returns:
the char at the current position.
Exceptions:
BufferUnderflowException if there no more data to return

virtual char get (int index) const
 Absolute get method.Reads the char at the given index.
Parameters:
index The index in the Buffer where the char is to be read.
Returns:
the char that is located at the given index.
Exceptions:
IndexOutOfBoundsException if index is not smaller than the buffer's limit or is negative.

virtual bool hasArray () const
 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 isReadOnly () const
 Tells whether or not this buffer is read-only.
Returns:
true if, and only if, this buffer is read-only.

virtual CharBuffer & put (char value)
 Writes the given char into this buffer at the current position, and then increments the position.
Parameters:
value The char value to be written.
Returns:
a reference to this buffer.
Exceptions:
BufferOverflowException if this buffer's current position is not smaller than its limit
ReadOnlyBufferException if this buffer is read-only.

virtual CharBuffer & put (int index, char value)
 Writes the given char into this buffer at the given index.
Parameters:
index The position in the Buffer to write the data.
value The char to write.
Returns:
a reference to this buffer.
Exceptions:
IndexOutOfBoundsException if index greater than the buffer's limit minus the size of the type being written, or index is negative.
ReadOnlyBufferException if this buffer is read-only.

virtual CharBuffer * slice () const
 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.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 lang::CharSequencesubSequence (int start, int end) const
 Creates a new character buffer that represents the specified subsequence of this buffer, relative to the current position.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.
Parameters:
start The index, relative to the current position, of the first character in the subsequence; must be non-negative and no larger than remaining().
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().
Returns:
The new character buffer, caller owns.
Exceptions:
IndexOutOfBoundsException if the preconditions on start and end fail.

Protected Member Functions

virtual void setReadOnly (bool value)
 Sets this CharArrayBuffer as Read-Only.

Protected Attributes

decaf::lang::Pointer
< ByteArrayAdapter
_array
int offset
int length
bool readOnly

Constructor & Destructor Documentation

decaf::internal::nio::CharArrayBuffer::CharArrayBuffer ( int  size,
bool  readOnly = false 
)

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.

Parameters:
size The size of the array, this is the limit we read and write to.
readOnly Boolean indicating if this buffer should be read-only, default as false.
Exceptions:
IllegalArguementException if the capacity value is negative.
decaf::internal::nio::CharArrayBuffer::CharArrayBuffer ( char *  array,
int  size,
int  offset,
int  length,
bool  readOnly = false 
)

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.

Parameters:
array The actual array to wrap.
size The size of the given array.
offset The position that is this buffers start position.
length The limit of how many bytes into the array this Buffer can write.
readOnly Boolean indicating if this buffer should be read-only, default as false.
Exceptions:
NullPointerException if buffer is NULL
IndexOutOfBoundsException if offset is greater than array capacity.
decaf::internal::nio::CharArrayBuffer::CharArrayBuffer ( const decaf::lang::Pointer< ByteArrayAdapter > &  array,
int  offset,
int  length,
bool  readOnly = false 
)

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.

Parameters:
array The ByteArrayAdapter to wrap.
offset The position that is this buffers start position.
length The limit of how many bytes into the array this Buffer can write.
readOnly Boolean indicating if this buffer should be read-only, default as false.
Exceptions:
NullPointerException if array is NULL
IndexOutOfBoundsException if offset + length is greater than array size.
decaf::internal::nio::CharArrayBuffer::CharArrayBuffer ( const CharArrayBuffer other  ) 

Create a CharArrayBuffer that mirrors this one, meaning it shares a reference to this buffers ByteArrayAdapter and when changes are made to that data it is reflected in both.

Parameters:
other The CharArrayBuffer this one is to mirror.
virtual decaf::internal::nio::CharArrayBuffer::~CharArrayBuffer (  )  [virtual]

Member Function Documentation

virtual char* decaf::internal::nio::CharArrayBuffer::array (  )  [virtual]

Returns the character array that backs this buffer (optional operation).Modifications to this buffer's content will cause the returned array's content to be modified, and vice versa.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.
Exceptions:
ReadOnlyBufferException if this Buffer is read only.
UnsupportedOperationException if the underlying store has no array.

Implements decaf::nio::CharBuffer.

virtual int decaf::internal::nio::CharArrayBuffer::arrayOffset (  )  [virtual]

Returns the offset within this buffer's backing array of the first element of the buffer (optional operation).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.
Exceptions:
ReadOnlyBufferException if this Buffer is read only.
UnsupportedOperationException if the underlying store has no array.

Implements decaf::nio::CharBuffer.

virtual CharBuffer* decaf::internal::nio::CharArrayBuffer::asReadOnlyBuffer (  )  const [virtual]

Creates a new, read-only char buffer that shares this buffer's content.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.If this buffer is itself read-only then this method behaves in exactly the same way as the duplicate method.The new buffer's capacity, limit, position, and mark values will be identical to those of this buffer.

Returns:
The new, read-only char buffer which the caller then owns.

Implements decaf::nio::CharBuffer.

virtual CharBuffer& decaf::internal::nio::CharArrayBuffer::compact (  )  [virtual]

Compacts this buffer.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.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.
Exceptions:
ReadOnlyBufferException - If this buffer is read-only

Implements decaf::nio::CharBuffer.

virtual CharBuffer* decaf::internal::nio::CharArrayBuffer::duplicate (  )  [virtual]

Creates a new char buffer that shares this buffer's content.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.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.

Implements decaf::nio::CharBuffer.

virtual char decaf::internal::nio::CharArrayBuffer::get ( int  index  )  const [virtual]

Absolute get method.Reads the char at the given index.

Parameters:
index The index in the Buffer where the char is to be read.
Returns:
the char that is located at the given index.
Exceptions:
IndexOutOfBoundsException if index is not smaller than the buffer's limit or is negative.

Implements decaf::nio::CharBuffer.

virtual char decaf::internal::nio::CharArrayBuffer::get (  )  [virtual]

Relative get method.Reads the character at this buffer's current position, and then increments the position.

Returns:
the char at the current position.
Exceptions:
BufferUnderflowException if there no more data to return

Implements decaf::nio::CharBuffer.

virtual bool decaf::internal::nio::CharArrayBuffer::hasArray (  )  const [inline, virtual]

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

Implements decaf::nio::CharBuffer.

virtual bool decaf::internal::nio::CharArrayBuffer::isReadOnly (  )  const [inline, virtual]

Tells whether or not this buffer is read-only.

Returns:
true if, and only if, this buffer is read-only.

Implements decaf::nio::Buffer.

virtual CharBuffer& decaf::internal::nio::CharArrayBuffer::put ( int  index,
char  value 
) [virtual]

Writes the given char into this buffer at the given index.

Parameters:
index The position in the Buffer to write the data.
value The char to write.
Returns:
a reference to this buffer.
Exceptions:
IndexOutOfBoundsException if index greater than the buffer's limit minus the size of the type being written, or index is negative.
ReadOnlyBufferException if this buffer is read-only.

Implements decaf::nio::CharBuffer.

virtual CharBuffer& decaf::internal::nio::CharArrayBuffer::put ( char  value  )  [virtual]

Writes the given char into this buffer at the current position, and then increments the position.

Parameters:
value The char value to be written.
Returns:
a reference to this buffer.
Exceptions:
BufferOverflowException if this buffer's current position is not smaller than its limit
ReadOnlyBufferException if this buffer is read-only.

Implements decaf::nio::CharBuffer.

virtual void decaf::internal::nio::CharArrayBuffer::setReadOnly ( bool  value  )  [inline, protected, virtual]

Sets this CharArrayBuffer as Read-Only.

Parameters:
value Boolean value, true if this buffer is to be read-only, false otherwise.
virtual CharBuffer* decaf::internal::nio::CharArrayBuffer::slice (  )  const [virtual]

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.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.

Implements decaf::nio::CharBuffer.

virtual lang::CharSequence* decaf::internal::nio::CharArrayBuffer::subSequence ( int  start,
int  end 
) const [virtual]

Creates a new character buffer that represents the specified subsequence of this buffer, relative to the current position.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.

Parameters:
start The index, relative to the current position, of the first character in the subsequence; must be non-negative and no larger than remaining().
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().
Returns:
The new character buffer, caller owns.
Exceptions:
IndexOutOfBoundsException if the preconditions on start and end fail.

Implements decaf::nio::CharBuffer.


Field Documentation


The documentation for this class was generated from the following file:

Generated on 1 Dec 2014 for activemq-cpp-3.8.2 by  doxygen 1.6.1