public interface GenericBufferIODevice extends GenericDevice, java.nio.channels.ByteChannel, BufferAccess<java.nio.ByteBuffer>
GenericBufferIODevice
interface defines generic methods for accessing and controlling
devices using read and write operations.
A platform implementer may allow through this interface access and control of devices
for which there exist no other more specific API such as
SPIDevice
or
I2CDevice
.
BIG_ENDIAN, LITTLE_ENDIAN, MIXED_ENDIAN
Modifier and Type | Method and Description |
---|---|
int |
read(java.nio.ByteBuffer dst)
Reads a sequence of bytes from this device into the given buffer.
|
int |
read(int skip,
java.nio.ByteBuffer dst)
Reads a sequence of bytes from this device into the given buffer, skipping the first
skip bytes read. |
int |
write(java.nio.ByteBuffer src)
Writes a sequence of bytes to this device from the given buffer.
|
getControl, setControl, setEventListener
close, getByteOrder, getDescriptor, isOpen, tryLock, unlock
getInputBuffer, getOutputBuffer, prepareBuffer
int read(java.nio.ByteBuffer dst) throws java.io.IOException, UnavailableDeviceException, UnsupportedByteOrderException, ClosedDeviceException
The availability of new input data may be notified through an GenericEvent
with ID GenericEvent.INPUT_DATA_AVAILABLE
.
read
in interface java.nio.channels.ReadableByteChannel
dst
- The buffer into which bytes are to be transferred.dst
, possibly zero, or -1
if the device has reached
end-of-streamjava.lang.NullPointerException
- If dst
is null
.UnavailableDeviceException
- if this device is not currently available - such as it is locked by another
application.UnsupportedByteOrderException
- if the byte ordering of the provided buffer is not supported (see Device Byte Order).ClosedDeviceException
- if the device has been closed.java.io.IOException
- if an I/O error occurred such as the device is not readable.int read(int skip, java.nio.ByteBuffer dst) throws java.io.IOException, UnavailableDeviceException, UnsupportedByteOrderException, ClosedDeviceException
skip
bytes read.
Apart from skipping the first skip
bytes, this method behaves identically to
read(java.nio.ByteBuffer)
.
skip
- the number of read bytes that must be ignored/skipped before filling in the
dst
buffer.dst
- The buffer into which bytes are to be transferred.dst
, possibly zero, or -1
if the device has reached
end-of-streamjava.lang.NullPointerException
- If dst
is null
.java.lang.IllegalArgumentException
- If skip
is negative.UnavailableDeviceException
- if this device is not currently available - such as it is locked by another
application.UnsupportedByteOrderException
- if the byte ordering of the provided buffer is not supported (see Device Byte Order).ClosedDeviceException
- if the device has been closed.java.io.IOException
- if an I/O error occurred such as the device is not readable.int write(java.nio.ByteBuffer src) throws java.io.IOException, UnavailableDeviceException, UnsupportedByteOrderException, ClosedDeviceException
An empty output buffer condition may be notified through an GenericEvent
with ID GenericEvent.OUTPUT_BUFFER_EMPTY
.
write
in interface java.nio.channels.WritableByteChannel
src
- The buffer from which bytes are to be retrieved.src
, possibly zero.java.lang.NullPointerException
- If src
is null
.UnavailableDeviceException
- if this device is not currently available - such as it is locked by another
application.UnsupportedByteOrderException
- if the byte ordering of the provided buffer is not supported (see Device Byte Order).ClosedDeviceException
- if the device has been closed.java.io.IOException
- if an I/O error occurred such as the device is not writable.Copyright © 2012, 2015, Oracle and/or its affiliates. All rights reserved.
Legal Notices