com.neeve.sto
Class StoBufferField

java.lang.Object
  extended by com.neeve.util.UtlListElement
      extended by com.neeve.sto.StoField
          extended by com.neeve.sto.StoBufferField
All Implemented Interfaces:
Cloneable

public final class StoBufferField
extends StoField

An STO field that holds a fixed length buffer.

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

Nested Class Summary
static interface StoBufferField.ChangeNotifier
          Interface through which buffer change notifications are dispatched.
 
Nested classes/interfaces inherited from class com.neeve.sto.StoField
StoField.Type
 
Field Summary
 
Fields inherited from class com.neeve.util.UtlListElement
count, head, next, prev
 
Method Summary
static StoBufferField create(ByteBuffer buffer, int bufferOffset)
          Create an STO fixed length buffer field from its serialized form.
static StoBufferField create(String name, int len)
          Create an STO fixed length buffer field.
static int getSerializedLength(ByteBuffer buffer, int offset)
          Get the length of a serialized buffer.
 ByteBuffer getValue()
          Get the field value.
 ByteBuffer getValue(StoBufferField.ChangeNotifier notifier)
          Get the field value and install a change notifier.
 boolean isVariableLength()
          Implementation of StoField.isVariableLength()
 void reset()
          Implementation of StoField.reset()
static int shiftForPreamble(int val)
          Shift a number by preamble length.
 
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
 

Method Detail

create

public static StoBufferField create(String name,
                                    int len)
Create an STO fixed length buffer field.

Parameters:
name - The name of the field. A value of null will cause an unnamed field to be created.
len - The length of the field. This value must be >= 0.

create

public static StoBufferField create(ByteBuffer buffer,
                                    int bufferOffset)
Create an STO fixed length buffer 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.

isVariableLength

public final boolean isVariableLength()
Implementation of StoField.isVariableLength()

Specified by:
isVariableLength in class StoField

reset

public final void reset()
Implementation of StoField.reset()

Specified by:
reset in class StoField

shiftForPreamble

public static int shiftForPreamble(int val)
Shift a number by preamble length.


getSerializedLength

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

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

This method leaves the buffer markers intact.


getValue

public final ByteBuffer getValue()
Get the field value.

It is important to note that the buffer returned from this methods can change across invocations. However, this can only happen if one or more operations were performed on the field between invocations that change the state of the backing buffer.

Note: This method leaves any installed change notifier in place.


getValue

public final ByteBuffer getValue(StoBufferField.ChangeNotifier notifier)
Get the field value and install a change notifier.

Parameters:
notifier - The change notifier to install. The notifier will be invoked when the buffer value returned by this method asynchronously changes (e.g. due to backing buffer resizing etc). A value of null will clear the installed notifier.

This method is the same as getValue() except that it installs a change notifier for the user to be asychronously notified of changes to the returned buffer reference.



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