Packagecom.kaazing.gateway.client.html5
Classpublic class ByteBuffer

ByteBuffer provides a byte buffer for ByteSocket.



Public Properties
 PropertyDefined by
  array : Array
The array property provides byte storage for the buffer.
ByteBuffer
  autoExpand : Boolean = true
The autoExpand property enables writing variable length data, and is on by default.
ByteBuffer
  capacity : int = 0
The capacity property indicates the maximum number of bytes of storage available if the buffer is not automatically expanding.
ByteBuffer
  limit : int = 0
The limit property indicates the last byte of data available for reading.
ByteBuffer
  order : ByteOrder
The order property indicates the endianness of multibyte integer types in the buffer.
ByteBuffer
  position : int = 0
The position property indicates the progress through the buffer, and indicates the position within the underlying array that subsequent data will be read from or written to.
ByteBuffer
Public Methods
 MethodDefined by
  
ByteBuffer(bytes:* = null)
Creates a new ByteBuffer instance.
ByteBuffer
  
allocate(capacity:int):ByteBuffer
[static] Allocates a new ByteBuffer instance.
ByteBuffer
  
Clears the buffer.
ByteBuffer
  
Compacts the buffer by removing leading bytes up to the buffer position, and decrements the limit and position values accordingly.
ByteBuffer
  
Duplicates the buffer by reusing the underlying byte array but with independent position, limit and capacity.
ByteBuffer
  
expand(expectedRemaining:int):ByteBuffer
Expands the buffer to support the expected number of remaining bytes after the current position.
ByteBuffer
  
expandAt(i:int, expectedRemaining:int):ByteBuffer
Expands the buffer to support the expected number of remaining bytes at the specified index.
ByteBuffer
  
fill(size:int):ByteBuffer
Fills the buffer with a repeated number of zeros.
ByteBuffer
  
fillWith(b:int, size:int):ByteBuffer
Fills the buffer with a specific number of repeated bytes.
ByteBuffer
  
Flips the buffer.
ByteBuffer
  
get():int
Returns a single-byte number from the buffer at the current position.
ByteBuffer
  
getAt(index:int):int
Returns a single-byte number from the buffer at the specified index.
ByteBuffer
  
getByteArray(length:int):ByteArray
Returns bytes in an ByteArray
ByteBuffer
  
getByteArrayAt(index:int, length:int):ByteArray
Returns a ByteArray of length size from the buffer starting from the specified position.
ByteBuffer
  
getBytes(length:int):Array
Returns specified number of bytes in an array
ByteBuffer
  
getBytesAt(index:int, length:int):Array
Returns a byte array of length size from the buffer starting from the specified position.
ByteBuffer
  
getHexDump():String
Returns a hex dump of this buffer.
ByteBuffer
  
getInt():int
Returns a four-byte number from the buffer at the current position.
ByteBuffer
  
getIntAt(index:int):int
Returns a four-byte number from the buffer at the specified index.
ByteBuffer
  
Returns a three-byte number from the buffer at the current position.
ByteBuffer
  
getMediumIntAt(index:int):int
Returns a three-byte number from the buffer at the specified index.
ByteBuffer
  
getPrefixedString(fieldSize:int, cs:Charset):String
Returns a length-prefixed string from the buffer at the current position.
ByteBuffer
  
getShort():int
Returns a two-byte number from the buffer at the current position.
ByteBuffer
  
getShortAt(index:int):int
Returns a two-byte number from the buffer at the specified index.
ByteBuffer
  
getString(cs:Charset):String
Returns a null-terminated string from the buffer at the current position.
ByteBuffer
  
Returns an unsigned single-byte number from the buffer at the current position.
ByteBuffer
  
getUnsignedAt(index:int):int
Returns an unsigned single-byte number from the buffer at the specified index.
ByteBuffer
  
getUnsignedBytes(length:int):Array
Returns specified number of unsigned bytes in an array
ByteBuffer
  
