Titanium.Buffer
> Titanium.Buffer

Buffer is a mutable, resizable container for raw data.

A Buffer works like a resizable array of byte values.

Use the Titanium.createBuffer method to create a buffer.

  • 1.7
  • 1.7
  • 1.7
Defined By

Properties

apiName : Stringreadonly

The name of the API that this proxy corresponds to.

The name of the API that this proxy corresponds to.

The value of this property is the fully qualified name of the API. For example, Button returns Ti.UI.Button.

  • 3.2.0
  • 3.2.0
  • 3.2.0
Indicates if the proxy will bubble an event to its parent. ...

Indicates if the proxy will bubble an event to its parent.

Some proxies (most commonly views) have a relationship to other proxies, often established by the add() method. For example, for a button added to a window, a click event on the button would bubble up to the window. Other common parents are table sections to their rows, table views to their sections, and scrollable views to their views. Set this property to false to disable the bubbling to the proxy's parent.

Default: true

  • 3.0.0
  • 3.0.0
  • 3.0.0
Titanium.Buffer
: NumberCreation-Only
Byte order of this buffer. ...

Byte order of this buffer.

Specify either Titanium.Codec.BIG_ENDIAN or Titanium.Codec.LITTLE_ENDIAN.

Default: OS native byte order.

Titanium.Buffer
: Number
Length of the buffer in bytes. ...

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 a buffer by setting its length should be used sparingly due to the associated overhead.

Default: 0 unless `value` is specified, in which case the length of the encoded data is used.

The Window or TabGroup whose Activity lifecycle should be triggered on the proxy.

The Window or TabGroup whose Activity lifecycle should be triggered on the proxy.

If this property is set to a Window or TabGroup, then the corresponding Activity lifecycle event callbacks will also be called on the proxy. Proxies that require the activity lifecycle will need this property set to the appropriate containing Window or TabGroup.

  • 3.6.0
Titanium.Buffer
: StringCreation-Only
The type of data encoding to use with value. ...

The type of data encoding to use with value.

Required when value is a Number. For numbers, specify a TYPE constant from Titanium.Codec, for example, Titanium.Codec.TYPE_DOUBLE.

When value is a String, specify a CHARSET constant from Titanium.Codec.

Default: For string values, defaults to Titanium.Codec.CHARSET_UTF8.

Titanium.Buffer
value : Number/StringCreation-Only

Data to be encoded.

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

Defined By

Methods

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

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

Parameters

  • name : String

    Name of the event.

  • callback : Callback<Object>

    Callback function to invoke when the event is fired.

Returns

  • void
Titanium.Buffer
( sourceBuffer, [sourceOffset], [sourceLength] ) : Number
Appends sourceBuffer to the this buffer. ...

Appends sourceBuffer to the this buffer.

This buffer is grown dynamically to accommodate the additional data if need be.

If sourceOffset and sourceLength are specified, data from sourceBuffer is copied starting at position sourceOffset, and no more than sourceLength bytes are copied.

Parameters

  • sourceBuffer : Titanium.Buffer

    Buffer to append to this buffer.

  • sourceOffset : Number (optional)

    Offset to start reading buffer data from. If specified, sourceLength must also be specified.

  • sourceLength : Number (optional)

    Number of bytes to read from sourceBuffer. If specified, sourceOffset must also be specified.

Returns

  • Number

    The number of bytes appended.

Applies the properties to the proxy. ...

Applies the properties to the proxy.

Properties are supplied as a dictionary. Each key-value pair in the object is applied to the proxy such that myproxy[key] = value.

  • 3.0.0
  • 3.0.0
  • 3.0.0

Parameters

  • props : Dictionary

    A dictionary of properties to apply.

Returns

  • void
Titanium.Buffer
( )
Clears this buffer's contents but does not change the size of the buffer. ...

Clears this buffer's contents but does not change the size of the buffer.

Returns

  • void
Titanium.Buffer
( [offset], [length] ) : Titanium.Buffer
Creates a complete or partial copy of this buffer. ...

Creates a complete or partial copy of this buffer.

If called with no arguments, retuns a complete copy of the current buffer.

If offset and length are specified, creates a new buffer from the original buffer contents starting at offset and ending at offset+length-1.

Parameters

  • offset : Number (optional)

    Offset of first byte of this buffer to clone. If specified, length must be specified as well.

  • length : Number (optional)

    Number of bytes of data to clone.

Returns

Titanium.Buffer
( sourceBuffer, offset, [sourceOffset], [sourceLength] ) : Number
Copies data from sourceBuffer into the current buffer at offset. ...

Copies data from sourceBuffer into the current buffer at offset.

Does not expand this buffer if there is not enough room to accomodate the data from sourceBuffer.

If sourceOffset and sourceLength are specified, bytes are copied from sourceBuffer starting at sourceOffset, and a maximum of sourceLength bytes are copied.

Parameters

  • sourceBuffer : Titanium.Buffer

    Buffer to copy data from.

  • offset : Number

    Offset in this buffer for the first byte of the copied data.

  • sourceOffset : Number (optional)

    Offset in sourceBuffer to copy data from. If specified, sourceLength must be specified as well.

  • sourceLength : Number (optional)

    Number of bytes to copy from sourceBuffer. If specified, sourceOffset must be specified as well.

