Class: BytesMessage

BytesMessage

A BytesMessage object is used to send a message that contains a stream of bytes as its payload. When the message is first created, and when clearBody is called, the body of the message is in write-only mode. After the first call to reset has been made, the message body is in read-only mode.

new BytesMessage()

This method is not meant to be used directly. Creates a BytesMessage object that is used to send a message that contains a stream of bytes as its payload.

Extends

Method Summary

clearBody
Clears the message body (e.
getBodyLength
Gets the number of bytes of the message body when the message is in read-only mode.
readBoolean
Reads a boolean from the bytes message stream.
readByte
Reads a signed 8-bit value from the bytes message stream.
readBytes
Reads a byte array from the bytes message stream.
readChar
Reads a Unicode character value from the bytes message stream.
readInt
Reads a signed 32-bit integer from the bytes message stream.
readShort
Reads a signed 16-bit number from the bytes message stream.
readUTF
Reads a string that has been encoded using a modified UTF-8 format from the bytes message stream.
reset
Puts the message body in read-only mode and repositions the stream of bytes to the beginning.
writeBoolean
Writes a boolean to the bytes message stream as a 1-byte value.
writeByte
Writes a byte to the bytes message stream as a 1-byte value.
writeBytes
Writes a byte array to the bytes message stream.
writeChar
Writes a char to the bytes message stream as a 2-byte value, high byte first.
writeInt
Writes an int to the bytes message stream as four bytes, high byte first.
writeShort
Writes a short to the bytes message stream as two bytes, high byte first.
writeUTF
Writes a string to the bytes message stream using UTF-8 encoding in a machine-independent manner.

Inherited Methods

Method Detail

clearBody()

Clears the message body (e.g. the payload). Message properties and specifications remain unaltered.
Overrides:

getBodyLength() → {Number}

Gets the number of bytes of the message body when the message is in read-only mode. The value returned is the entire length of the message body, regardless of where the pointer for reading the message is currently located.
Returns:
Type
Number

readBoolean() → {Boolean}

Reads a boolean from the bytes message stream.
Returns:
Type
Boolean

readByte() → {Number}

Reads a signed 8-bit value from the bytes message stream.
Returns:
Type
Number

readBytes() → {Number}

Reads a byte array from the bytes message stream.
Returns:
the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached
Type
Number

readChar() → {String}

Reads a Unicode character value from the bytes message stream.
Returns:
Type
String

readInt() → {Number}

Reads a signed 32-bit integer from the bytes message stream.
Returns:
Type
Number

readShort() → {Number}

Reads a signed 16-bit number from the bytes message stream.
Returns:
Type
Number

readUTF() → {String}

Reads a string that has been encoded using a modified UTF-8 format from the bytes message stream.
Returns:
Type
String

reset()

Puts the message body in read-only mode and repositions the stream of bytes to the beginning.

writeBoolean(value)

Writes a boolean to the bytes message stream as a 1-byte value.
Parameters:
Name Type Description
value Boolean the boolean value to be written.

writeByte(value)

Writes a byte to the bytes message stream as a 1-byte value.
Parameters:
Name Type Description
value Number the byte value to be written.

writeBytes(value)

Writes a byte array to the bytes message stream.
Parameters:
Name Type Description
value Array the byte array to be written.

writeChar(value)

Writes a char to the bytes message stream as a 2-byte value, high byte first.
Parameters:
Name Type Description
value String the char value to be written.

writeInt(value)

Writes an int to the bytes message stream as four bytes, high byte first.
Parameters:
Name Type Description
value Number the int value to be written.

writeShort(value)

Writes a short to the bytes message stream as two bytes, high byte first.
Parameters:
Name Type Description
value Number the short value to be written.

writeUTF(value)

Writes a string to the bytes message stream using UTF-8 encoding in a machine-independent manner.
Parameters:
Name Type Description
value String the string value to be written.