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 TypeMethodDescriptionvoid
close()
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 ProtonBufferComponent
Returns the first readable component that this access object provides which resets the iteration state to the beginning.default ProtonBufferComponent
Returns 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 ProtonBufferComponent
default ProtonBufferComponent
default 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:
close
in 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
ProtonBufferComponent
instance.
-
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
ProtonBufferComponent
instance.
-
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
ProtonBufferComponent
instance.
-
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
ProtonBufferComponent
instance.
-
nextReadable
- Returns:
- the next readable
ProtonBufferComponent
in the current chain.
-
nextWritable
- Returns:
- the next readable
ProtonBufferComponent
in the current chain.
-
components
- Returns:
- an
Iterable
instance over all the buffer components this instance can reach
-
readableComponents
- Returns:
- an
Iterable
instance over all the readable buffer components this instance can reach
-
writableComponents
- Returns:
- an
Iterable
instance over all the writable buffer components this instance can reach
-
componentIterator
- Returns:
- an
Iterator
that traverses all components within theProtonBuffer
-
readableComponentIterator
- Returns:
- an
Iterator
that traverses all readable components within theProtonBuffer
-
writableComponentIterator
- Returns:
- an
Iterator
that traverses all writable components within theProtonBuffer
-