Titanium.Buffer

Object of Titanium.
Platform Since
Android 1.7
iPhone 1.7
iPad 1.7

Summary

Buffer is a container for raw data. A buffer is created by the method Titanium.createBuffer.

Methods

Name Summary
addEventListener

Adds the specified callback as an event listener for the named event.

append

appends sourceBuffer to the current buffer. Buffer is grown dynamically to accommodate the additional data if need be.

append

same as normal append except this allows appending only sourceLength bytes from the sourceBuffer starting at sourceOffset.

clear

Clears buffer contents but does not change the size of the buffer

clone

create new copy of the current buffer

clone

Creates a new buffer from the original buffer contents starting at offset and ending at offset + length

copy

copies the contents of sourceBuffer into the current buffer at offset. will not expand buffer if there is not enough room in the current buffer to accomodate all the requested data from sourceBuffer.

copy

copies sourceLength contents from sourceBuffer starting at sourceOffset into the current buffer at offset. will not expand buffer if there is not enough room in the current buffer to accomodate all the request data from sourceBuffer.

fill

fills buffer with fillByte

fill

fills buffer starting from offset until length number of fillByte has been written or the end of the buffer is reached

fireEvent

Fires a synthesized event to any registered listeners.

getByteOrder

Gets the value of the byteOrder property.

getLength

Gets the value of the length property.

getType

Gets the value of the type property.

getValue

Gets the value of the value property.

insert

inserts sourceBuffer into the current buffer at offset. Buffer is grown to accommodate the new data.

insert

inserts sourceLength amount of data starting at sourceOffset from sourceBuffer into current buffer at offset. Buffer is grown to accommodate the new data.

release

Releases the space allocated to the buffer, sets length to 0. This is effectively the same as buffer.length = 0

removeEventListener

Removes the specified callback as an event listener for the named event.

setLength

Sets the value of the length property.

toBlob

Converts this buffer to a Titanium.Blob

toString

Converts this buffer to a String

Properties

Name Type Summary
byteOrder Number

The byte order of this buffer. The OS native byte order is used by default. creation

length Number

The length of the buffer in bytes. When length is modified the buffer will be re-sized while preserving existing data where possible. If the new buffer length is smaller than the length of the existing data then the existing data will be truncated down to the size of the new buffer. Resizing the buffer via setting length should be used sparingly due to the associated overhead.

type String

The type of data encoding to use with value. Required when value is a Number. When value is a String, Titanium.Codec.CHARSET_UTF8 is the default. creation

value Number or String

Data to be encoded. If value is a Number, type must also be set. (this is simply a convenient way of calling Titanium.Codec.encodeString or Titanium.Codec.encodeNumber). creation

Events

This type has no events.