Top Description Methods
org.osgi.service.zigbee

public Interface ZigBeeDataOutput

Imports
java.io.IOException

The ZigBeeDataOutput interface is designed for converting Java data types into a series of bytes. The purpose of this interface is the same as the DataOutput interface provided by Java, with the difference that in this interface, the generated bytes ordering is little endian, whereas in the DataOutput is big endian.
Author
$Id: 881f0d5fc3869f01558c34796ba78b3faee5b31f $

Method Summary

Modifier and TypeMethod and Description
public void
writeByte(byte
The value to append.
value
)

Appends a byte to the data output.

public void
writeBytes(byte[]
A buffer containing the bytes to append to the data output stream.
bytes
,
int
The length in bytes that have to be actually appended.
length
)

Appends on the Data Output Stream a byte array.

public void
writeDouble(double
The double value to append.
value
)

Appends on the Data Output Stream a double value.

public void
writeFloat(float
The float value to append.
value
,
int
The size in bytes that have to be actually appended. The size must be 2 for semi precision floats or 4 for standard precision floats (see the ZigBee Cluster Library specifications).
size
)

Appends on the Data Output Stream a float value.

public void
writeInt(int
The integer value to append
value
,
int
The size in bytes that have to be actually appended. The size must be in the range [1,4].
size
)

Appends an int value to the data output.

public void
writeLong(long
The long value to append
value
,
int
The size in bytes that have to be actually appended. The size must be in the range [1,8].
size
)

Appends a long to the data output.

Method Detail

writeByteback to summary
public void writeByte(byte value)

Appends a byte to the data output.

To avoid losing information, the passed value must be in the range [-128, 127] for signed numbers and [0, 255] for unsigned numbers.

Parameters
value:byte

The value to append.

writeBytesback to summary
public void writeBytes(byte[] bytes, int length) throws IOException

Appends on the Data Output Stream a byte array. The byte array is written on the data output starting from the byte at index 0.

Parameters
bytes:byte[]

A buffer containing the bytes to append to the data output stream.

length:int

The length in bytes that have to be actually appended.

Exceptions
IOException:
If an I/O error occurs.
IllegalArgumentException:
If the passed buffer is null or shorter than length bytes.
writeDoubleback to summary
public void writeDouble(double value) throws IOException

Appends on the Data Output Stream a double value.

Parameters
value:double

The double value to append.

Exceptions
IOException:
If an I/O error occurs.
writeFloatback to summary
public void writeFloat(float value, int size) throws IOException

Appends on the Data Output Stream a float value.

Parameters
value:float

The float value to append.

size:int

The size in bytes that have to be actually appended. The size must be 2 for semi precision floats or 4 for standard precision floats (see the ZigBee Cluster Library specifications).

Exceptions
IOException:
If an I/O error occurs.
IllegalArgumentException:
If the passed size is not within the allowed range.
writeIntback to summary
public void writeInt(int value, int size) throws IOException

Appends an int value to the data output.

To avoid losing information, according to the size argument, the passed long value if it represents a signed number must fit in the range [ -2^(size * 8 - 1), -2^(size * 8 - 1) - 1].

For unsigned numbers it should fit in the range [ 0, -2^(size * 8) - 1].

For instance if size is 2 the correct range for signed numbers is [0xffff8000, 0x7fff] (that is, [-32768, +32767]), whereas for unsigned numbers is [0L, 0xffff].

Although this method allows write even 1 byte of the passed int value, it is suggested to use the writeByte(byte) because this latter could be implemented in a more efficient way.

Parameters
value:int

The integer value to append

size:int

The size in bytes that have to be actually appended. The size must be in the range [1,4].

Exceptions
IOException:
If an I/O error occurs.
IllegalArgumentException:
If the passed size is not within the allowed range.
writeLongback to summary
public void writeLong(long value, int size) throws IOException

Appends a long to the data output.

To avoid losing information, according to the size argument, the passed long value if it represents a signed number must fit in the range [ -2^(size * 8 - 1), -2^(size * 8 - 1) - 1].

For unsigned numbers it should fit in the range [ 0, -2^(size * 8) - 1].

For instance if size is 3 the correct range for signed numbers is [0xffffffffff800000L, 0x7fffffL] (that is, [-21474836448, +2147483647]), whereas for unsigned numbers is [0L, 0xffffffL].

Although this method allows write even 1 byte of the passed long value, it is suggested to use the writeByte(byte) because this latter could be implemented in a more efficient way.

Parameters
value:long

The long value to append

size:int

The size in bytes that have to be actually appended. The size must be in the range [1,8].

Exceptions
IOException:
If an I/O error occurs.
IllegalArgumentException:
If the passed size is not within the allowed range.