fulmine.protocol.specification
Class FrameWriter

java.lang.Object
  extended by fulmine.protocol.specification.FrameWriter
All Implemented Interfaces:
IFrameWriter

public final class FrameWriter
extends Object
implements IFrameWriter

A utility class for writing fulmine delta (FD) protocol frames.

Please refer to the "Fulmine Delta Transmission Protocol" specification for a complete description of the fulmine serialisation technique.

Author:
Ramon Servadei
See Also:
IFrameConstants

Constructor Summary
FrameWriter()
          Standard constructor.
 
Method Summary
static byte[] mergeBuffers(int[] headerBufferPosition, byte[][] headerBuffer, int[] dataBufferPosition, byte[][] dataBuffer)
           
 byte[] write(IContainer container)
          Write a container's state into an FD frame.
static byte[] write(IOperationScope scope, IContainer container, boolean completeState)
          Write a container's current state changes into an FD frame.
 byte[] writeComplete(IContainer container)
          Write a container's complete state into an FD frame.
static void writeHeaderAndData(IContainer container, Collection<? extends IComponent> components, IWireIdentityRegistry registry, IOperationScope scope, byte[][] headerBuffer, int[] headerBufferPosition, byte[][] dataBuffer, int[] dataBufferPosition, boolean completeState)
          Write the container and fields to the header and data buffers.
 byte[] writeMeta(IContainer container)
          Write only a container's meta state into an FD frame.
static byte[] writeNested(Collection<? extends IComponent> components, IWireIdentityRegistry registry, IOperationScope scope, boolean completeState)
          Write a nested container's state into a nested FD frame.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FrameWriter

public FrameWriter()
Standard constructor.

Method Detail

write

public static byte[] write(IOperationScope scope,
                           IContainer container,
                           boolean completeState)
Write a container's current state changes into an FD frame.

Parameters:
scope - the scope to use for the write operation
container - the container to write as a frame
completeState - whether to write the complete state or only changes
Returns:
the byte[] for the FD frame representing the state of the container

writeComplete

public byte[] writeComplete(IContainer container)
Write a container's complete state into an FD frame.

Specified by:
writeComplete in interface IFrameWriter
Parameters:
container - the container to write as a frame
Returns:
the byte[] for the FD frame representing the state of the container

write

public byte[] write(IContainer container)
Write a container's state into an FD frame.

Specified by:
write in interface IFrameWriter
Parameters:
container - the container to write as a frame
Returns:
the byte[] for the FD frame representing the state of the container

writeMeta

public byte[] writeMeta(IContainer container)
Write only a container's meta state into an FD frame. The meta state includes the current state (active/inactive)

Specified by:
writeMeta in interface IFrameWriter
Parameters:
container - the container to write
Returns:
the byte[] for the FD frame representing the meta state of the container

writeNested

public static byte[] writeNested(Collection<? extends IComponent> components,
                                 IWireIdentityRegistry registry,
                                 IOperationScope scope,
                                 boolean completeState)
Write a nested container's state into a nested FD frame. Nested FD frames have the following structure:
 -----------------------------------------------------------------
 |  nested frame preamble  |            nested frame             |
 -----------------------------------------------------------------
 |   4 byte    |  4 byte   | header size bytes | data size bytes |
 -----------------------------------------------------------------
 | header size | data size |       header      |       data      |
 -----------------------------------------------------------------
 
Notice that there is no container identifier or any of the other fields found in the general container header.

Parameters:
fields - the fields of the container to write into the frame
registry - used to get the IWF wire codes for the fields
scope - the scope of the write operation
completeState - whether to write the complete state or only changes
Returns:
the byte[] for the nested FD frame representing the state of the nested container

mergeBuffers

public static byte[] mergeBuffers(int[] headerBufferPosition,
                                  byte[][] headerBuffer,
                                  int[] dataBufferPosition,
                                  byte[][] dataBuffer)

writeHeaderAndData

public static void writeHeaderAndData(IContainer container,
                                      Collection<? extends IComponent> components,
                                      IWireIdentityRegistry registry,
                                      IOperationScope scope,
                                      byte[][] headerBuffer,
                                      int[] headerBufferPosition,
                                      byte[][] dataBuffer,
                                      int[] dataBufferPosition,
                                      boolean completeState)
Write the container and fields to the header and data buffers. The header and data buffers make up an FD frame.

Parameters:
container - the container to write into the header and data buffers of the frame
fields - the fields of the container to write into the frame, can be null
registry - used to get the IWF wire codes for the fields
scope - the scope of the write operation
headerBuffer - headerBuffer[0] holds the buffer for the header of the frame
headerBufferPosition - headerBufferPosition[0] points to the end of the header data in headerDataBuffer[0]
dataBuffer - dataBuffer[0] holds the buffer for the data of the frame
dataBufferPosition - dataBufferPosition[0] points to the end of the data in dataBuffer[0]
completeState - whether to write the complete state or only changes


Copyright © 2007-2009. All Rights Reserved.