D - data typeW - wrapper to hold partially read datapublic interface DataPacker<D,W>
| Modifier and Type | Method and Description | 
|---|---|
| int | determineLength(D data,
               PackerStore store)Pack the data and return the size of the data in bytes once packed. | 
| boolean | isHeaderRequired()Indicates whether length should be packed before the actual key | 
| byte[] | packToByteArray(D data) | 
| java.nio.ByteBuffer | packToByteBuffer(java.nio.ByteBuffer byteBuffer,
                D data)This method puts a value to the  ByteBuffer. | 
| java.nio.ByteBuffer | packToByteBuffer(java.nio.ByteBuffer byteBuffer,
                int offset,
                D data)This method puts a value to the  ByteBuffer, starting from specified
 index of the buffer. | 
| int | readDataFromBuffer(ObjectBuilder<D,W> objectBuilder,
                  int currentBufferLocation,
                  DataBuffer dataBuffer)Read the buffer and build the actual object. | 
| D | unpackFromBuffer(java.nio.ByteBuffer byteBuffer,
                int byteLength)This method will extract a value from buffer starting from buffer's current position. | 
| D | unpackFromBuffer(java.nio.ByteBuffer byteBuffer,
                int bufferOffset,
                int byteLength)This method will extract a value from buffer starting from the position specified. | 
| default D | unpackFromByteArray(byte[] array) | 
| W | wrapperForByteLength(int byteLength)Returns an empty wrapper to hold byteLength amount of type T | 
| void | writeDataToBuffer(D data,
                 PackerStore packerStore,
                 int alreadyCopied,
                 int leftToCopy,
                 int spaceLeft,
                 java.nio.ByteBuffer targetBuffer)Transfer the data to the buffer. | 
int determineLength(D data, PackerStore store)
writeDataToBuffer(D, edu.iu.dsc.tws.api.comms.packing.PackerStore, int, int, int, java.nio.ByteBuffer), you may just
 return the byte size of data from this method.data - the data (can be Integer, Object etc)store - A store to temporary store the serialized data,
 if you had to serialize data to determine length.void writeDataToBuffer(D data, PackerStore packerStore, int alreadyCopied, int leftToCopy, int spaceLeft, java.nio.ByteBuffer targetBuffer)
determineLength(Object, PackerStore),
 you may transfer data from state
 * to targetBuffer. If not, you may directly transfer data to the targetBuffer.int readDataFromBuffer(ObjectBuilder<D,W> objectBuilder, int currentBufferLocation, DataBuffer dataBuffer)
ObjectBuilder.setFinalObject(Object)
 to set and mark the end of the current objectbyte[] packToByteArray(D data)
java.nio.ByteBuffer packToByteBuffer(java.nio.ByteBuffer byteBuffer,
                                     D data)
ByteBuffer.
 The position of byteBuffer should be updated.java.nio.ByteBuffer packToByteBuffer(java.nio.ByteBuffer byteBuffer,
                                     int offset,
                                     D data)
ByteBuffer, starting from specified
 index of the buffer.
 The position of the buffer shouldn't be affectedW wrapperForByteLength(int byteLength)
boolean isHeaderRequired()
D unpackFromBuffer(java.nio.ByteBuffer byteBuffer, int bufferOffset, int byteLength)
byteBuffer - ByteBuffer instancebufferOffset - position to start reading from bufferbyteLength - amount of data to readD unpackFromBuffer(java.nio.ByteBuffer byteBuffer, int byteLength)
default D unpackFromByteArray(byte[] array)