com.neeve.sto
Class StoCompoundField

java.lang.Object
  extended by com.neeve.util.UtlListElement
      extended by com.neeve.sto.StoField
          extended by com.neeve.sto.StoVariableLengthField<StoFieldContainer>
              extended by com.neeve.sto.StoCompoundField
All Implemented Interfaces:
Cloneable

public final class StoCompoundField
extends StoVariableLengthField<StoFieldContainer>

An STO field that holds a compound value.

Threading:
STO fields are not safe for concurrent access by multiple threads.

Nested Class Summary
 
Nested classes/interfaces inherited from class com.neeve.sto.StoField
StoField.Type
 
Field Summary
static int HEADER_LENGTH
           
 
Fields inherited from class com.neeve.util.UtlListElement
count, head, next, prev
 
Method Summary
static StoCompoundField create(ByteBuffer buffer, int bufferOffset)
          Create an STO compound field from its serialized form.
static StoCompoundField create(String name)
          Create an STO compound field.
static StoFieldContainer get(ByteBuffer buffer, int offset)
          Deserialize an STO field container.
static int getBodySerializedLength(ByteBuffer buffer, int offset)
          Get the length of a serialized body of a compound value.
static int getBodySerializedLength(StoFieldContainer val)
          Get the serialized length of the body of a compound value
static int getSerializedLength(ByteBuffer buffer, int offset)
          Get the length of a serialized compound value.
static int getSerializedLength(StoFieldContainer val)
          Get the serialized length of a compound value.
static int put(ByteBuffer buffer, int offset, StoFieldContainer val)
          Serialize an STO field container as a compound field body.
 
Methods inherited from class com.neeve.sto.StoVariableLengthField
getValue, isVariableLength, reset, setValue
 
Methods inherited from class com.neeve.sto.StoField
changeBackingBuffer, clearBackingBuffer, clone, contentsEquals, getBackingBuffer, getHeader, getLength, getName, getSerializedLength, getType, getVersion, isNamed, setBackingBuffer, shiftForHeader, sync, toString
 
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, wait, wait, wait
 

Field Detail

HEADER_LENGTH

public static final int HEADER_LENGTH
See Also:
Constant Field Values
Method Detail

create

public static StoCompoundField create(String name)
Create an STO compound field.

Parameters:
name - The name of the field. A value of null will cause an unnamed field to be created.

create

public static StoCompoundField create(ByteBuffer buffer,
                                      int bufferOffset)
Create an STO compound field from its serialized form.

Parameters:
buffer - The buffer containing the serialized field.
bufferOffset - The offset into the buffer where the serialized form of the field begins.

getBodySerializedLength

public static final int getBodySerializedLength(ByteBuffer buffer,
                                                int offset)
Get the length of a serialized body of a compound value.

A compound field serializes its value preceded by a header (containing type information, etc). This method returns the length of the serialized portion excluding the header portion.


getSerializedLength

public static int getSerializedLength(ByteBuffer buffer,
                                      int offset)
Get the length of a serialized compound value.

Parameters:
buffer - The buffer containing the serialized value.
offset - The offset into the buffer where the value is serialized.

The value returned by this method is HEADER_LENGTH + the value returned by getBodySerializedLength(ByteBuffer, int)

This method leaves the buffer markers intact.


getBodySerializedLength

public static final int getBodySerializedLength(StoFieldContainer val)
Get the serialized length of the body of a compound value


getSerializedLength

public static int getSerializedLength(StoFieldContainer val)
Get the serialized length of a compound value.

Parameters:
val - The compound value whose serialized length is to be returned.

The value returned by this method is HEADER_LENGTH + the valkue returned by getBodySerializedLength(StoFieldContainer)


put

public static int put(ByteBuffer buffer,
                      int offset,
                      StoFieldContainer val)
Serialize an STO field container as a compound field body.

Parameters:
buffer - The buffer in which to serialize the array.
offset - The offset into the buffer at which point to serialize the container.
Returns:
Returns the serialized length

A field container, when serialized, does not serialize any preamble information regarding serialized length. Therefore, to deserialize a container (using StoFieldContainer.create(ByteBuffer)), the user needs to manage the buffer markers such that the 'remaining' bytes in te buffer exactly contain the serialized container. This works well for root containers. However, for embedded containers, information needs to be serialized so that the deserialization process can ascertain the serialized length from the wire. This method performs that.

This method always syncs the container to the specified buffer.

This method leaves the buffer markers intact.


get

public static StoFieldContainer get(ByteBuffer buffer,
                                    int offset)
Deserialize an STO field container.

Parameters:
buffer - The byte array from which to deserialize the value.
offset - The offset into the array from which to deserialize the array.

This method works to deserialize field containers serialized using put(java.nio.ByteBuffer, int, com.neeve.sto.StoFieldContainer)

This method leaves the buffer markers intact.



Copyright © 2015 Neeve Research, LLC. All Rights Reserved.