activemq-cpp-3.9.0
decaf::lang::StringBuffer Class Reference

StringBuffer is a variable size contiguous indexable array of characters. More...

#include <src/main/decaf/lang/StringBuffer.h>

Inheritance diagram for decaf::lang::StringBuffer:

Public Member Functions

 StringBuffer ()
 Creates an empty StringBuffer instance with a capacity of 16. More...
 
 StringBuffer (int capacity)
 Creates an empty StringBuffer instance with the given capacity. More...
 
 StringBuffer (const String &source)
 Constructs a string buffer initialized to the contents of the specified string. More...
 
 StringBuffer (const CharSequence *source)
 Constructs a string buffer initialized to the contents of the specified string. More...
 
virtual ~StringBuffer ()
 
virtual int capacity () const
 Returns the current capacity. More...
 
virtual char charAt (int index) const
 Returns the character at the given index. More...
 
virtual void ensureCapacity (int minCapacity)
 Ensures that the capacity is at least equal to the specified min value. More...
 
virtual void getChars (int start, int end, char *dst, int dstSize, int dstStart) const
 Copies characters from this character buffer into the given character array. More...
 
virtual int indexOf (const String &value) const
 Search for the index within this string of the first occurrence of the specified substring. More...
 
virtual int indexOf (const String &value, int start) const
 Search for the index within this string of the first occurrence of the specified substring starting at the given position and moving towards the end of this String. More...
 
virtual int lastIndexOf (const String &value) const
 Search for the last index within this string where the given substring can be found. More...
 
virtual int lastIndexOf (const String &value, int start) const
 Search for the last index within this string where the given substring can be found starting from the specified index and moving towards the beginning of the string. More...
 
virtual int length () const
 Returns the current length of the String that has been built. More...
 
virtual void setLength (int length)
 Sets the length of this character buffer. More...
 
virtual void setCharAt (int index, char value)
 Sets the character at the specified index to the new char value given. More...
 
virtual String substring (int start) const
 Returns a new String that contains a subset of the characters currently contained in this character buffer. More...
 
virtual String substring (int start, int end) const
 Returns a new String that contains a subset of the characters currently contained in this character buffer. More...
 
virtual CharSequencesubSequence (int start, int end) const
 Creates and returns a new CharSequence object that is a subset of the characters contained in this character buffer. More...
 
virtual String toString () const
 Returns a String that represents the contents of this buffer. More...
 
virtual void trimToSize ()
 Attempts to reduce storage used for the character sequence. More...
 
template<typename POINTER >
StringBufferappend (const POINTER *pointer)
 Appends the string representation of the given object pointer. More...
 
template<typename TYPE >
StringBufferappend (const Pointer< TYPE > pointer)
 Appends the string representation of the given object pointer. More...
 
StringBufferappend (bool value)
 Appends the string representation of the given boolean value. More...
 
StringBufferappend (char value)
 Appends the given char value into the internal char buffer. More...
 
StringBufferappend (short value)
 Appends the given short value into the internal char buffer. More...
 
StringBufferappend (int value)
 Appends the given int value into the internal char buffer. More...
 
StringBufferappend (long long value)
 Appends the given long long value into the internal char buffer. More...
 
StringBufferappend (float value)
 Appends the given float value into the internal char buffer. More...
 
StringBufferappend (double value)
 Appends the given double value into the internal char buffer. More...
 
StringBufferappend (const char *value)
 Appends the contents of the given C string into this buffer. More...
 
StringBufferappend (const char *value, int offset, int length)
 Appends the given subsequence of the given C string into this buffer. More...
 
StringBufferappend (const CharSequence *value)
 Appends the contents of the CharSequence into this buffer, if the CharSequence pointer is NULL then this method appends the string "null" to this Buffer. More...
 
StringBufferappend (const CharSequence *value, int offset, int length)
 Appends the given CharSequence to this buffer starting at the given offset and ending after the length number of characters has been append. More...
 
StringBufferappend (const String &value)
 Appends the contents of the String into this buffer. More...
 
StringBufferappend (const StringBuilder &value)
 Appends the contents of the StringBuffer into this buffer. More...
 
