Interface ProtonBufferComponentAccessor
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
Netty4ToProtonBufferAdapter,Netty5ToProtonBufferAdapter,ProtonByteArrayBuffer
ProtonBuffer
which can be used to gain access to underlying buffer internals for IO or other
low level buffer operations.
A component access object is not meant to have a long life-span as it can prevent the quick cleanup of buffer resources. Likewise the access object must be closed upon completion of the access if proper resource cleanup is to occur as the object itself ensure that there is concrete referencing of the buffer preventing a JVM GC of the object should the user discard the buffer before the access object has been discarded.
The general usage of the component access object should be within a try-with-resource
block as follows although it should be noted that if using the iteration type component
walk an allocation of an Iterable and an Iterator will be made:
try (ProtonBufferComponentAccessor accessor = buffer.componentAccessor()) {
for (ProtonBufferComponent component : accessor.readableComponents()) {
// Access logic here....
}
}
Or an alternative that does not create an iterator for walking the list of available ProtonBufferComponents would look as follows:
try (ProtonBufferComponentAccessor accessor = buffer.componentAccessor()) {
for (ProtonBufferComponent component = accessor.first(); component != null; component = accessor.next()) {
// Access logic here....
}
}
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Safe to call close in all cases the close will not throw.default Iterator<ProtonBufferComponent>default Iterable<ProtonBufferComponent>first()Returns the first component that this access object provides which resets the iteration state to the beginning.default ProtonBufferComponentReturns the first readable component that this access object provides which resets the iteration state to the beginning.default ProtonBufferComponentReturns the first writable component that this access object provides which resets the iteration state to the beginning.next()Returns the next component that this access object provides which can be null if either the first method has never been called or the access of components has reached the end of the chain of buffer components that this access object is assigned to.default ProtonBufferComponentdefault ProtonBufferComponentdefault Iterator<ProtonBufferComponent>default Iterable<ProtonBufferComponent>default Iterator<ProtonBufferComponent>default Iterable<ProtonBufferComponent>
-
Method Details
-
close
void close()Safe to call close in all cases the close will not throw.- Specified by:
closein interfaceAutoCloseable
-
first
ProtonBufferComponent first()Returns the first component that this access object provides which resets the iteration state to the beginning.- Returns:
- the first component in the sequence of
ProtonBufferComponentinstance.
-
firstReadable
Returns the first readable component that this access object provides which resets the iteration state to the beginning.- Returns:
- the first readable component in the sequence of
ProtonBufferComponentinstance.
-
firstWritable
Returns the first writable component that this access object provides which resets the iteration state to the beginning.- Returns:
- the first writable component in the sequence of
ProtonBufferComponentinstance.
-
next
ProtonBufferComponent next()Returns the next component that this access object provides which can be null if either the first method has never been called or the access of components has reached the end of the chain of buffer components that this access object is assigned to.- Returns:
- the first component in the sequence of
ProtonBufferComponentinstance.
-
nextReadable
- Returns:
- the next readable
ProtonBufferComponentin the current chain.
-
nextWritable
- Returns:
- the next readable
ProtonBufferComponentin the current chain.
-
components
- Returns:
- an
Iterableinstance over all the buffer components this instance can reach
-
readableComponents
- Returns:
- an
Iterableinstance over all the readable buffer components this instance can reach
-
writableComponents
- Returns:
- an
Iterableinstance over all the writable buffer components this instance can reach
-
componentIterator
- Returns:
- an
Iteratorthat traverses all components within theProtonBuffer
-
readableComponentIterator
- Returns:
- an
Iteratorthat traverses all readable components within theProtonBuffer
-
writableComponentIterator
- Returns:
- an
Iteratorthat traverses all writable components within theProtonBuffer
-