Top Description Methods
org.osgi.service.zigbee

public Interface ZigBeeDataInput

Imports
java.io.DataInput, .EOFException, .IOException

The ZigBeeDataInput interface is designed for converting a series of bytes in Java data types. The purpose of this interface is the same as the DataInput interface available in the standard Java library, with the difference that in this interface, byte ordering is little endian, whereas in the DataInput interface is big endian.

Each method provided by this interface read one or more bytes from the underlying stream, combine them, and return a Java data type. The pointer to the stream is then moved immediately after the last byte read. If this pointer past the available buffer bounds, a subsequent call to one of these methods will throw a EOFException.

Author
$Id: bec827b3b3c1dc2b4a4ca973636585f44f8d01ad $

Method Summary

Modifier and TypeMethod and Description
public byte

Returns:

the byte read from the data input.
readByte
()

Reads a byte from the DataInput Stream.

public byte[]

Returns:

return a copy of the bytes contained in the stream.
readBytes
(int
the number of bytes to read.
len
)

Reads the specified amount of bytes from the underlying stream and return a copy of them.

public double

Returns:

a decoded double.
readDouble
()

Reads a number of type Double.

public float

Returns:

The float number read from the data input.
readFloat
(int
expected value for this parameter are 2 or 4 depending if reading ZigBeeDataTypes#FLOATING_SEMI or ZigBeeDataTypes#FLOATING_SINGLE.
size
)

Reads a number of type Float.

public int

Returns:

the integer read from the data input.
readInt
(int
the number of bytes that have to be read. Allowed values for this parameter are in the range [1, 4].
size
)

Reads an integer of the specified size.

public long

Returns:

The long value read from the data input.
readLong
(int
the number of bytes that have to be read. Allowed values for this parameter are in the range [1, 8].
size
)

Reads a certain amount of bytes and returns a long.

Method Detail

readByteback to summary
public byte readByte() throws IOException

Reads a byte from the DataInput Stream.

Returns:byte

the byte read from the data input.

Exceptions
IOException:
If an I/O error occurs.
EOFException:
When the end of the input has been reached and there are no more data to read.
readBytesback to summary
public byte[] readBytes(int len) throws IOException

Reads the specified amount of bytes from the underlying stream and return a copy of them. If the number of available bytes is less than the requested len, it throws an EOFException.

Parameters
len:int

the number of bytes to read.

Returns:byte[]

return a copy of the bytes contained in the stream.

Exceptions
IOException:
If an I/O error occurs.
EOFException:
if there are not at least len bytes left on the data input.
readDoubleback to summary
public double readDouble() throws IOException

Reads a number of type Double.

Returns:double

a decoded double.

Exceptions
IOException:
If an I/O error occurs.
EOFException:
if there are not at least size 8 bytes left on the data input.
readFloatback to summary
public float readFloat(int size) throws IOException

Reads a number of type Float.

Parameters
size:int

expected value for this parameter are 2 or 4 depending if reading ZigBeeDataTypes#FLOATING_SEMI or ZigBeeDataTypes#FLOATING_SINGLE.

Returns:float

The float number read from the data input.

Exceptions
IOException:
If an I/O error occurs.
EOFException:
if there are not at least size bytes left on the data input.
IllegalArgumentException:
If the passed size is not in the allowed range.
readIntback to summary
public int readInt(int size) throws IOException

Reads an integer of the specified size. The sign bit of the size-bytes integer is left-extended. In other words if a readInt(2) is issued and the byte read are 0x01, 0x02 and 0xf0, the method returns 0xfff00201. For this reason if the 4 bytes read from the stream represent an unsigned value, to get the expected value the and bitwise operator must be used:

int u = readInt(3) & 0xffffff;

Parameters
size:int

the number of bytes that have to be read. Allowed values for this parameter are in the range [1, 4].

Returns:int

the integer read from the data input.

Exceptions
IOException:
If an I/O error occurs.
EOFException:
When the end of the input has been reached and there are no more data to read.
IllegalArgumentException:
If the passed size is not in the allowed range.
readLongback to summary
public long readLong(int size) throws IOException

Reads a certain amount of bytes and returns a long. The sign bit of the read size-bytes long is left-extended. In other words if a readLong(2) is issued and the byte read are 0x01 and 0xf0, the method returns 0xfffffffffffff001L. For this reason if the 2 bytes read from the stream represent an unsigned value, to get the expected value the and bitwise operator must be used:

long u = readLong(2) & 0xffff;

Parameters
size:int

the number of bytes that have to be read. Allowed values for this parameter are in the range [1, 8].

Returns:long

The long value read from the data input.

Exceptions
IOException:
If an I/O error occurs.
EOFException:
if there are not at least size bytes left on the data input.
IllegalArgumentException:
If the passed size is not in the allowed range.