StringBufferdeleteRange (int start, int end)
 Removes the characters in a substring of this buffer. More...
 
StringBufferdeleteCharAt (int index)
 Deletes the char at the specified position in this buffer, length decreases by one. More...
 
template<typename POINTER >
StringBufferinsert (int index, const POINTER *pointer)
 Inserts the string representation of the given object pointer. More...
 
template<typename TYPE >
StringBufferinsert (int index, const Pointer< TYPE > pointer)
 Inserts the string representation of the given object pointer. More...
 
StringBufferinsert (int index, char value)
 Inserts the given char into the character buffer at the given index. More...
 
StringBufferinsert (int index, bool value)
 Inserts the given boolean into the character buffer at the given index. More...
 
StringBufferinsert (int index, short value)
 Inserts the given short into the character buffer at the given index. More...
 
StringBufferinsert (int index, int value)
 Inserts the given int into the character buffer at the given index. More...
 
StringBufferinsert (int index, long long value)
 Inserts the given long long into the character buffer at the given index. More...
 
StringBufferinsert (int index, float value)
 Inserts the given float into the character buffer at the given index. More...
 
StringBufferinsert (int index, double value)
 Inserts the given double into the character buffer at the given index. More...
 
StringBufferinsert (int index, const char *value)
 Inserts the given C string into the character buffer at the given index. More...
 
StringBufferinsert (int index, const String &value)
 Inserts the given String into the character buffer at the given index. More...
 
StringBufferinsert (int index, const std::string &value)
 Inserts the given std::string into the character buffer at the given index. More...
 
StringBufferinsert (int index, const char *value, int offset, int length)
 Inserts the given C string into the character buffer at the given index starting from the given offset into the string and copying up to length chars from the string into this buffer. More...
 
StringBufferinsert (int index, const CharSequence *value)
 Inserts the given CharSequence into the character buffer at the given index starting from the given offset into the string and copying up to length chars from the string into this buffer. More...
 
StringBufferinsert (int index, const CharSequence *value, int offset, int length)
 Inserts the given CharSequence into the character buffer at the given index starting from the given offset into the string and copying up to length chars from the string into this buffer. More...
 
StringBufferreplace (int start, int end, const String &value)
 Replace some number of characters in this Buffer with the value given. More...
 
StringBufferreverse ()
 Reverses the order of characters in this builder. More...
 
- Public Member Functions inherited from decaf::lang::AbstractStringBuilder
 AbstractStringBuilder ()
 
 AbstractStringBuilder (int capacity)
 
 AbstractStringBuilder (const String &source)
 
 AbstractStringBuilder (const std::string &source)
 
 AbstractStringBuilder (const CharSequence *source)
 
virtual ~AbstractStringBuilder ()
 
- Public Member Functions inherited from decaf::internal::util::concurrent::SynchronizableImpl
 SynchronizableImpl ()
 
virtual ~SynchronizableImpl ()
 
virtual void lock ()
 Locks the object. More...
 
virtual bool tryLock ()
 Attempts to Lock the object, if the lock is already held by another thread than this method returns false. More...
 
virtual void unlock ()
 Unlocks the object. More...
 
virtual void wait ()
 Waits on a signal from this object, which is generated by a call to Notify. More...
 
virtual void wait (long long millisecs)
 Waits on a signal from this object, which is generated by a call to Notify. More...
 
virtual void wait (long long millisecs, int nanos)
 Waits on a signal from this object, which is generated by a call to Notify. More...
 
virtual void notify ()
 Signals a waiter on this object that it can now wake up and continue. More...
 
virtual void notifyAll ()
 Signals the waiters on this object that it can now wake up and continue. More...
 
- Public Member Functions inherited from decaf::util::concurrent::Synchronizable
virtual ~Synchronizable ()
 
- Public Member Functions inherited from decaf::lang::Appendable
virtual ~Appendable ()
 

Additional Inherited Members

- Protected Member Functions inherited from decaf::lang::AbstractStringBuilder
void doAppendNull ()
 Appends the string "null" to the current character buffer. More...
 
void doAppend (const char value)
 Appends the given char to this buffer. More...
 
void doAppend (const char *value)
 Appends the given C string to this buffer. More...
 
