The String class represents an immutable sequence of chars.
More...
#include <src/main/decaf/lang/String.h>
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 () |
String & | operator= (const String &) |
String & | operator= (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:
-
index | The position to return the char at. |
- Returns:
- the char at the given position.
- Exceptions:
-
IndexOutOfBoundsException | if index is > than length() or negative |
|
virtual CharSequence * | subSequence (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:
-
start | The start index, inclusive. |
end | The end index, exclusive. |
- Returns:
- a new CharSequence
- Exceptions:
-
IndexOutOfBoundsException | if start or end > length() or start or end are negative. |
|
virtual std::string | toString () const |
| - Returns:
- the string representation of this 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:
-
source | The 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:
-
source | The 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:
-
array | The character buffer to copy into this new String object. |
size | The size of the string buffer given, in case the string is not NULL terminated. |
- Exceptions:
-
NullPointerException | if the character array parameter is NULL. |
IndexOutOfBoundsException | if 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:
-
array | The character buffer to copy into this new String object. |
size | The size of the string buffer given, in case the string is not NULL terminated. |
offset | The position to start copying from in the given buffer. |
length | The number of bytes to copy from the given buffer starting from the offset. |
- Exceptions:
-
NullPointerException | if the character array parameter is NULL. |
IndexOutOfBoundsException | if 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:
-
index | The position to return the char at. |
- Returns:
- the char at the given position.
- Exceptions:
-
IndexOutOfBoundsException | if 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] |
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:
-
start | The start index, inclusive. |
end | The end index, exclusive. |
- Returns:
- a new CharSequence
- Exceptions:
-
IndexOutOfBoundsException | if start or end > length() or start or end are negative. |
Implements decaf::lang::CharSequence.
virtual std::string decaf::lang::String::toString |
( |
| ) |
const [virtual] |
static String decaf::lang::String::valueOf |
( |
bool |
value | ) |
[static] |
Returns a String that represents the value of the given boolean value.
- Parameters:
-
value | The value whose string representation is to be returned. |
- Returns:
- "true" if the boolean is true, "false" otherwise.
static String decaf::lang::String::valueOf |
( |
float |
value | ) |
[static] |
Returns a String that represents the value of the given float value.
- Parameters:
-
value | The 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:
-
value | The 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 |
( |
long long |
value | ) |
[static] |
Returns a String that represents the value of the given 64bit long value.
- Parameters:
-
value | The value whose string representation is to be returned. |
- Returns:
- a String that contains the string representation of the 64 bit long value given.
static String decaf::lang::String::valueOf |
( |
int |
value | ) |
[static] |
Returns a String that represents the value of the given integer value.
- Parameters:
-
value | The 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 |
( |
char |
value | ) |
[static] |
Returns a String that represents the value of the given char value.
- Parameters:
-
value | The value whose string representation is to be returned. |
- Returns:
- a String that contains the single character value given.
static String decaf::lang::String::valueOf |
( |
short |
value | ) |
[static] |
Returns a String that represents the value of the given short value.
- Parameters:
-
value | The value whose string representation is to be returned. |
- Returns:
- a String that contains the string representation of the short value given.
The documentation for this class was generated from the following file: