public class BufferUnderflowWithSizeException
extends java.nio.BufferUnderflowException
BufferUnderflowException
with information about how much data is
needed. In contrast to a regular BufferUnderflowException
, this
exception indicates how much data is needed in order to perform the operation
that just failed.
The number returned is a minimum estimate. This means that the operation might still fail with a BufferUnderflowException if the indicated number of bytes is made available. However, the operation is guaranteed to fail if not at least the indicated number of bytes is made available. Therefore, the calling code does not have to try the operation again until it can supply the required data.
In contrast to most exceptions in this package, this exception does not
inherit from JackieRuntimeException
. This is so that it can inherit
from BufferUnderflowException
and thus is fully compatible with code
that expects a regular BufferUnderflowException
.
Constructor and Description |
---|
BufferUnderflowWithSizeException(int bytesNeeded)
Creates a buffer underflow exception with size information.
|
Modifier and Type | Method and Description |
---|---|
int |
getBytesNeeded()
Returns the minimum number of bytes that are needed for the operation to
succeed.
|
public BufferUnderflowWithSizeException(int bytesNeeded)
ByteBuffer
's Buffer.remaining()
method must at least
return the indicated number of bytes for the operation to be able to
succeed.bytesNeeded
- number of bytes that are at least needed for the operation to
be successful.public int getBytesNeeded()
Returns the minimum number of bytes that are needed for the operation to succeed. This means that the operation will certainly fail if tried again with less than the indicated number of bytes. However, it might also fail if the indicated number of bytes is available, so the returned number is just a lower estimate.
The number returned is the total number of bytes needed. For example, if this method returns 40 and 24 bytes are already available, 16 bytes need to be supplied in addition to the data that is already available.
Copyright © 2014–2024 aquenos GmbH. All rights reserved.