activemq-cpp-3.6.0
decaf::lang::String Class Reference

The String class represents an immutable sequence of chars. More...

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

Inheritance diagram for decaf::lang::String:

Public Member Functions

 String ()
 Creates a new empty String object.
 String (const String &source)
 Create a new String object that represents the given STL string.
 String (const std::string &source)
 Create a new String object that represents the given STL string.
 String (const char *array, int size)
 Create a new String object that represents the given array of characters.
 String (const char *array, int size, int offset, int length)
 Create a new String object that represents the given array of characters.
virtual ~String ()
Stringoperator= (const String &)
Stringoperator= (const std::string &)
bool isEmpty () const
virtual int length () const
 
Returns
the length of the underlying character sequence.

virtual char charAt (int index) const
 Returns the Char at the specified index so long as the index is not greater than the length of the sequence.
Parameters
indexThe position to return the char at.
Returns
the char at the given position.
Exceptions
IndexOutOfBoundsExceptionif index is > than length() or negative

virtual CharSequencesubSequence (int start, int end) const
 Returns a new CharSequence that is a subsequence of this sequence.The subsequence starts with the char value at the specified index and ends with the char value at index end - 1. The length (in chars) of the returned sequence is end - start, so if start == end then an empty sequence is returned.
Parameters
startThe start index, inclusive.
endThe end index, exclusive.
Returns
a new CharSequence
Exceptions
IndexOutOfBoundsExceptionif start or end > length() or start or end are negative.

virtual std::string toString () const
 
Returns
the string representation of this CharSequence

- Public Member Functions inherited from decaf::lang::CharSequence
virtual ~CharSequence ()

Static Public Member Functions

static String valueOf (bool value)
 Returns a String that represents the value of the given boolean value.
static String valueOf (char value)
 Returns a String that represents the value of the given char value.
static String valueOf (float value)
 Returns a String that represents the value of the given float value.
static String valueOf (double value)
 Returns a String that represents the value of the given double value.
static String valueOf (short value)
 Returns a String that represents the value of the given short value.
static String valueOf (int value)
 Returns a String that represents the value of the given integer value.
static String valueOf (long long value)
 Returns a String that represents the value of the given 64bit long value.

Detailed Description

The String class represents an immutable sequence of chars.

Since
1.0

Constructor & Destructor Documentation

decaf::lang::String::String ( )

Creates a new empty String object.

decaf::lang::String::String ( const String source)

Create a new String object that represents the given STL string.

Parameters
sourceThe string to copy into this new String object.
decaf::lang::String::String ( const std::string &  source)

Create a new String object that represents the given STL string.

Parameters
sourceThe string to copy into this new String object.
decaf::lang::String::String ( const char *  array,
int  size 
)

Create a new String object that represents the given array of characters.

The method takes the size of the array as a parameter to allow for strings that are not NULL terminated, the caller can pass strlen(array) in the case where the array is properly NULL terminated.

Parameters
arrayThe character buffer to copy into this new String object.
sizeThe size of the string buffer given, in case the string is not NULL terminated.
Exceptions
NullPointerExceptionif the character array parameter is NULL.
IndexOutOfBoundsExceptionif the size parameter is negative.
decaf::lang::String::String ( const char *  array,
int  size,
int  offset,
int  length 
)

Create a new String object that represents the given array of characters.

The method takes the size of the array as a parameter to allow for strings that are not NULL terminated, the caller can pass strlen(array) in the case where the array is properly NULL terminated.

Parameters
arrayThe character buffer to copy into this new String object.
sizeThe size of the string buffer given, in case the string is not NULL terminated.
offsetThe position to start copying from in the given buffer.
lengthThe number of bytes to copy from the given buffer starting from the offset.
Exceptions
NullPointerExceptionif the character array parameter is NULL.
IndexOutOfBoundsExceptionif the size, offset or length parameter is negative or if the length to copy is greater than the span of size - offset.
virtual decaf::lang::String::~String ( )
virtual

Member Function Documentation

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

Returns the Char at the specified index so long as the index is not greater than the length of the sequence.

Parameters
indexThe position to return the char at.
Returns
the char at the given position.
Exceptions
IndexOutOfBoundsExceptionif index is > than length() or negative

Implements decaf::lang::CharSequence.

bool decaf::lang::String::isEmpty ( ) const
Returns
true if the length of this String is zero.
virtual int decaf::lang::String::length ( ) const
virtual

Returns
the length of the underlying character sequence.

Implements decaf::lang::CharSequence.

String& decaf::lang::String::operator= ( const String )
String& decaf::lang::String::operator= ( const std::string &  )
virtual CharSequence* decaf::lang::String::subSequence ( int  start,
int  end 
) const
virtual

Returns a new CharSequence that is a subsequence of this sequence.The subsequence starts with the char value at the specified index and ends with the char value at index end - 1. The length (in chars) of the returned sequence is end - start, so if start == end then an empty sequence is returned.

Parameters
startThe start index, inclusive.
endThe end index, exclusive.
Returns
a new CharSequence
Exceptions
IndexOutOfBoundsExceptionif start or end > length() or start or end are negative.

Implements decaf::lang::CharSequence.

virtual std::string decaf::lang::String::toString ( ) const
virtual

Returns
the string representation of this CharSequence

Implements decaf::lang::CharSequence.

static String decaf::lang::String::valueOf ( bool  value)
static

Returns a String that represents the value of the given boolean value.

Parameters
valueThe value whose string representation is to be returned.
Returns
"true" if the boolean is true, "false" otherwise.
static String decaf::lang::String::valueOf ( char  value)
static

Returns a String that represents the value of the given char value.

Parameters
valueThe value whose string representation is to be returned.
Returns
a String that contains the single character value given.
static String decaf::lang::String::valueOf ( float  value)
static

Returns a String that represents the value of the given float value.

Parameters
valueThe value whose string representation is to be returned.
Returns
a String that contains the string representation of the float value given.
static String decaf::lang::String::valueOf ( double  value)
static

Returns a String that represents the value of the given double value.

Parameters
valueThe value whose string representation is to be returned.
Returns
a String that contains the string representation of the double value given.
static String decaf::lang::String::valueOf ( short  value)
static

Returns a String that represents the value of the given short value.

Parameters
valueThe value whose string representation is to be returned.
Returns
a String that contains the string representation of the short value given.
static String decaf::lang::String::valueOf ( int  value)
static

Returns a String that represents the value of the given integer value.

Parameters
valueThe value whose string representation is to be returned.
Returns
a String that contains the string representation of the integer value given.
static String decaf::lang::String::valueOf ( long long  value)
static

Returns a String that represents the value of the given 64bit long value.

Parameters
valueThe value whose string representation is to be returned.
Returns
a String that contains the string representation of the 64 bit long value given.

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