Returns an unsigned four-byte number from the buffer at the current position.
ByteBuffer
  
getUnsignedIntAt(index:int):int
Returns an unsigned four-byte number from the buffer at the specified index.
ByteBuffer
  
Returns an unsigned three-byte number from the buffer at the current position.
ByteBuffer
  
getUnsignedMediumIntAt(index:int):int
Returns an unsigned three-byte number from the buffer at the specified index.
ByteBuffer
  
Returns an unsigned two-byte number from the buffer at the current position.
ByteBuffer
  
getUnsignedShortAt(index:int):int
Returns an unsigned two-byte number from the buffer at the specified index.
ByteBuffer
  
hasRemaining():Boolean
Returns true if this buffer has remaining bytes, false otherwise.
ByteBuffer
  
indexOf(b:int):int
Returns the index of the specified byte in the buffer.
ByteBuffer
  
Marks a position in the buffer.
ByteBuffer
  
markValue():int
Returns the mark position in the buffer.
ByteBuffer
  
put(v:int):ByteBuffer
Puts a single byte number into the buffer at the current position.
ByteBuffer
  
putAt(index:int, v:int):ByteBuffer
Puts a single byte number into the buffer at the specified index.
ByteBuffer
  
Puts a buffer into the buffer at the current position.
ByteBuffer
  
Puts a buffer into the buffer at the specified index.
ByteBuffer
  
putByteArray(v:ByteArray, offset:int = 0, length:int = 0):ByteBuffer
Puts a single-byte array into the buffer at the current position.
ByteBuffer
  
putByteArrayAt(index:int, v:ByteArray, offset:int = 0, length:int = 0):ByteBuffer
Puts a single-byte array into the buffer at the current position.
ByteBuffer
  
putBytes(v:Array):ByteBuffer
Puts a single-byte array into the buffer at the current position.
ByteBuffer
  
putBytesAt(index:int, v:Array):ByteBuffer
Puts a single-byte array into the buffer at the specified index.
ByteBuffer
  
Puts a four-byte number into the buffer at the current position.
ByteBuffer
  
putIntAt(index:int, v:*):ByteBuffer
Puts a four-byte number into the buffer at the specified index.
ByteBuffer
  
Puts a three-byte number into the buffer at the current position.
ByteBuffer
  
putMediumIntAt(i:int, v:int):ByteBuffer
Puts a three-byte number into the buffer at the specified index.
ByteBuffer
  
putPrefixedString(fieldSize:int, v:String, cs:Charset):ByteBuffer
Puts a string into the buffer at the specified index, using the character set to encode the string as bytes.
ByteBuffer
  
Puts a two-byte number into the buffer at the current position.
ByteBuffer
  
putShortAt(index:int, v:int):ByteBuffer
Puts a two-byte number into the buffer at the specified index.
ByteBuffer
  
putString(v:String, cs:Charset):ByteBuffer
Puts a string into the buffer at the current position, using the character set to encode the string as bytes.
ByteBuffer
  
Puts an unsigned single-byte number into the buffer at the current position.
ByteBuffer
  
putUnsignedAt(index:int, v:int):ByteBuffer
Puts an unsigned single-byte number into the buffer at the specified position.
ByteBuffer
  
Puts an unsigned four-byte number into the buffer at the current position.
ByteBuffer
  
putUnsignedIntAt(index:int, v:uint):ByteBuffer
Puts an unsigned four-byte number into the buffer at the specified position.
ByteBuffer
  
Puts an unsigned two-byte number into the buffer at the current position.
ByteBuffer
  
putUnsignedShortAt(index:int, v:int):ByteBuffer
Puts an unsigned two-byte number into the buffer at the specified position.
ByteBuffer
  
remaining():int
Returns the number of bytes remaining from the current position to the limit.
ByteBuffer
  
Resets the buffer position using the mark.
ByteBuffer
  
Rewinds the buffer.
ByteBuffer
  
