|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.neeve.util.UtlListElement
com.neeve.pkt.PktSerializable
com.neeve.pkt.PktBody
public abstract class PktBody
Base class for all packet bodies.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class com.neeve.pkt.PktSerializable |
---|
PktSerializable.DeserializeContext, PktSerializable.SerializeContext |
Field Summary |
---|
Fields inherited from class com.neeve.util.UtlListElement |
---|
count, head, next, prev |
Method Summary | |
---|---|
void |
deserialize(PktSerializable.DeserializeContext context,
int bodySerializedLength,
Tracer tracer)
Implementation of PktSerializable.deserialize(com.neeve.pkt.PktSerializable.DeserializeContext, int, com.neeve.trace.Tracer) |
PktBuffer |
getBuffer()
Get the backing buffer |
int |
getSerializedLength()
Implementation of PktSerializable.getSerializedLength() |
int |
getType()
Get the body type |
void |
initializeBuffer()
Implementation of PktBuffer.Initializer.initializeBuffer()
The default implementation of this method is no-op. |
boolean |
isNative()
Get if the body is backed by a native or heap buffer |
void |
reset()
Reset the body contents This method resets the contents of a packet body. |
void |
serialize(PktSerializable.SerializeContext context,
Tracer tracer)
Implementation of PktSerializable.serialize(com.neeve.pkt.PktSerializable.SerializeContext, com.neeve.trace.Tracer)
This method serializes the packet body into the buffer list
in the specified serialization context. |
Methods inherited from class com.neeve.pkt.PktSerializable |
---|
deserialize, getDeserializationPolicy, getSerializationPolicy, isValidDeserializationPolicy, isValidSerializationPolicy, serialize, setDeserializationPolicy, setSerializationPolicy |
Methods inherited from class com.neeve.util.UtlListElement |
---|
count, insertAfter, insertBefore, isLinked, next, previous, unlink, wipe |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public final int getType()
public final boolean isNative()
public final PktBuffer getBuffer()
public final void reset()
This method resets the contents of a packet body. Upon return from this method, the contents of the body are the same as a freshly created body of the same type.
This method retains its references (if any) to its enclosing packet and associated packet header.
This method is intended for use with object pools through which packet body objects can be recycled rather than created fresh every time.
public final int getSerializedLength()
PktSerializable.getSerializedLength()
getSerializedLength
in class PktSerializable
public final void serialize(PktSerializable.SerializeContext context, Tracer tracer) throws EPktSerializeException
PktSerializable.serialize(com.neeve.pkt.PktSerializable.SerializeContext, com.neeve.trace.Tracer)
This method serializes the packet body into the buffer list
in the specified serialization context. This method invokes
PktSerializable.resolveSerializationPolicy(int)
using the
policy in the specified context to resolve the serialization
policy to use. The default serialization policy set in this
entity is determined using the configuration information for
the type of the packet being serialized.
serialize
in class PktSerializable
context
- The context to be used by the serialization process. See
PktSerializable.SerializeContext
for more information.tracer
- Tracer used to output serialization related trace. Can be
null in which case no trace is output.
EPktSerializeException
- Thrown in case an error is encountered
during the serialization process.
This method serializes a serialiable entity into a byte array presented as a set of byte buffers. As input, this method accepts a serialization context that, among other fields, contains a list of buffers of type {link java.nio.ByteBuffer} into which the entity is to serialize itself. The serialization operation is policy driven and the policy determines whether the header is copied into space remaining in the provided buffers or whether the internal entity buffers are just appended to the provided buffer list. In case the decision is made to copy the serialized data into the provided buffers, the data is always copied into the last buffer in the list. In case the last buffer does not contain enough remaining space to accomodate all the serialized data, this method will allocate and append a new buffer that will be of the same type and capacity as the last buffer in the provided list. Read the documentation of the policy constants to understand which policies cause the header to be copied as opposed to appended (the policy constant names are also self descriptive)
public final void deserialize(PktSerializable.DeserializeContext context, int bodySerializedLength, Tracer tracer) throws EPktDeserializeException
PktSerializable.deserialize(com.neeve.pkt.PktSerializable.DeserializeContext, int, com.neeve.trace.Tracer)
deserialize
in class PktSerializable
context
- The context to be used by the deserialization process.
See PktSerializable.DeserializeContext
for more information.bodySerializedLength
- This parameter is present for entities
whose serialized form does not contain the serialized length of the
entity. For such entities, the caller needs to pass in the serialized
length to the entity during deserialize time. For other entities, this
value will be ignored and should be set to -1 (some entities that
pull the length from the serialized form may indeed validate that
the passed in value is -1)tracer
- Tracer used to output deserialization related trace. Can be
null in which case no trace is output.
EPktDeserializeException
public void initializeBuffer()
PktBuffer.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 PktBuffer.Initializer
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |