public abstract class PktBody extends UtlListElement implements IOElasticBuffer.Sizer, IOElasticBuffer.Initializer
count, head, next, prev| Modifier and Type | Method and Description |
|---|---|
void |
deserialize(byte[] array,
int arrayOffset,
int length)
Deserialize a packet body from a byte array
This method invokes putFrom(array, arrayOffset, length).desync()
|
void |
deserialize(ByteBuffer buf,
int length)
Deserialize a packet body from a byte buffer
This method invokes deserialize(buf, buf.position(), length)
|
void |
deserialize(ByteBuffer buf,
int bufOffset,
int length)
Deserialize a packet body from a byte buffer
This method invokes putFrom(buf, bufOffset, length).desync()
|
void |
deserialize(IOBuffer iobuf,
int iobufOffset,
int length)
Deserialize a packet body from an IO buffer
This method invokes
deserialize(iobuf, iobufOffset, length, false).desync()
|
void |
deserialize(IOBuffer iobuf,
int iobufOffset,
int length,
boolean wrap)
Deserialize a packet body from an IO buffer
This method invokes putFrom(iobuf, iobufOffset, length, wrap).desync()
|
void |
deserialize(IOElasticBuffer iobuf,
int iobufOffset,
int length)
Deserialize a packet body from an elastic IO buffer
This method invokes
deserialize(iobuf, iobufOffset, length).desync()
|
void |
deserialize(long addr,
int addrOffset,
int length)
Deserialize a packet body from a native memory region
This method invokes
deserialize(addr, addrOffset, length).desync()
|
void |
desync()
Desync the early desync contents of a packet body's backing buffer
|
String |
dump(String prefix)
Dump the contents of a packet body
|
IOElasticBuffer |
getBuffer()
Get the backing buffer
|
int |
getInitialBufferLength()
Implementation of
IOElasticBuffer.Sizer.getInitialBufferLength() |
int |
getSerializedLength()
Get the serialized length of a packet body
|
int |
getTo(byte[] array)
Copy the contents of a packet body's backing buffer to a byte array
This method invokes
return getTo(array, 0)
|
int |
getTo(byte[] array,
int arrayOffset)
Copy the contents of a packet body's backing buffer to a byte array
|
int |
getTo(ByteBuffer buf)
Copy the contents of a packet body's backing buffer to a byte buffer
This method invokes
return getTo(buf, buf.position())
|
int |
getTo(ByteBuffer buf,
int bufOffset)
Copy the contents of a packet body's backing buffer to a byte buffer
|
int |
getTo(IOBuffer iobuf,
int iobufOffset)
Copy the contents of a packet body's backing buffer to an
IOBuffer |
int |
getTo(IOElasticBuffer iobuf,
int iobufOffset)
Copy the contents of a packet body's backing buffer to an
IOElasticBuffer |
int |
getTo(long addr,
int addrOffset)
Copy the contents of a packet body's backing buffer to a native memory region
|
int |
getType()
Get the body type
|
void |
initializeBuffer()
Implementation of
IOElasticBuffer.Initializer.initializeBuffer()
The default implementation of this method is no-op. |
PktBody |
putFrom(byte[] array,
int arrayOffset,
int length)
Copy the contents of a packet body's backing buffer from a byte array
|
PktBody |
putFrom(ByteBuffer buf,
int length)
Copy the contents of a packet body's backing buffer from a byte buffer
This method invokes
putFrom(buf, buf.position(), length) |
PktBody |
putFrom(ByteBuffer buf,
int bufOffset,
int length)
Copy the contents of a packet body's backing buffer from a byte buffer
|
PktBody |
putFrom(IOBuffer iobuf,
int iobufOffset,
int length)
Copy the contents of a packet body's backing buffer from an
IOBuffer
This method invokes putFrom(iobuf, iobufOffset, length, false)
|
PktBody |
putFrom(IOBuffer iobuf,
int iobufOffset,
int length,
boolean wrap)
Copy the contents of a packet body's backing buffer from an
IOBuffer |
PktBody |
putFrom(IOElasticBuffer iobuf,
int iobufOffset,
int length)
Copy the contents of a packet body's backing buffer from an
IOElasticBuffer |
PktBody |
putFrom(long addr,
int addrOffset,
int length)
Copy the contents of a packet body's backing buffer from a native memory region
|
PktBody |
putFrom(PktBody src)
Copy a packet body from another packet body
|
void |
reset()
Reset the body contents
This method invokes
reset(true)
|
void |
reset(boolean initBackingBuffer)
Reset the body contents
|
int |
serialize(byte[] array,
int arrayOffset)
Serialize a packet body to a byte array
This method invokes syncf().getTo(buf, bufOffset)
|
int |
serialize(ByteBuffer buf)
Serialize a packet body to a byte buffer
This method invokes serialize(buf, buf.position())
|
int |
serialize(ByteBuffer buf,
int bufOffset)
Serialize a packet body to a byte buffer
This method invokes syncf().getTo(buf, bufOffset)
|
int |
serialize(IOBuffer iobuf,
int iobufOffset)
Serialize a packet body to an IO buffer
This method invokes syncf().getTo(iobuf, iobufOffset)
|
int |
serialize(IOElasticBuffer iobuf,
int iobufOffset)
Serialize a packet body to an elastic IO buffer
This method invokes syncf().getTo(iobuf, iobufOffset)
|
int |
serialize(long addr,
int addrOffset)
Serialize a packet body to a native memory region
This method invokes syncf().getTo(addr, addrOffset)
|
int |
sync()
Sync a packets body contents to the body's backing buffer
|
PktBody |
syncf()
Sync method for use with fluent programming
|
count, insertAfter, insertBefore, isLinked, next, previous, unlink, wipepublic final int getType()
public final IOElasticBuffer getBuffer()
public final void reset(boolean initBackingBuffer)
initializeBuffer - Whether to wipe and initialize the backing buffer
This method resets the contents of a packet body.
public final void reset()
This method invokes reset(true)
public final int getSerializedLength()
public final int sync()
Invoking this method ensures that a packet body is fully serialized to it backing buffer and can be copied out
public final PktBody syncf()
This method is the same as sync() except it return this
object instead of length for fluent invocation chaining
public final void desync()
public final int getTo(ByteBuffer buf, int bufOffset)
buf - The byte buffer to copy tobufOffset - The offset into the buffer where the serialized contents
of the packet body needs to be copiedThis method copies the contents of a packet body to a byte buffer. It copies the contents to the target buffer starting at the supplied buffer offset. This method does not change any of the markers of the target byte buffer.
Note:Since this method does not change any markers of the target buffer, the caller needs to ensure the buffer has enough capacity to accommodate the body's contents. The caller can invokegetSerializedLength() to get
the length of the body's contents and use that to set the target buffer's
capacity before invoking this method.
Note:This method does not invoke sync() before doing the
copy. The caller needs to ensure that sync() is invoked prior to invoking
this method.
public final int getTo(ByteBuffer buf)
This method invokes return getTo(buf, buf.position())
public final int getTo(byte[] array,
int arrayOffset)
array - The byte array to copy toarrayOffset - The offset into the array where the serialized contents
of the packet body needs to be copiedThis method copies the contents of a packet body to a byte array.
Note:The caller needs to ensure the target array has enough capacity to accommodate the body's contents. The caller can invokegetSerializedLength()
to get the length of the body's contents and use that to set the target array's
capacity before invoking this method.
Note:This method does not invoke sync() before doing the
copy. The caller needs to ensure that sync() is invoked prior to invoking
this method.
public final int getTo(byte[] array)
This method invokes return getTo(array, 0)
public final int getTo(IOBuffer iobuf, int iobufOffset)
IOBufferiobuf - The IO buffer to copy toiobufOffset - The offset into the IO buffer where the serialized contents
of the packet body needs to be copiedThis method copies the contents of a packet body to an IO buffer.
Note:The caller needs to ensure the target buffer has enough capacity to accommodate the body's serialized contents. The caller can invoke thegetSerializedLength() method to get the length of the body's contents
to ensure the target buffer is sized correctly
Note:This method does not invoke sync() before doing the
copy. The caller needs to ensure that sync() is invoked prior to invoking
this method.
public final int getTo(IOElasticBuffer iobuf, int iobufOffset)
IOElasticBufferiobuf - The IO buffer to copy toiobufOffset - The offset into the IO buffer where the serialized contents
of the packet body needs to be copied
This method copies the contents of a packet body to an IOelasticBuffer
sync() before doing the
copy. The caller needs to ensure that sync() is invoked prior to invoking
this method.
public final int getTo(long addr,
int addrOffset)
addr - The address of the native memory region to copy toaddrOffset - The offset into the memory region where the serialized
contents of the packet body should be copied to.This method copies the contents of a packet body to a native memory region.
Note:The caller needs to ensure the target memory region has enough capacity to accommodate the header's serialized contents. The caller can invoke thegetSerializedLength() method to get the length of the header's contents
to ensure the target region is sized correctly
Note:This method does not invoke sync() before doing the
copy. The caller needs to ensure that sync() is invoked prior to invoking
this method.
public final PktBody putFrom(ByteBuffer buf, int bufOffset, int length)
buf - The byte buffer to copy fromlength - The length of the body's serialized contentsThis method copies the contents of a packet body from a byte buffer to the packet body's buffer. It does not change any of the markers of the source byte buffer
public final PktBody putFrom(ByteBuffer buf, int length)
This method invokes putFrom(buf, buf.position(), length)
public final PktBody putFrom(byte[] array, int arrayOffset, int length)
array - The byte array to copy fromarrayOffset - The offset into the array where the serialized contents
of the packet body begins.length - The length of the body's serialized contentsThis method copies the contents of a packet from a byte array to the packet body's buffer.
public final PktBody putFrom(IOBuffer iobuf, int iobufOffset, int length, boolean wrap)
IOBufferiobuf - The IO buffer to copy fromiobufOffset - The offset into the IO buffer where the serialized contents
of the packet body begins.length - The length of the body's serialized contentswrap - Indicates whether this method should copy the contents of the IO buffer
to the packet body or wrap the packet body's buffer around the supplied IO buffer
This method copies the contents from an IOBuffer to the packet body's buffer.
public final PktBody putFrom(IOBuffer iobuf, int iobufOffset, int length)
IOBuffer
This method invokes putFrom(iobuf, iobufOffset, length, false)
public final PktBody putFrom(IOElasticBuffer iobuf, int iobufOffset, int length)
IOElasticBufferiobuf - The IO buffer to copy fromiobufOffset - The offset into the IO buffer where the serialized
contents of the packet body begins.length - The length of the body's serialized contents
This method copies the contents from an IOElasticBufferto the packet body's buffer.
public final PktBody putFrom(long addr, int addrOffset, int length)
addr - The address of the native memory region to copy fromaddrOffset - The offset into the memory region where the serialized
contents of the packet body begins.length - The length of the body's serialized contentsThis method copies the contents from a native memory region to the packet body's buffer.
public final PktBody putFrom(PktBody src)
Note: This method assumes that the source body is already sync'd
public final int serialize(ByteBuffer buf)
This method invokes serialize(buf, buf.position())
public final int serialize(ByteBuffer buf, int bufOffset)
This method invokes syncf().getTo(buf, bufOffset)
public final int serialize(byte[] array,
int arrayOffset)
This method invokes syncf().getTo(buf, bufOffset)
public final int serialize(IOBuffer iobuf, int iobufOffset)
This method invokes syncf().getTo(iobuf, iobufOffset)
public final int serialize(IOElasticBuffer iobuf, int iobufOffset)
This method invokes syncf().getTo(iobuf, iobufOffset)
public final int serialize(long addr,
int addrOffset)
This method invokes syncf().getTo(addr, addrOffset)
public final void deserialize(ByteBuffer buf, int length)
This method invokes deserialize(buf, buf.position(), length)
public final void deserialize(ByteBuffer buf, int bufOffset, int length)
This method invokes putFrom(buf, bufOffset, length).desync()
public final void deserialize(byte[] array,
int arrayOffset,
int length)
This method invokes putFrom(array, arrayOffset, length).desync()
public final void deserialize(IOBuffer iobuf, int iobufOffset, int length, boolean wrap)
This method invokes putFrom(iobuf, iobufOffset, length, wrap).desync()
public final void deserialize(IOBuffer iobuf, int iobufOffset, int length)
This method invokes deserialize(iobuf, iobufOffset, length, false).desync()
public final void deserialize(IOElasticBuffer iobuf, int iobufOffset, int length)
This method invokes deserialize(iobuf, iobufOffset, length).desync()
public final void deserialize(long addr,
int addrOffset,
int length)
This method invokes deserialize(addr, addrOffset, length).desync()
public final int getInitialBufferLength()
IOElasticBuffer.Sizer.getInitialBufferLength()getInitialBufferLength in interface IOElasticBuffer.SizerdoGetInitialBufferLength() otherwisepublic void initializeBuffer()
IOElasticBuffer.Initializer.initializeBuffer()
The default implementation of this method is no-op. The concrete body implementation should override and implement this method if it needs to do buffer initialization.
initializeBuffer in interface IOElasticBuffer.InitializerCopyright © 2019 N5 Technologies, Inc. All Rights Reserved.