Class StringBuffer

Description

Implements a mutable sequence of characters

A string buffer can be initialized with a string value and a capacity (length). The methods provided by the class are able to change the buffer, by expanding and collapsing it, reading, changing or inserting characters.

Located in /core/text/StringBuffer.class.php (line 43)

PHP2Go
   |
   --StringBuffer
Variable Summary
int $capacity
string $string
Method Summary
StringBuffer StringBuffer ([string $initStr = ""], [int $initCapacity = NULL])
void append (mixed $appendValue)
int capacity ()
string charAt (int $index)
void delete (int $start, int $end)
void deleteCharAt (int $index)
void ensureCapacity (int $minimum)
void getChars (int $srcBegin, int $srcEnd, string &$dst, [int $dstBegin = NULL])
int indexOf (string $str, [int $fromIndex = NULL])
void insert (int $index, mixed $insertValue)
int lastIndexOf (string $str, [int $fromIndex = NULL])
int length ()
void reverse ()
void setCharAt (int $index, string $ch)
void setLength (int $newLength)
string subSequence (int $start, int $end)
string subString (int $start)
string __toString ()
Variables
int $capacity (line 59)

Buffer capacity

  • access: private
string $string = "" (line 51)

Buffer contents

  • access: private
Methods
Constructor StringBuffer (line 71)

Class constructor

If $initStr and $initCapacity are missing, the initial capacity of the buffer will be 16 chars.

StringBuffer StringBuffer ([string $initStr = ""], [int $initCapacity = NULL])
  • string $initStr: Initial buffer contents
  • int $initCapacity: Initial capacity
append (line 262)

Appends a value in the end of the buffer

void append (mixed $appendValue)
  • mixed $appendValue: Value to append
capacity (line 87)

Get current buffer capacity

int capacity ()
charAt (line 128)

Read a char from the buffer, given its index

string charAt (int $index)
  • int $index: Char index
delete (line 300)

Removes a substring from the buffer

void delete (int $start, int $end)
  • int $start: Start index
  • int $end: End index
deleteCharAt (line 311)

Removes a char from the buffer

void deleteCharAt (int $index)
  • int $index: Char index
ensureCapacity (line 326)

Checks if the current buffer capacity is greater than a given lower bound

If $minimum is an integer value greater than zero, the buffer capacity will be set as the max value between $minimum and the double of the current capacity plus 2.

void ensureCapacity (int $minimum)
  • int $minimum: Lower bound
getChars (line 113)

Get a substring of the buffer and copy to a given variable

The chars between $srcBegin and $srcEnd positions are copied to the $dst variable. Optionally, a position in the target variable can be provided through the $dstBegin argument.

void getChars (int $srcBegin, int $srcEnd, string &$dst, [int $dstBegin = NULL])
  • int $srcBegin: Substring start
  • int $srcEnd: Substring end
  • string &$dst: Target variable
  • int $dstBegin: Target position
indexOf (line 145)

Get the index of the first occurence of a substring in the buffer

Returns -1 when the substring is not found.

int indexOf (string $str, [int $fromIndex = NULL])
  • string $str: Substring
  • int $fromIndex: Start index, to be used to perform the search
insert (line 281)

Inserts a value in a given index of the buffer

void insert (int $index, mixed $insertValue)
  • int $index: Insert index
  • mixed $insertValue: Insert value
lastIndexOf (line 173)

Get the index of the last occurence of a substring in the buffer

Returns -1 if the substring is not present in the buffer.

int lastIndexOf (string $str, [int $fromIndex = NULL])
  • string $str: Substring
  • int $fromIndex: Start index, to be used to perform the search
length (line 96)

Get current buffer length

int length ()
reverse (line 335)

Inverts the buffer contents

void reverse ()
setCharAt (line 230)

Changes a given position of the buffer

void setCharAt (int $index, string $ch)
  • int $index: Index
  • string $ch: Character
setLength (line 244)

Changes the length of the buffer

If the new length is greater than the current length, a sequence of "\x00" chars is used to fill the buffer. If it is lower, the buffer content is truncated.

void setLength (int $newLength)
  • int $newLength: New length
subSequence (line 217)

Get a substring from the buffer, starting at $start and ending at $end

Returns NULL if one or both limits are invalid.

string subSequence (int $start, int $end)
  • int $start: Start index
  • int $end: End index
subString (line 201)

Get a substring from the buffer, starting at $start

Returns NULL if $start is lower than 0 or greater than the buffer length.

string subString (int $start)
  • int $start: Start index
__toString (line 344)

Converts the buffer into a regular string value

string __toString ()

Redefinition of:
PHP2Go::__toString()
Generate a string representation of the object

Inherited Methods

Inherited From PHP2Go

PHP2Go::PHP2Go()
PHP2Go::equals()
PHP2Go::generateUniqueId()
PHP2Go::getClassName()
PHP2Go::getConfigVal()
PHP2Go::getLangVal()
PHP2Go::getObjectName()
PHP2Go::getParentName()
PHP2Go::hasDestructor()
PHP2Go::hashCode()
PHP2Go::isA()
PHP2Go::isSubclassOf()
PHP2Go::logError()
PHP2Go::raiseError()
PHP2Go::registerDestructor()
PHP2Go::registerShutdownFunc()
PHP2Go::retrieve()
PHP2Go::store()
PHP2Go::__toString()

Documentation generated on Sun, 07 Oct 2007 19:29:52 -0300 by phpDocumentor 1.3.2