Returns

  • Number

    The number of bytes copied.

Titanium.Buffer
( fillByte, [offset], [length] )
Fills this buffer with the specified byte value. ...

Fills this buffer with the specified byte value.

Fills the buffer by setting byte values to fillByte.

If offset and length are specified, fills the buffer starting at offset and ending at offset+length-1.

If offset and length are omitted, fills the entire buffer.

Parameters

  • fillByte : Number

    Byte to fill buffer with.

  • offset : Number (optional)

    Offset of the first byte to set to fillByte.

  • length : Number (optional)

    Number of bytes to fill.

Returns

  • void
Fires a synthesized event to any registered listeners. ...

Fires a synthesized event to any registered listeners.

Parameters

  • name : String

    Name of the event.

  • event : Dictionary

    A dictionary of keys and values to add to the Titanium.Event object sent to the listeners.

Returns

  • void
Gets the value of the apiName property. ...

Gets the value of the apiName property.

  • 3.2.0
  • 3.2.0
  • 3.2.0

Returns

  • String
Gets the value of the bubbleParent property. ...

Gets the value of the bubbleParent property.

  • 3.0.0
  • 3.0.0
  • 3.0.0

Returns

  • Boolean
Titanium.Buffer
( ) : Number
Gets the value of the byteOrder property. ...

Gets the value of the byteOrder property.

Returns

  • Number
Titanium.Buffer
( ) : Number
Gets the value of the length property. ...

Gets the value of the length property.

Returns

  • Number
Gets the value of the lifecycleContainer property. ...

Gets the value of the lifecycleContainer property.

  • 3.6.0

Returns

Titanium.Buffer
( ) : String
Gets the value of the type property. ...

Gets the value of the type property.

Returns

  • String
Titanium.Buffer
( ) : Number/String
Gets the value of the value property. ...

Gets the value of the value property.

Returns

  • Number/String
Titanium.Buffer
( sourceBuffer, offset, [sourceOffset], [sourceLength] ) : Number
Inserts data from sourceBuffer into this buffer at offset. ...

Inserts data from sourceBuffer into this buffer at offset.

Buffer is grown to accommodate the new data.

If sourceOffset and sourceLength are specified, sourceLength bytes of data are copied from sourceBuffer, with the first byte at sourceOffset.

Parameters

  • sourceBuffer : Titanium.Buffer

    Buffer holding data to insert into this buffer.

  • offset : Number

    Offset in this buffer to insert the first byte copied from sourceBuffer.

  • sourceOffset : Number (optional)

    Offset in sourceBuffer of the first byte to insert. If specified, sourceLength must be specified as well.

  • sourceLength : Number (optional)

    Number of bytes to insert from sourceBuffer. If specified, sourceOffset must be specified as well.

Returns

  • Number

    The number of bytes inserted.

Titanium.Buffer
( )
Releases the space allocated to the buffer, and sets its length to 0. ...

Releases the space allocated to the buffer, and sets its length to 0.

This is effectively the same as buffer.length = 0.

Returns

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

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

Multiple listeners can be registered for the same event, so the callback parameter is used to determine which listener to remove.

When adding a listener, you must save a reference to the callback function in order to remove the listener later:

var listener = function() { Ti.API.info("Event listener called."); }
window.addEventListener('click', listener);

To remove the listener, pass in a reference to the callback function:

window.removeEventListener('click', listener);

Parameters

  • name : String

    Name of the event.

  • callback : Callback<Object>

    Callback function to remove. Must be the same function passed to addEventListener.

Returns

  • void
Sets the value of the bubbleParent property. ...

Sets the value of the bubbleParent property.

  • 3.0.0
  • 3.0.0
  • 3.0.0

Parameters

  • bubbleParent : Boolean

    New value for the property.

Returns

  • void
Titanium.Buffer
( byteOrder )
Sets the value of the byteOrder property. ...

Sets the value of the byteOrder property.

Parameters

  • byteOrder : Number

    New value for the property.

Returns

  • void
Titanium.Buffer
( length )
Sets the value of the length property. ...

Sets the value of the length property.

Parameters

  • length : Number

    New value for the property.

Returns

  • void
Sets the value of the lifecycleContainer property. ...

Sets the value of the lifecycleContainer property.

  • 3.6.0

Parameters

Returns

  • void
Titanium.Buffer
( type )
Sets the value of the type property. ...

Sets the value of the type property.

Parameters

  • type : String

    New value for the property.

Returns

  • void
Titanium.Buffer
( value )
Sets the value of the value property. ...

Sets the value of the value property.

Parameters

  • value : Number/String

    New value for the property.

Returns

  • void
Titanium.Buffer
( ) : Titanium.Blob
Converts this buffer to a Titanium.Blob. ...

Converts this buffer to a Titanium.Blob.

Returns

Titanium.Buffer
( ) : String
Converts this buffer to a String. ...

Converts this buffer to a String.

Returns

  • String