void doAppend (const char *value, int offset, int length)
 Appends the given C string to this buffer starting at the given offset and ending after the length number of characters has been appended. More...
 
void doAppend (const CharSequence *value)
 Appends the given CharSequence to this buffer. More...
 
void doAppend (const CharSequence *value, int offset, int length)
 Appends the given CharSequence to this buffer starting at the given offset and ending after the length number of characters has been appended. More...
 
void doAppend (const std::string &value)
 Append the given std::string to this buffer. More...
 
void doAppend (const String &value)
 Append the given String to this buffer. More...
 
void doAppend (const AbstractStringBuilder &value)
 Append the given AbstractStringBuilder to this buffer. More...
 
void doDeleteRange (int start, int end)
 Delete the characters in the range start - end. More...
 
void doDeleteCharAt (int index)
 Deletes the character at the given index from this buffer. More...
 
void doInsert (int index, char value)
 Inserts a single char value at the given index. More...
 
void doInsert (int index, const char *value)
 Inserts a C string value at the given index. More...
 
void doInsert (int index, const String &value)
 Inserts a String value at the given index. More...
 
void doInsert (int index, const std::string &value)
 Inserts a std::string value at the given index. More...
 
void doInsert (int index, const char *value, int offset, int length)
 Inserts the given C string at the given index in this buffer starting at the given offset and ending after the length number of characters has been appended. More...
 
void doInsert (int index, const CharSequence *value)
 Inserts the given CharSequence at the given index in this buffer. More...
 
void doInsert (int index, const CharSequence *value, int start, int end)
 Inserts the given CharSequence at the given index in this buffer starting at the given index and ending at the specified end index. More...
 
void doReplace (int start, int end, const String &value)
 Replace some number of characters in this Buffer with the value given. More...
 
void doReverse ()
 Reverses the characters contained in this character buffer. More...
 
- Protected Attributes inherited from decaf::internal::util::concurrent::SynchronizableImpl
decaf::util::concurrent::Mutex mutex
 
- Static Protected Attributes inherited from decaf::lang::AbstractStringBuilder
static const int INITIAL_CAPACITY
 

Detailed Description

StringBuffer is a variable size contiguous indexable array of characters.

The length of the StringBuffer is the number of characters it contains. The capacity of the StringBuffer is the number of characters it can hold.

Characters may be inserted at any position up to the length of the StringBuffer, increasing the length of the StringBuffer. Characters at any position in the StringBuffer may be replaced, which does not affect the StringBuffer length.

The capacity of a StringBuffer may be specified when the StringBuffer is created. If the capacity of the StringBuffer is exceeded, the capacity is increased.

StringBuffer objects are safe for use by multiple threads. The methods are synchronized where necessary so that all the operations on any particular instance behave as if they occur in some serial order that is consistent with the order of the method calls made by each of the individual threads involved.

See also
String
StringBuffer
Since
1.0

Constructor & Destructor Documentation

decaf::lang::StringBuffer::StringBuffer ( )

Creates an empty StringBuffer instance with a capacity of 16.

decaf::lang::StringBuffer::StringBuffer ( int  capacity)

Creates an empty StringBuffer instance with the given capacity.

Parameters
capacityThe initial capacity to give this new instance.
Exceptions
NegativeArraySizeExceptionif the given capacity is less than zero.
decaf::lang::StringBuffer::StringBuffer ( const String source)

Constructs a string buffer initialized to the contents of the specified string.

The initial capacity of the string builder is 16 plus the length of the string argument.

Parameters
sourceThe String whose contents are to be copied into this StringBuffer.
decaf::lang::StringBuffer::StringBuffer ( const CharSequence source)

Constructs a string buffer initialized to the contents of the specified string.

The initial capacity of the string builder is 16 plus the length of the string argument.

Parameters
sourceThe CharSequence whose contents are to be copied into this StringBuffer.
Exceptions
NullPointerExceptionif the CharSequence pointer is NULL.
virtual decaf::lang::StringBuffer::~StringBuffer ( )
virtual

Member Function Documentation

template<typename POINTER >
StringBuffer& decaf::lang::StringBuffer::append ( const POINTER *  pointer)
inline

Appends the string representation of the given object pointer.

If the pointer is NULL then the value "null" is appended to this StringBuffer.

Parameters
pointerA pointer to some object that must define a toString method.
Returns
a reference to this StringBuffer so that operations can be chained.

References NULL.

template<typename TYPE >
StringBuffer& decaf::lang::StringBuffer::append ( const Pointer< TYPE pointer)
inline

Appends the string representation of the given object pointer.

If the pointer is NULL then the value "null" is appended to this StringBuffer.

Parameters
pointerA pointer to some object that must define a toString method.
Returns
a reference to this StringBuffer so that operations can be chained.

References NULL.

StringBuffer& decaf::lang::StringBuffer::append ( bool  value)

Appends the string representation of the given boolean value.

Parameters
valueThe value to append to the contents of the StringBuffer.
Returns
a reference to this StringBuffer so that operations can be chained.
StringBuffer& decaf::lang::StringBuffer::append ( char  value)
virtual

Appends the given char value into the internal char buffer.

Parameters
valueThe value to append to the contents of the StringBuffer.
Returns
a reference to this StringBuffer so that operations can be chained.

Implements decaf::lang::Appendable.

StringBuffer& decaf::lang::StringBuffer::append ( short  value)

Appends the given short value into the internal char buffer.

Parameters
valueThe value to append to the contents of the StringBuffer.
Returns
a reference to this StringBuffer so that operations can be chained.
StringBuffer& decaf::lang::StringBuffer::append ( int  value)

Appends the given int value into the internal char buffer.

Parameters
valueThe value to append to the contents of the StringBuffer.
Returns
a reference to this StringBuffer so that operations can be chained.
StringBuffer& decaf::lang::StringBuffer::append ( long long  value)

Appends the given long long value into the internal char buffer.

Parameters
valueThe value to append to the contents of the StringBuffer.
Returns
a reference to this StringBuffer so that operations can be chained.
StringBuffer& decaf::lang::StringBuffer::append ( float  value)

Appends the given float value into the internal char buffer.

Parameters
valueThe value to append to the contents of the StringBuffer.
Returns
a reference to this StringBuffer so that operations can be chained.
StringBuffer& decaf::lang::StringBuffer::append ( double  value)

Appends the given double value into the internal char buffer.

Parameters
valueThe value to append to the contents of the StringBuffer.
Returns
a reference to this StringBuffer so that operations can be chained.
StringBuffer& decaf::lang::StringBuffer::append ( const char *  value)

Appends the contents of the given C string into this buffer.

Parameters
valueThe value to append to the contents of the StringBuffer.
Returns
a reference to this StringBuffer so that operations can be chained.
StringBuffer& decaf::lang::StringBuffer::append ( const char *  value,
int  offset,
int  length 
)

Appends the given subsequence of the given C string into this buffer.

Parameters
valueThe C string value to be appended into this buffer.
offsetThe starting position into the C string array.
lengthThe number of characters to copy from the given array.
Exceptions
NullPointerExceptionif the pointer is NULL.
IndexOutOfBoundsExceptionif offset or length is negative or the value of offset + length is greater than the strings length.
StringBuffer& decaf::lang::StringBuffer::append ( const CharSequence value)
virtual

Appends the contents of the CharSequence into this buffer, if the CharSequence pointer is NULL then this method appends the string "null" to this Buffer.

Parameters
valueThe CharSequence value to be appended into this buffer.
Returns
a reference to this StringBuffer so that operations can be chained.

Implements decaf::lang::Appendable.

StringBuffer& decaf::lang::StringBuffer::append ( const CharSequence value,
int  offset,
int  length 
)
virtual

Appends the given CharSequence to this buffer starting at the given offset and ending after the length number of characters has been append.

If the given CharSequence pointer is NULL then this method appends the string "null".

Parameters
valueThe CharSequence value to be appended into this buffer.
offsetThe starting position into the CharSequence.
lengthThe number of characters to copy from the given CharSequence.
Exceptions
IndexOutOfBoundsExceptionif offset or length is negative or the value of offset + length is greater than the strings length.

Implements decaf::lang::Appendable.

StringBuffer& decaf::lang::StringBuffer::append ( const String value)

Appends the contents of the String into this buffer.

Parameters
valueThe value to append to the contents of the StringBuffer.
Returns
a reference to this StringBuffer so that operations can be chained.
StringBuffer& decaf::lang::StringBuffer::append ( const StringBuilder value)

Appends the contents of the StringBuffer into this buffer.

Parameters
valueThe value to append to the contents of the StringBuffer.
Returns
a reference to this StringBuffer so that operations can be chained.
virtual int decaf::lang::StringBuffer::capacity ( ) const
virtual

Returns the current capacity.

The capacity indicates the amount of space available in the internal character buffer, when the number of characters inserted exceeds the current capacity the internal buffer is reallocated and old contents copied to the new buffer.

Returns
the current capacity value.

Reimplemented from decaf::lang::AbstractStringBuilder.

virtual char decaf::lang::StringBuffer::charAt ( int  index) const
virtual

Returns the character at the given index.

Parameters
indexThe index in this buffer where the character to return is located.
Exceptions
IndexOutOfBoundsExceptionif index < 0 or index >= length().

Reimplemented from decaf::lang::AbstractStringBuilder.

StringBuffer& decaf::lang::StringBuffer::deleteCharAt ( int  index)

Deletes the char at the specified position in this buffer, length decreases by one.

Parameters
indexThe index in this buffer where the character to delete is located.
Returns
a reference to this StringBuffer so that operations can be chained.
Exceptions
StringIndexOutOfBoundsExceptionif the index is negative or greater than or equal to length().
StringBuffer& decaf::lang::StringBuffer::deleteRange ( int  start,
int  end 
)

Removes the characters in a substring of this buffer.

The substring begins at the specified start and extends to the character at index end - 1 or to the end of the sequence if end is greater than the current length() value. If start is equal to end, no changes are made.

Parameters
startThe starting index to delete from this buffer.
endThe ending index (exclusive) to delete from this buffer.
Returns
a reference to this StringBuffer so that operations can be chained.
Exceptions
StringIndexOutOfBoundsExceptionif start is negative, greater than length(), or greater than end.
virtual void decaf::lang::StringBuffer::ensureCapacity ( int  minCapacity)
virtual

Ensures that the capacity is at least equal to the specified min value.

If the current capacity is less than the given value, then this buffer backing this instance will be reallocated and the old contents copied into the new buffer. The new capacity is set to either the given value or twice the old capacity + 2 depending on which is larger.

If the minimumCapacity argument is negative this method does nothing.

Parameters
minCapacityThe minimum capacity to ensure exists in this buffer.

Reimplemented from decaf::lang::AbstractStringBuilder.

virtual void decaf::lang::StringBuffer::getChars ( int  start,
int  end,
char *  dst,
int  dstSize,
int  dstStart 
) const
virtual

Copies characters from this character buffer into the given character array.

Parameters
startThe index in this buffer to start the copy from
endThe index in this buffer where the copy ends.
destThe destination character array where the values are copied.
destSizeThe size of the destination array.
destStartThe index in the destination array to start the copy at.
Exceptions
NullPointerExceptionif the dst pointer is NULL
IndexOutOfBoundsExceptionif: start or end is negative dstSize or dstStart is negative start is greater than end dstStart is greater than dstSize dstStart + (end - start) is greater than the dstSize

Reimplemented from decaf::lang::AbstractStringBuilder.

virtual int decaf::lang::StringBuffer::indexOf ( const String value) const
virtual

Search for the index within this string of the first occurrence of the specified substring.

Parameters
valueThe String to locate within this string buffer.
Returns
the index of the specified substring within this string buffer or -1 if not found.

Reimplemented from decaf::lang::AbstractStringBuilder.

virtual int decaf::lang::StringBuffer::indexOf ( const String value,
int  start 
) const
virtual

Search for the index within this string of the first occurrence of the specified substring starting at the given position and moving towards the end of this String.

Parameters
valueThe String to locate within this string buffer.
startThe index to start the search from.
Returns
the index of the specified substring within this string buffer or -1 if not found.

Reimplemented from decaf::lang::AbstractStringBuilder.

template<typename POINTER >
StringBuffer& decaf::lang::StringBuffer::insert ( int  index,
const POINTER *  pointer 
)
inline