skip(size:int):ByteBuffer
Skips the specified number of bytes from the current position.
ByteBuffer
  
Returns a sliced buffer, setting the position to zero, and decrementing the limit accordingly.
ByteBuffer
  
toString():String
Returns the string representation of this buffer.
ByteBuffer
  
wrap(bytes:Array):ByteBuffer
[static] Wraps a byte array as a new ByteBuffer instance.
ByteBuffer
  
wrapByteArray(bytes:ByteArray):ByteBuffer
[static]
ByteBuffer
Property detail
arrayproperty
public var array:Array

The array property provides byte storage for the buffer.

autoExpandproperty 
public var autoExpand:Boolean = true

The autoExpand property enables writing variable length data, and is on by default.

capacityproperty 
public var capacity:int = 0

The capacity property indicates the maximum number of bytes of storage available if the buffer is not automatically expanding.

limitproperty 
public var limit:int = 0

The limit property indicates the last byte of data available for reading.

orderproperty 
public var order:ByteOrder

The order property indicates the endianness of multibyte integer types in the buffer.

positionproperty 
public var position:int = 0

The position property indicates the progress through the buffer, and indicates the position within the underlying array that subsequent data will be read from or written to.

Constructor detail
ByteBuffer()constructor
public function ByteBuffer(bytes:* = null)

Creates a new ByteBuffer instance.

Parameters
bytes:* (default = null) — bytes the byte-valued Number array
Method detail
allocate()method
public static function allocate(capacity:int):ByteBuffer

Allocates a new ByteBuffer instance. The new buffer's position will be zero, its limit will be its capacity, and its mark will be undefined.

Parameters
capacity:int — the maximum buffer capacity

Returns
ByteBuffer — the allocated ByteBuffer
clear()method 
public function clear():ByteBuffer

Clears the buffer. The position is set to zero, the limit is set to the capacity and the mark is reset.

Returns
ByteBuffer — the buffer
compact()method 
public function compact():ByteBuffer

Compacts the buffer by removing leading bytes up to the buffer position, and decrements the limit and position values accordingly.

Returns
ByteBuffer — the buffer
duplicate()method 
public function duplicate():ByteBuffer

Duplicates the buffer by reusing the underlying byte array but with independent position, limit and capacity.

Returns
ByteBuffer — the duplicated buffer
expand()method 
public function expand(expectedRemaining:int):ByteBuffer

Expands the buffer to support the expected number of remaining bytes after the current position.

Parameters
expectedRemaining:int — expectedRemaining the expected number of remaining bytes

Returns
ByteBuffer — the buffer
expandAt()method 
public function expandAt(i:int, expectedRemaining:int):ByteBuffer

Expands the buffer to support the expected number of remaining bytes at the specified index.

Parameters
i:int — i the index
 
expectedRemaining:int — expectedRemaining the expected number of remaining bytes

Returns
ByteBuffer — the buffer
fill()method 
public function fill(size:int):ByteBuffer

Fills the buffer with a repeated number of zeros.

Parameters
size:int — the number of zeros to repeat

Returns
ByteBuffer — the buffer
fillWith()method 
public function fillWith(b:int, size:int):ByteBuffer

Fills the buffer with a specific number of repeated bytes.

Parameters
b:int — the byte to repeat
 
size:int — the number of times to repeat

Returns
ByteBuffer — the buffer
flip()method 
public function flip():ByteBuffer

Flips the buffer. The limit is set to the current position, the position is set to zero, and the mark is reset.

Returns
ByteBuffer — the flipped buffer
get()method 
public function get():int

Returns a single-byte number from the buffer at the current position.

Returns
int — the single-byte number
getAt()method 
public function getAt(index:int):int

Returns a single-byte number from the buffer at the specified index.

Parameters
index:int — the index

Returns
int — the single-byte number
getByteArray()method 
public function getByteArray(length:int):ByteArray

Returns bytes in an ByteArray

Parameters
length:int — the number of bytes to read

Returns
ByteArray — a new ByteArray with bytes read from the buffer
getByteArrayAt()method 
public function getByteArrayAt(index:int, length:int):ByteArray

Returns a ByteArray of length size from the buffer starting from the specified position.

Parameters
index:int — start index
 
length:int — the size of the buffer to be returned

Returns
ByteArray — a new byte array with bytes read from the buffer
getBytes()method 
public function getBytes(length:int):Array

Returns specified number of bytes in an array

Parameters
length:int — the number of bytes to read

Returns
Array — a new byte array with bytes read from the buffer
getBytesAt()method 
public function getBytesAt(index:int, length:int):Array

Returns a byte array of length size from the buffer starting from the specified position.

Parameters
index:int — start index
 
length:int — the size of the buffer to be returned

Returns
Array — a new byte array with bytes read from the buffer
getHexDump()method 
public function getHexDump():String

Returns a hex dump of this buffer.

Returns
String — the hex dump
getInt()method 
public function getInt():int

Returns a four-byte number from the buffer at the current position.

Returns
int — the four-byte number
getIntAt()method 
public function getIntAt(index:int):int

Returns a four-byte number from the buffer at the specified index.

Parameters
index:int — the index

Returns
int — the four-byte number
getMediumInt()method 
public function getMediumInt():int

Returns a three-byte number from the buffer at the current position.

Returns
int — the three-byte number
getMediumIntAt()method 
public function getMediumIntAt(index:int):int

Returns a three-byte number from the buffer at the specified index.

Parameters
index:int — the index

Returns
int — the three-byte number
getPrefixedString()method 
public function getPrefixedString(fieldSize:int, cs:Charset):String

Returns a length-prefixed string from the buffer at the current position.

Parameters
fieldSize:int — fieldSize the width in bytes of the prefixed length field
 
cs:Charset — cs the character set

Returns
String — the length-prefixed string
getShort()method 
public function getShort():int

Returns a two-byte number from the buffer at the current position.

Returns
int — the two-byte number
getShortAt()method 
public function getShortAt(index:int):int

Returns a two-byte number from the buffer at the specified index.

Parameters
index:int — the index

Returns
int — the two-byte number
getString()method 
public function getString(cs:Charset):String

Returns a null-terminated string from the buffer at the current position. If the end of buffer if reached before discovering a null terminator byte, then the decoded string includes all bytes up to the end of the buffer.

Parameters
cs:Charset — cs the character set

Returns
String — the null-terminated string
getUnsigned()method 
public function getUnsigned():int

Returns an unsigned single-byte number from the buffer at the current position.

Returns
int — the unsigned single-byte number
getUnsignedAt()method 
public function getUnsignedAt(index:int):int

Returns an unsigned single-byte number from the buffer at the specified index.

Parameters
index:int — the index

Returns
int — the unsigned single-byte number
getUnsignedBytes()method 
public function getUnsignedBytes(length:int):Array

Returns specified number of unsigned bytes in an array

Parameters
length:int — the number of bytes to read

Returns
Array — array of unsigned bytes
getUnsignedInt()method 
public function getUnsignedInt():int

Returns an unsigned four-byte number from the buffer at the current position.

Returns
int — the unsigned four-byte number
getUnsignedIntAt()method 
public function getUnsignedIntAt(index:int):int

Returns an unsigned four-byte number from the buffer at the specified index.

Parameters
index:int — the index

Returns
int — the unsigned four-byte number
getUnsignedMediumInt()method 
public function getUnsignedMediumInt():int

Returns an unsigned three-byte number from the buffer at the current position.

Returns
int — the unsigned three-byte number
getUnsignedMediumIntAt()method 
public function getUnsignedMediumIntAt(index:int):int

Returns an unsigned three-byte number from the buffer at the specified index.

Parameters
index:int — the index

Returns
int — the unsigned three-byte number
getUnsignedShort()method 
public function getUnsignedShort():int

Returns an unsigned two-byte number from the buffer at the current position.

Returns
int — the unsigned two-byte number
getUnsignedShortAt()method 
public function getUnsignedShortAt(index:int):int

Returns an unsigned two-byte number from the buffer at the specified index.

Parameters
index:int — the index

Returns
int — the unsigned two-byte number
hasRemaining()method 
public function hasRemaining():Boolean

Returns true if this buffer has remaining bytes, false otherwise.

Returns
Boolean — whether this buffer has remaining bytes
indexOf()method 
public function indexOf(b:int):int

Returns the index of the specified byte in the buffer.

Parameters
b:int — the byte to find

Returns
int — the index of the byte in the buffer, or -1 if not found
mark()method 
public function mark():ByteBuffer

Marks a position in the buffer.

Returns
ByteBuffer — the buffer

See also

markValue()method 
public function markValue():int

Returns the mark position in the buffer.

Returns
int — the mark position

See also

put()method 
public function put(v:int):ByteBuffer

Puts a single byte number into the buffer at the current position.

Parameters
v:int — the single-byte number

Returns
ByteBuffer — the buffer
putAt()method 
public function putAt(index:int, v:int):ByteBuffer

Puts a single byte number into the buffer at the specified index.

Parameters
index:int — the index
 
v:int — the single-byte number

Returns
ByteBuffer — the buffer
putBuffer()method 
public function putBuffer(v:ByteBuffer):ByteBuffer

Puts a buffer into the buffer at the current position.

Parameters
v:ByteBuffer — the single-byte array

Returns
ByteBuffer — the buffer
putBufferAt()method 
public function putBufferAt(index:int, v:ByteBuffer):ByteBuffer

Puts a buffer into the buffer at the specified index.

Parameters
index:int — the index
 
v:ByteBuffer — the single-byte array

Returns
ByteBuffer — the buffer
putByteArray()method 
public function putByteArray(v:ByteArray, offset:int = 0, length:int = 0):ByteBuffer

Puts a single-byte array into the buffer at the current position.

Parameters
v:ByteArray — the single-byte array
 
offset:int (default = 0)
 
length:int (default = 0)

Returns
ByteBuffer — the buffer
putByteArrayAt()method 
public function putByteArrayAt(index:int, v:ByteArray, offset:int = 0, length:int = 0):ByteBuffer

Puts a single-byte array into the buffer at the current position.

Parameters
index:int — the index
 
v:ByteArray — the single-byte array
 
offset:int (default = 0)
 
length:int (default = 0)

Returns
ByteBuffer — the buffer
putBytes()method 
public function putBytes(v:Array):ByteBuffer

Puts a single-byte array into the buffer at the current position.

Parameters
v:Array — the single-byte array

Returns
ByteBuffer — the buffer
putBytesAt()method 
public function putBytesAt(index:int, v:Array):ByteBuffer

Puts a single-byte array into the buffer at the specified index.

Parameters
index:int — the index
 
v:Array — the single-byte array

Returns
ByteBuffer — the buffer
putInt()method 
public function putInt(v:int):ByteBuffer

Puts a four-byte number into the buffer at the current position.

Parameters
v:int — the four-byte number

Returns
ByteBuffer — the buffer
putIntAt()method 
public function putIntAt(index:int, v:*):ByteBuffer

Puts a four-byte number into the buffer at the specified index.

Parameters
index:int — the index
 
v:* — the four-byte number

Returns
ByteBuffer — the buffer
putMediumInt()method 
public function putMediumInt(v:int):ByteBuffer

Puts a three-byte number into the buffer at the current position.

Parameters
v:int — the three-byte number

Returns
ByteBuffer — the buffer
putMediumIntAt()method 
public function putMediumIntAt(i:int, v:int):ByteBuffer

Puts a three-byte number into the buffer at the specified index.

Parameters
i:int — the index
 
v:int — the three-byte number

