|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.neeve.pkt.PktSerializable.SerializeContext
public static final class PktSerializable.SerializeContext
Contains context used in the serialization of an entity.
An instance of this class is passed to the PktSerializable.serialize(com.neeve.pkt.PktSerializable.SerializeContext, com.neeve.trace.Tracer)
method
and contains information related to the serialization process. Basically,
the class stores the following pieces of information. The buffers
field is an IN-OUT field and contains a buffer list to where the entity
is serialized. The serialization process either copies serialized data
to the last buffer in the list and/or appends new buffers to the list
depending on the space remaining in the last buffer and the serialization
policy specifie. The policy field contains the serialization
policy to be used by the entity. This is an IN-OUT field allowing
an entity to modify the serialization policy to be used by subsequent
entities serialized using the same context.
It should be noted that this context does not convey the status
of the serialization. See PktSerializable.serialize(com.neeve.pkt.PktSerializable.SerializeContext, com.neeve.trace.Tracer)
on how the status is
communicated back to the user.
Method Summary | |
---|---|
PktSerializable.SerializeContext |
addBuffer(com.neeve.io.IOBuffer ioBuffer)
Add a serialization buffer |
PktSerializable.SerializeContext |
compactBuffers()
Compact buffers post draining |
static PktSerializable.SerializeContext |
create()
Create a serialize context |
PktSerializable.SerializeContext |
dropBuffers()
Wipe the buffer list clean (without dispose) |
PktSerializable.SerializeContext |
dropLastBuffer()
Drop the last buffer (without dispose) |
void |
dump(String prefix,
StringBuilder to)
Dumps content for diagnostic purposes. |
PktSerializable.SerializeContext |
flipBuffers()
Flip buffers for draining |
com.neeve.io.IOBuffer |
getBuffer(int index)
Get a serialization buffer |
int |
getBufferCount()
Get the number of buffers used.. |
long |
getBuffered()
Get bytes buffered for write |
com.neeve.io.IOBuffer[] |
getBuffers()
Get the serialization buffer list. |
ByteBuffer |
getByteBuffer(int index)
Get a serialization byte buffer |
ByteBuffer |
getByteBufferForCopy(int serializedDataLength)
Gets the next buffer to copy serialize to |
ByteBuffer[] |
getByteBuffers()
Get the serialization byte buffer list. |
int |
getPolicy()
Get the serialization policy to be used. |
long |
getRemaining()
Get remaining bytes to write |
boolean |
getSerializeWithoutMagic()
Gets whether the header will be serialized with or without magic |
PktSerializable.SerializeContext |
resizeBuffer(int index,
int newSize)
Resize a particular buffer |
PktSerializable.SerializeContext |
setBufferCount(int val)
Set current buffer count |
PktSerializable.SerializeContext |
setPolicy(int policy)
Set the serialization policy to be used. |
PktSerializable.SerializeContext |
setSerializeWithoutMagic(boolean val)
Sets whether or not to serialize with the header magic |
void |
trace(Tracer tracer,
String prefix)
Trace contents for debugging purposes |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static PktSerializable.SerializeContext create()
public final PktSerializable.SerializeContext setSerializeWithoutMagic(boolean val)
val
- A value of true will cause serialization to be done without the header magicpublic final boolean getSerializeWithoutMagic()
public final com.neeve.io.IOBuffer[] getBuffers()
public final com.neeve.io.IOBuffer getBuffer(int index)
public final ByteBuffer[] getByteBuffers()
public final ByteBuffer getByteBuffer(int index)
public final int getBufferCount()
public final PktSerializable.SerializeContext addBuffer(com.neeve.io.IOBuffer ioBuffer)
public final ByteBuffer getByteBufferForCopy(int serializedDataLength)
serializedDataLength
- The length of the data being copied.public final PktSerializable.SerializeContext resizeBuffer(int index, int newSize)
public final PktSerializable.SerializeContext flipBuffers()
public final PktSerializable.SerializeContext compactBuffers()
public final long getBuffered()
public final long getRemaining()
public final PktSerializable.SerializeContext setBufferCount(int val)
public final PktSerializable.SerializeContext dropLastBuffer()
public final PktSerializable.SerializeContext dropBuffers()
public final PktSerializable.SerializeContext setPolicy(int policy)
IllegalArgumentException
- Thrown in case the specified
policy is invalid.
The following are the permissible serialization policies:
PktConstants.SERIALIZE_POLICY_DEFAULT
PktConstants.SERIALIZE_POLICY_HEADER_COPY_BODY_COPY
PktConstants.SERIALIZE_POLICY_HEADER_COPY_BODY_ATTACH
PktConstants.SERIALIZE_POLICY_HEADER_ATTACH_BODY_ATTACH
getPolicy()
public final int getPolicy()
This method returns the serialization policy to be used by the deserialization process. This field is an IN-OUT field and therefore the user should not retain any reference to the policy outside of this context. The entity is free to change this field before returning from the serialization process.
public final void trace(Tracer tracer, String prefix)
public final void dump(String prefix, StringBuilder to)
This method includes the hex content of the dumped buffers.
prefix
- A prefix for each line in the dump.to
- A String builder to which to append.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |