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

A modifiable sequence of characters for use in creating and modifying Strings. More...

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

Inheritance diagram for decaf::lang::AbstractStringBuilder:

Public Member Functions

 AbstractStringBuilder ()
 
 AbstractStringBuilder (int capacity)
 
 AbstractStringBuilder (const String &source)
 
 AbstractStringBuilder (const std::string &source)
 
 AbstractStringBuilder (const CharSequence *source)
 
virtual ~AbstractStringBuilder ()
 
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...
 
- 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 ()
 

Protected Member Functions

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

Static Protected Attributes

static const int INITIAL_CAPACITY
 

Additional Inherited Members

- Protected Attributes inherited from decaf::internal::util::concurrent::SynchronizableImpl
decaf::util::concurrent::Mutex mutex
 

Detailed Description

A modifiable sequence of characters for use in creating and modifying Strings.

This class is intended as a base class for StringBuffer and StringBuilder.

See also
StringBuffer
StringBuilder
Since
1.0

Constructor & Destructor Documentation

decaf::lang::AbstractStringBuilder::AbstractStringBuilder ( )
decaf::lang::AbstractStringBuilder::AbstractStringBuilder ( int  capacity)
decaf::lang::AbstractStringBuilder::AbstractStringBuilder ( const String source)
decaf::lang::AbstractStringBuilder::AbstractStringBuilder ( const std::string &  source)
decaf::lang::AbstractStringBuilder::AbstractStringBuilder ( const CharSequence source)
virtual decaf::lang::AbstractStringBuilder::~AbstractStringBuilder ( )
virtual

Member Function Documentation

virtual int decaf::lang::AbstractStringBuilder::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 in decaf::lang::StringBuffer.

virtual char decaf::lang::AbstractStringBuilder::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 in decaf::lang::StringBuffer.

void decaf::lang::AbstractStringBuilder::doAppend ( const char  value)
protected

Appends the given char to this buffer.

Parameters
valueThe char value to be appended into this buffer.
void decaf::lang::AbstractStringBuilder::doAppend ( const char *  value)
protected

Appends the given C string to this buffer.

Parameters
valueThe C string value to be appended into this buffer.
Exceptions
NullPointerExceptionif the pointer is NULL.
void decaf::lang::AbstractStringBuilder::doAppend ( const char *  value,
int  offset,
int  length 
)
protected

Appends the given C string to this buffer starting at the given offset and ending after the length number of characters has been appended.

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.
void decaf::lang::AbstractStringBuilder::doAppend ( const CharSequence value)
protected

Appends the given CharSequence to this buffer.

Parameters
valueThe CharSequence value to be appended into this buffer.
Exceptions
NullPointerExceptionif the pointer is NULL.
void decaf::lang::AbstractStringBuilder::doAppend ( const CharSequence value,
int  offset,
int  length 
)
protected

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

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
NullPointerExceptionif the pointer is NULL.
IndexOutOfBoundsExceptionif offset or length is negative or the value of offset + length is greater than the strings length.
void decaf::lang::AbstractStringBuilder::doAppend ( const std::string &  value)
protected

Append the given std::string to this buffer.

Parameters
valueThe String instance to append into this buffer.
void decaf::lang::AbstractStringBuilder::doAppend ( const String value)
protected

Append the given String to this buffer.

Parameters
valueThe String instance to append into this buffer.
void decaf::lang::AbstractStringBuilder::doAppend ( const AbstractStringBuilder value)
protected

Append the given AbstractStringBuilder to this buffer.

Parameters
valueThe String instance to append into this buffer.
void decaf::lang::AbstractStringBuilder::doAppendNull ( )
protected

Appends the string "null" to the current character buffer.

void decaf::lang::AbstractStringBuilder::doDeleteCharAt ( int  index)
protected

Deletes the character at the given index from this buffer.

Parameters
indexThe index of the character to delete.
void decaf::lang::AbstractStringBuilder::doDeleteRange ( int  start,
int  end 
)
protected

Delete the characters in the range start - end.

Parameters
startThe starting index of the delete operation
endThe ending index of the delete operation (exclusive).
void decaf::lang::AbstractStringBuilder::doInsert ( int  index,
char  value 
)
protected

Inserts a single char value at the given index.

Parameters
indexThe index to insert the char at
valueThe char value to insert.
void decaf::lang::AbstractStringBuilder::doInsert ( int  index,
const char *  value 
)
protected

Inserts a C string value at the given index.

Parameters
indexThe index to insert the C string at
valueThe char value to insert.
void decaf::lang::AbstractStringBuilder::doInsert ( int  index,
const String value 
)
protected

Inserts a String value at the given index.

Parameters
indexThe index to insert the String at
valueThe char value to insert.
void decaf::lang::AbstractStringBuilder::doInsert ( int  index,
const std::string &  value 
)
protected

Inserts a std::string value at the given index.

Parameters
indexThe index to insert the std::string at
valueThe char value to insert.
void decaf::lang::AbstractStringBuilder::doInsert ( int  index,
const char *  value,
int  offset,
int  length 
)
protected

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.

Parameters
indexThe index in this buffer to start inserting the C string.
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 index, offset or length is negative or the value of offset + length is greater than the strings length.
void decaf::lang::AbstractStringBuilder::doInsert ( int  index,
const CharSequence value 
)
protected

Inserts the given CharSequence at the given index in this buffer.

Parameters
indexThe index in this buffer to start inserting the CharSequence.
valueThe CharSequence value to be appended into this buffer.
Exceptions
NullPointerExceptionif the pointer is NULL.
IndexOutOfBoundsExceptionif index is negative or greater than length().
void decaf::lang::AbstractStringBuilder::doInsert ( int  index,
const CharSequence value,
int  start,
int  end 
)
protected

Inserts the given CharSequence at the given index in this buffer starting at the given index and ending at the specified end index.

If the CharSequence pointer is NULL the string "null" is inserted.

Parameters
indexThe index in this buffer to start inserting the CharSequence.
valueThe CharSequence value to be appended into this buffer.
startThe starting index into the CharSequence.
endThe end index in the CharSequence to be inserted into this Buffer.
Exceptions
IndexOutOfBoundsExceptionif index, start or end is negative or the value of start < end or the end index is greater than the sequence length.
void decaf::lang::AbstractStringBuilder::doReplace ( int  start,
int  end,
const String value 
)
protected

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.
Exceptions
IndexOutOfBoundsExceptionif start is negative, greater than end or greater than length().
void decaf::lang::AbstractStringBuilder::doReverse ( )
protected

Reverses the characters contained in this character buffer.

virtual void decaf::lang::AbstractStringBuilder::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 in decaf::lang::StringBuffer.

virtual void decaf::lang::AbstractStringBuilder::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 in decaf::lang::StringBuffer.

virtual int decaf::lang::AbstractStringBuilder::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 in decaf::lang::StringBuffer.

virtual int decaf::lang::AbstractStringBuilder::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 in decaf::lang::StringBuffer.

virtual int decaf::lang::AbstractStringBuilder::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 in decaf::lang::StringBuffer.

virtual int decaf::lang::AbstractStringBuilder::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 in decaf::lang::StringBuffer.

virtual int decaf::lang::AbstractStringBuilder::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 in decaf::lang::StringBuffer, and decaf::lang::StringBuilder.

virtual void decaf::lang::AbstractStringBuilder::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 in decaf::lang::StringBuffer.

virtual void decaf::lang::AbstractStringBuilder::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 in decaf::lang::StringBuffer.

virtual CharSequence* decaf::lang::AbstractStringBuilder::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 in decaf::lang::StringBuffer.

virtual String decaf::lang::AbstractStringBuilder::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 in decaf::lang::StringBuffer.

virtual String decaf::lang::AbstractStringBuilder::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 in decaf::lang::StringBuffer.

virtual String decaf::lang::AbstractStringBuilder::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 in decaf::lang::StringBuffer.

virtual void decaf::lang::AbstractStringBuilder::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 in decaf::lang::StringBuffer.

Field Documentation

const int decaf::lang::AbstractStringBuilder::INITIAL_CAPACITY
staticprotected

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