Inserts the string representation of the given object pointer.

If the pointer is NULL then the value "null" is inserted to this StringBuffer.

Parameters
indexThe position in the buffer to insert the char value.
pointerA pointer to some object that must define a toString method.
Returns
a reference to this StringBuffer so that operations can be chained.

References NULL.

template<typename TYPE >
StringBuffer& decaf::lang::StringBuffer::insert ( int  index,
const Pointer< TYPE pointer 
)
inline

Inserts the string representation of the given object pointer.

If the pointer is NULL then the value "null" is inserted to this StringBuffer.

Parameters
indexThe position in the buffer to insert the char value.
pointerA pointer to some object that must define a toString method.
Returns
a reference to this StringBuffer so that operations can be chained.

References NULL.

StringBuffer& decaf::lang::StringBuffer::insert ( int  index,
char  value 
)

Inserts the given char into the character buffer at the given index.

The contents of the buffer are shifted up by one from the given index prior to insertion.

Parameters
indexThe position in the buffer to insert the char value.
valueThe value to insert at the given index.
Returns
a reference to this StringBuffer so that operations can be chained.
Exceptions
IndexOutOfBoundsExceptionif the index is negative or greater than or equal to length().
StringBuffer& decaf::lang::StringBuffer::insert ( int  index,
bool  value 
)

Inserts the given boolean into the character buffer at the given index.

The value is converted to a String in the same fashion as calling String::valueOf(bool).

Parameters
indexThe position in the buffer to insert the boolean value.
valueThe value to insert at the given index.
Returns
a reference to this StringBuffer so that operations can be chained.
Exceptions
IndexOutOfBoundsExceptionif the index is negative or greater than or equal to length().
StringBuffer& decaf::lang::StringBuffer::insert ( int  index,
short  value 
)

Inserts the given short into the character buffer at the given index.

The value is converted to a String in the same fashion as calling String::valueOf(short).

Parameters
indexThe position in the buffer to insert the short value.
valueThe value to insert at the given index.
Returns
a reference to this StringBuffer so that operations can be chained.
Exceptions
IndexOutOfBoundsExceptionif the index is negative or greater than or equal to length().
StringBuffer& decaf::lang::StringBuffer::insert ( int  index,
int  value 
)

Inserts the given int into the character buffer at the given index.

The value is converted to a String in the same fashion as calling String::valueOf(int).

Parameters
indexThe position in the buffer to insert the int value.
valueThe value to insert at the given index.
Returns
a reference to this StringBuffer so that operations can be chained.
Exceptions
IndexOutOfBoundsExceptionif the index is negative or greater than or equal to length().
StringBuffer& decaf::lang::StringBuffer::insert ( int  index,
long long  value 
)

Inserts the given long long into the character buffer at the given index.

The value is converted to a String in the same fashion as calling String::valueOf(long long).

Parameters
indexThe position in the buffer to insert the long long value.
valueThe value to insert at the given index.
Returns
a reference to this StringBuffer so that operations can be chained.
Exceptions
IndexOutOfBoundsExceptionif the index is negative or greater than or equal to length().
StringBuffer& decaf::lang::StringBuffer::insert ( int  index,
float  value 
)

Inserts the given float into the character buffer at the given index.

The value is converted to a String in the same fashion as calling String::valueOf(float).

Parameters
indexThe position in the buffer to insert the float value.
valueThe value to insert at the given index.
Returns
a reference to this StringBuffer so that operations can be chained.
Exceptions
IndexOutOfBoundsExceptionif the index is negative or greater than or equal to length().
StringBuffer& decaf::lang::StringBuffer::insert ( int  index,
double  value 
)

Inserts the given double into the character buffer at the given index.

The value is converted to a String in the same fashion as calling String::valueOf(double).

Parameters
indexThe position in the buffer to insert the double value.
valueThe value to insert at the given index.
Returns
a reference to this StringBuffer so that operations can be chained.
Exceptions
IndexOutOfBoundsExceptionif the index is negative or greater than or equal to length().
StringBuffer& decaf::lang::StringBuffer::insert ( int  index,
const char *  value 
)

Inserts the given C string into the character buffer at the given index.

Parameters
indexThe position in the buffer to insert the char value.
valueThe value to insert at the given index.
Returns
a reference to this StringBuffer so that operations can be chained.
Exceptions
NullPointerExceptionif the target C string pointer is NULL.
IndexOutOfBoundsExceptionif the index is negative or greater than or equal to length().
StringBuffer& decaf::lang::StringBuffer::insert ( int  index,
const String value 
)

Inserts the given String into the character buffer at the given index.

Parameters
indexThe position in the buffer to insert the char value.
valueThe value to insert at the given index.
Returns
a reference to this StringBuffer so that operations can be chained.
Exceptions
NullPointerExceptionif the target C string pointer is NULL.
IndexOutOfBoundsExceptionif the index is negative or greater than or equal to length().
StringBuffer& decaf::lang::StringBuffer::insert ( int  index,
const std::string &  value 
)

Inserts the given std::string into the character buffer at the given index.

Parameters
indexThe position in the buffer to insert the char value.
valueThe value to insert at the given index.
Returns
a reference to this StringBuffer so that operations can be chained.
Exceptions
NullPointerExceptionif the target std::string pointer is NULL.
IndexOutOfBoundsExceptionif the index is negative or greater than or equal to length().
StringBuffer& decaf::lang::StringBuffer::insert ( int  index,
const char *  value,
int  offset,
int  length 
)

Inserts the given C string into the character buffer at the given index starting from the given offset into the string and copying up to length chars from the string into this buffer.

Parameters
indexThe position in the buffer to insert the char value.
valueThe value to insert at the given index.
offsetThe offset into the C string to start the copy from.
lengthThe number of characters to copy from the given C string.
Returns
a reference to this StringBuffer so that operations can be chained.
Exceptions
NullPointerExceptionif the target C string pointer is NULL.
IndexOutOfBoundsExceptionif the index is negative or greater than or equal to length(). If offset or length is negative or offset > the string length + length.
StringBuffer& decaf::lang::StringBuffer::insert ( int  index,
const CharSequence value 
)

Inserts the given CharSequence into the character buffer at the given index starting from the given offset into the string and copying up to length chars from the string into this buffer.

If the CharSequence pointer is NULL then this method inserts the string "null" into this Buffer.

Parameters
indexThe position in the buffer to insert the char value.
valueThe value to insert at the given index.
Returns
a reference to this StringBuffer so that operations can be chained.
Exceptions
IndexOutOfBoundsExceptionif the index is negative or greater than or equal to length().
StringBuffer& decaf::lang::StringBuffer::insert ( int  index,
const CharSequence value,
int  offset,
int  length 
)

Inserts the given CharSequence into the character buffer at the given index starting from the given offset into the string and copying up to length chars from the string into this buffer.

If the CharSequence pointer is NULL then this method inserts the string "null" into this Buffer.

Parameters
indexThe position in the buffer to insert the char value.
valueThe value to insert at the given index.
offsetThe offset into the CharSequence to start the copy from.
lengthThe number of characters to copy from the given CharSequence.
Returns
a reference to this StringBuffer so that operations can be chained.
Exceptions
IndexOutOfBoundsExceptionif the index is negative or greater than or equal to length(). If offset or length is negative or offset > the string length + length.
virtual int decaf::lang::StringBuffer::lastIndexOf ( const String value) const
virtual

Search for the last index within this string where the given substring can be found.

Parameters
valueThe String to locate within this string buffer.
Returns
the last index of the specified substring within this string buffer or -1 if not found.

Reimplemented from decaf::lang::AbstractStringBuilder.

virtual int decaf::lang::StringBuffer::lastIndexOf ( const String value,
int  start 
) const
virtual

Search for the last index within this string where the given substring can be found starting from the specified index and moving towards the beginning of the string.

Parameters
valueThe String to locate within this string buffer.
startThe index to start the search from.
Returns
the last index of the specified substring within this string buffer or -1 if not found.

Reimplemented from decaf::lang::AbstractStringBuilder.

virtual int decaf::lang::StringBuffer::length ( ) const
virtual

Returns the current length of the String that has been built.

Returns
the current number of characters that have been inserted.