Returns
ByteBuffer — the buffer
putPrefixedString()method 
public function putPrefixedString(fieldSize:int, v:String, cs:Charset):ByteBuffer

Puts a string into the buffer at the specified index, using the character set to encode the string as bytes.

Parameters
fieldSize:int — the width in bytes of the prefixed length field
 
v:String — the string
 
cs:Charset — the character set

Returns
ByteBuffer — the buffer
putShort()method 
public function putShort(v:int):ByteBuffer

Puts a two-byte number into the buffer at the current position.

Parameters
v:int — the two-byte number

Returns
ByteBuffer — the buffer
putShortAt()method 
public function putShortAt(index:int, v:int):ByteBuffer

Puts a two-byte number into the buffer at the specified index.

Parameters
index:int — the index
 
v:int — the two-byte number

Returns
ByteBuffer — the buffer
putString()method 
public function putString(v:String, cs:Charset):ByteBuffer

Puts a string into the buffer at the current position, using the character set to encode the string as bytes.

Parameters
v:String — the string
 
cs:Charset — the character set

Returns
ByteBuffer — the buffer
putUnsigned()method 
public function putUnsigned(v:int):ByteBuffer

Puts an unsigned single-byte number into the buffer at the current position.

Parameters
v:int — the unsigned byte as an int

Returns
ByteBuffer — the buffer
putUnsignedAt()method 
public function putUnsignedAt(index:int, v:int):ByteBuffer

Puts an unsigned single-byte number into the buffer at the specified position.

Parameters
index:int — the index
 
v:int — the unsigned byte as an int

Returns
ByteBuffer — the buffer
putUnsignedInt()method 
public function putUnsignedInt(v:uint):ByteBuffer

Puts an unsigned four-byte number into the buffer at the current position.

Parameters
v:uint — the four-byte number

Returns
ByteBuffer — the buffer
putUnsignedIntAt()method 
public function putUnsignedIntAt(index:int, v:uint):ByteBuffer

Puts an unsigned four-byte number into the buffer at the specified position.

Parameters
index:int — the index
 
v:uint — the four-byte number

Returns
ByteBuffer — the buffer
putUnsignedShort()method 
public function putUnsignedShort(v:int):ByteBuffer

Puts an unsigned two-byte number into the buffer at the current position.

Parameters
v:int — the two-byte number

Returns
ByteBuffer — the buffer
putUnsignedShortAt()method 
public function putUnsignedShortAt(index:int, v:int):ByteBuffer

Puts an unsigned two-byte number into the buffer at the specified position.

Parameters
index:int — the index
 
v:int — the two-byte number

Returns
ByteBuffer — the buffer
remaining()method 
public function remaining():int

Returns the number of bytes remaining from the current position to the limit.

Returns
int — the number of bytes remaining
reset()method 
public function reset():ByteBuffer

Resets the buffer position using the mark.

Returns
ByteBuffer — the buffer

Throws
— if the mark is invalid

See also

rewind()method 
public function rewind():ByteBuffer

Rewinds the buffer. The position is set to zero and the mark is reset.

Returns
ByteBuffer — the buffer
skip()method 
public function skip(size:int):ByteBuffer

Skips the specified number of bytes from the current position.

Parameters
size:int — size the number of bytes to skip

Returns
ByteBuffer — the buffer
slice()method 
public function slice():ByteBuffer

Returns a sliced buffer, setting the position to zero, and decrementing the limit accordingly.

Returns
ByteBuffer — the sliced buffer
toString()method 
public function toString():String

Returns the string representation of this buffer.

Returns
String — the string representation
wrap()method 
public static function wrap(bytes:Array):ByteBuffer

Wraps a byte array as a new ByteBuffer instance.

Parameters
bytes:Array — an array of byte-sized numbers

Returns
ByteBuffer — the bytes wrapped as a ByteBuffer
wrapByteArray()method 
public static function wrapByteArray(bytes:ByteArray):ByteBufferParameters
bytes:ByteArray

Returns
ByteBuffer