Reimplemented from decaf::lang::AbstractStringBuilder.

StringBuffer& decaf::lang::StringBuffer::replace ( int  start,
int  end,
const String value 
)

Replace some number of characters in this Buffer with the value given.

The characters replaced start at the given index and end at the given end value (exclusive). If the replacement string value is longer the internal buffer is lengthened to accommodate the new value.

Parameters
startThe starting index to replace in the buffer (inclusive).
endThe ending index of the replacement operation (exclusive).
valueThe new string value to replace the older value.
Returns
a reference to this StringBuffer so that operations can be chained.
Exceptions
IndexOutOfBoundsExceptionif start is negative, greater than end or greater than length().
StringBuffer& decaf::lang::StringBuffer::reverse ( )

Reverses the order of characters in this builder.

Returns
a reference to this StringBuffer so that operations can be chained.
virtual void decaf::lang::StringBuffer::setCharAt ( int  index,
char  value 
)
virtual

Sets the character at the specified index to the new char value given.

Parameters
indexThe index of the character to modify.
valueThe new char value to assign at the given index.
Exceptions
IndexOutOfBoundsExceptionif index is negative or greater than length().

Reimplemented from decaf::lang::AbstractStringBuilder.

virtual void decaf::lang::StringBuffer::setLength ( int  length)
virtual

Sets the length of this character buffer.

The backing buffer is changed to a new character buffer whose length is specified by the argument. Each character in the old buffer is copied into the new buffer up to the given length value. If the new length is greater than the old buffer length then the additional character are all set to '\0'.

Parameters
lengthThe new length to give this character buffer
Exceptions
IndexOutOfBoundsExceptionif length is less than zero.

Reimplemented from decaf::lang::AbstractStringBuilder.

virtual CharSequence* decaf::lang::StringBuffer::subSequence ( int  start,
int  end 
) const
virtual

Creates and returns a new CharSequence object that is a subset of the characters contained in this character buffer.

This method behaves the same as the two parameter substring method except that it returns a pointer value instead of a String, this allows for subclasses to implement CharSequence.

Parameters
startThe starting index of the substring to create. (inclusive)
endThe ending index of the substring to create. (exclusive)
Returns
a new CharSequence pointer that is a subset of this character buffer.
Exceptions
StringIndexOutOfBoundsExceptionif start or end is less than zero, or end is greater than the length of this buffer or start is greater than end.

Reimplemented from decaf::lang::AbstractStringBuilder.

virtual String decaf::lang::StringBuffer::substring ( int  start) const
virtual

Returns a new String that contains a subset of the characters currently contained in this character buffer.

The substring starts at the specified index and extends to the end of this character buffer.

Parameters
startThe starting index of the substring to create.
Returns
a new String that is a subset of this character buffer.
Exceptions
StringIndexOutOfBoundsExceptionif start is less than zero, or greater than the length of this buffer.

Reimplemented from decaf::lang::AbstractStringBuilder.

virtual String decaf::lang::StringBuffer::substring ( int  start,
int  end 
) const
virtual

Returns a new String that contains a subset of the characters currently contained in this character buffer.

The substring starts at the specified index and extends to the given end index.

Parameters
startThe starting index of the substring to create. (inclusive)
endThe ending index of the substring to create. (exclusive)
Returns
a new String that is a subset of this character buffer.
Exceptions
StringIndexOutOfBoundsExceptionif start or end is less than zero, or end is greater than the length of this buffer or start is greater than end.

Reimplemented from decaf::lang::AbstractStringBuilder.

virtual String decaf::lang::StringBuffer::toString ( ) const
virtual

Returns a String that represents the contents of this buffer.

Any changes made to this buffer after calling this method will not be reflected in the String value that is returned.

Reimplemented from decaf::lang::AbstractStringBuilder.

virtual void decaf::lang::StringBuffer::trimToSize ( )
virtual

Attempts to reduce storage used for the character sequence.

If the buffer is larger than necessary to hold its current sequence of characters, then it may be resized to become more space efficient. Calling this method may, but is not required to, affect the value returned by a subsequent call to the capacity() method.

Reimplemented from decaf::lang::AbstractStringBuilder.


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