fulmine.protocol.specification
Class FieldWriter

java.lang.Object
  extended by fulmine.protocol.specification.FieldWriter

public final class FieldWriter
extends Object

Utility methods for writing fields into byte[] form. This is an implementation of the fulmine delta (FD) protocol. Writing a component includes writing the identity of the component (as a component spec) and the value of the component. This technique is covered in the "Fulmine Delta Transmission Protocol" specification.

If a component has an integer wire format (IWF), the component spec is:

 |   1 byte        |   fbc bytes     |  dbc bytes      |
 -------------------------------------------------------
 | 7 6 5 4 3 2 1 0 |                 |                 |
 -------------------------------------------------------
 |   fbc  |   dbc  |   component     |    dpos         |
 
Otherwise (for string wire format - SWF) it is:
 | 1 byte | 1 byte |   fbc bytes     |  dbc bytes      |
 -------------------------------------------------------
 |        |        |                 |                 |
 -------------------------------------------------------
 |   fbc  |   dbc  |   component     |    dpos         |
 

Author:
Ramon Servadei
See Also:
FieldReader

Constructor Summary
FieldWriter()
           
 
Method Summary
static void writeBooleanField(IWireIdentity wireId, boolean data, byte[][] headerBuffer, int[] headerBufferPosition, byte[][] dataBuffer, int[] dataBufferPosition)
          Write the component spec for a boolean component represented by the wireId to the buffer held in headerBuffer[0] starting at headerBufferPosition[0].
static void writeDoubleField(IWireIdentity wireId, double data, byte[][] headerBuffer, int[] headerBufferPosition, byte[][] dataBuffer, int[] dataBufferPosition)
          Write the component spec for a double component represented by the wireId to the buffer held in headerBuffer[0] starting at headerBufferPosition[0].
static void writeFloatField(IWireIdentity wireId, float data, byte[][] headerBuffer, int[] headerBufferPosition, byte[][] dataBuffer, int[] dataBufferPosition)
          Write the component spec for a float component represented by the wireId to the buffer held in headerBuffer[0] starting at headerBufferPosition[0].
static void writeIntegerField(IWireIdentity wireId, int data, byte[][] headerBuffer, int[] headerBufferPosition, byte[][] dataBuffer, int[] dataBufferPosition)
          Write the component spec for an integer component represented by the wireId to the buffer held in headerBuffer[0] starting at headerBufferPosition[0].
static void writeLongField(IWireIdentity wireId, long data, byte[][] headerBuffer, int[] headerBufferPosition, byte[][] dataBuffer, int[] dataBufferPosition)
          Write the component spec for a long component represented by the wireId to the buffer held in headerBuffer[0] starting at headerBufferPosition[0].
static void writeRawBytesField(IWireIdentity wireId, byte[] data, byte[][] headerBuffer, int[] headerBufferPosition, byte[][] dataBuffer, int[] dataBufferPosition)
          Write the component spec for a raw byte[] component represented by the wireId to the buffer held in headerBuffer[0] starting at headerBufferPosition[0].
static void writeStringField(IWireIdentity wireId, String data, byte[][] headerBuffer, int[] headerBufferPosition, byte[][] dataBuffer, int[] dataBufferPosition)
          Write the component spec for a String component represented by the wireId to the buffer held in headerBuffer[0] starting at headerBufferPosition[0].
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FieldWriter

public FieldWriter()
Method Detail

writeRawBytesField

public static void writeRawBytesField(IWireIdentity wireId,
                                      byte[] data,
                                      byte[][] headerBuffer,
                                      int[] headerBufferPosition,
                                      byte[][] dataBuffer,
                                      int[] dataBufferPosition)
Write the component spec for a raw byte[] component represented by the wireId to the buffer held in headerBuffer[0] starting at headerBufferPosition[0]. The raw byte[] data for the component is written to the buffer held in dataBuffer[0] starting at dataBufferPosition[0].

When this method completes, headerBufferPosition[0] points to the end of the data in headerBuffer[0] and, similarly, dataBufferPosition[0] points to the end of the data in dataBufferPosition[0].

Parameters:
wireId - the 'wire' identity of the component to write in the component spec
data - the data to write to the buffer held in dataBuffer[0]
headerBuffer - headerBuffer[0] holds the buffer for the header, this is where the component spec is written to
headerBufferPosition - headerBufferPosition[0] points to the position in headerBuffer[0] where the component spec should be written to. When this method completes, headerBufferPosition[0] points to the end of the header data in headerDataBuffer[0]
dataBuffer - dataBuffer[0] holds the buffer for the data
dataBufferPosition - dataBufferPosition[0] points to the position in dataBuffer[0] where the data should be written to. When this method completes, dataBufferPosition[0] points to the end of the data in dataBuffer[0]

writeIntegerField

public static void writeIntegerField(IWireIdentity wireId,
                                     int data,
                                     byte[][] headerBuffer,
                                     int[] headerBufferPosition,
                                     byte[][] dataBuffer,
                                     int[] dataBufferPosition)
Write the component spec for an integer component represented by the wireId to the buffer held in headerBuffer[0] starting at headerBufferPosition[0]. The data for the component is written to the buffer held in dataBuffer[0] starting at dataBufferPosition[0].

When this method completes, headerBufferPosition[0] points to the end of the data in headerBuffer[0] and, similarly, dataBufferPosition[0] points to the end of the data in dataBufferPosition[0].

Parameters:
wireId - the 'wire' identity of the component to write in the component spec
data - the data to write to the buffer held in dataBuffer[0]
headerBuffer - headerBuffer[0] holds the buffer for the header, this is where the component spec is written to
headerBufferPosition - headerBufferPosition[0] points to the position in headerBuffer[0] where the component spec should be written to. When this method completes, headerBufferPosition[0] points to the end of the header data in headerDataBuffer[0]
dataBuffer - dataBuffer[0] holds the buffer for the data
dataBufferPosition - dataBufferPosition[0] points to the position in dataBuffer[0] where the data should be written to. When this method completes, dataBufferPosition[0] points to the end of the data in dataBuffer[0]

writeLongField

public static void writeLongField(IWireIdentity wireId,
                                  long data,
                                  byte[][] headerBuffer,
                                  int[] headerBufferPosition,
                                  byte[][] dataBuffer,
                                  int[] dataBufferPosition)
Write the component spec for a long component represented by the wireId to the buffer held in headerBuffer[0] starting at headerBufferPosition[0]. The data for the component is written to the buffer held in dataBuffer[0] starting at dataBufferPosition[0].

When this method completes, headerBufferPosition[0] points to the end of the data in headerBuffer[0] and, similarly, dataBufferPosition[0] points to the end of the data in dataBufferPosition[0].

Parameters:
wireId - the 'wire' identity of the component to write in the component spec
data - the data to write to the buffer held in dataBuffer[0]
headerBuffer - headerBuffer[0] holds the buffer for the header, this is where the component spec is written to
headerBufferPosition - headerBufferPosition[0] points to the position in headerBuffer[0] where the component spec should be written to. When this method completes, headerBufferPosition[0] points to the end of the header data in headerDataBuffer[0]
dataBuffer - dataBuffer[0] holds the buffer for the data
dataBufferPosition - dataBufferPosition[0] points to the position in dataBuffer[0] where the data should be written to. When this method completes, dataBufferPosition[0] points to the end of the data in dataBuffer[0]

writeFloatField

public static void writeFloatField(IWireIdentity wireId,
                                   float data,
                                   byte[][] headerBuffer,
                                   int[] headerBufferPosition,
                                   byte[][] dataBuffer,
                                   int[] dataBufferPosition)
Write the component spec for a float component represented by the wireId to the buffer held in headerBuffer[0] starting at headerBufferPosition[0]. The data for the component is written to the buffer held in dataBuffer[0] starting at dataBufferPosition[0].

When this method completes, headerBufferPosition[0] points to the end of the data in headerBuffer[0] and, similarly, dataBufferPosition[0] points to the end of the data in dataBufferPosition[0].

Parameters:
wireId - the 'wire' identity of the component to write in the component spec
data - the data to write to the buffer held in dataBuffer[0]
headerBuffer - headerBuffer[0] holds the buffer for the header, this is where the component spec is written to
headerBufferPosition - headerBufferPosition[0] points to the position in headerBuffer[0] where the component spec should be written to. When this method completes, headerBufferPosition[0] points to the end of the header data in headerDataBuffer[0]
dataBuffer - dataBuffer[0] holds the buffer for the data
dataBufferPosition - dataBufferPosition[0] points to the position in dataBuffer[0] where the data should be written to. When this method completes, dataBufferPosition[0] points to the end of the data in dataBuffer[0]

writeDoubleField

public static void writeDoubleField(IWireIdentity wireId,
                                    double data,
                                    byte[][] headerBuffer,
                                    int[] headerBufferPosition,
                                    byte[][] dataBuffer,
                                    int[] dataBufferPosition)
Write the component spec for a double component represented by the wireId to the buffer held in headerBuffer[0] starting at headerBufferPosition[0]. The data for the component is written to the buffer held in dataBuffer[0] starting at dataBufferPosition[0].

When this method completes, headerBufferPosition[0] points to the end of the data in headerBuffer[0] and, similarly, dataBufferPosition[0] points to the end of the data in dataBufferPosition[0].

Parameters:
wireId - the 'wire' identity of the component to write in the component spec
data - the data to write to the buffer held in dataBuffer[0]
headerBuffer - headerBuffer[0] holds the buffer for the header, this is where the component spec is written to
headerBufferPosition - headerBufferPosition[0] points to the position in headerBuffer[0] where the component spec should be written to. When this method completes, headerBufferPosition[0] points to the end of the header data in headerDataBuffer[0]
dataBuffer - dataBuffer[0] holds the buffer for the data
dataBufferPosition - dataBufferPosition[0] points to the position in dataBuffer[0] where the data should be written to. When this method completes, dataBufferPosition[0] points to the end of the data in dataBuffer[0]

writeStringField

public static void writeStringField(IWireIdentity wireId,
                                    String data,
                                    byte[][] headerBuffer,
                                    int[] headerBufferPosition,
                                    byte[][] dataBuffer,
                                    int[] dataBufferPosition)
Write the component spec for a String component represented by the wireId to the buffer held in headerBuffer[0] starting at headerBufferPosition[0]. The data for the component is written to the buffer held in dataBuffer[0] starting at dataBufferPosition[0].

When this method completes, headerBufferPosition[0] points to the end of the data in headerBuffer[0] and, similarly, dataBufferPosition[0] points to the end of the data in dataBufferPosition[0].

Parameters:
wireId - the 'wire' identity of the component to write in the component spec
data - the data to write to the buffer held in dataBuffer[0]
headerBuffer - headerBuffer[0] holds the buffer for the header, this is where the component spec is written to
headerBufferPosition - headerBufferPosition[0] points to the position in headerBuffer[0] where the component spec should be written to. When this method completes, headerBufferPosition[0] points to the end of the header data in headerDataBuffer[0]
dataBuffer - dataBuffer[0] holds the buffer for the data
dataBufferPosition - dataBufferPosition[0] points to the position in dataBuffer[0] where the data should be written to. When this method completes, dataBufferPosition[0] points to the end of the data in dataBuffer[0]

writeBooleanField

public static void writeBooleanField(IWireIdentity wireId,
                                     boolean data,
                                     byte[][] headerBuffer,
                                     int[] headerBufferPosition,
                                     byte[][] dataBuffer,
                                     int[] dataBufferPosition)
Write the component spec for a boolean component represented by the wireId to the buffer held in headerBuffer[0] starting at headerBufferPosition[0]. The data for the component is written to the buffer held in dataBuffer[0] starting at dataBufferPosition[0].

When this method completes, headerBufferPosition[0] points to the end of the data in headerBuffer[0] and, similarly, dataBufferPosition[0] points to the end of the data in dataBufferPosition[0].

Parameters:
wireId - the 'wire' identity of the component to write in the component spec
data - the data to write to the buffer held in dataBuffer[0]
headerBuffer - headerBuffer[0] holds the buffer for the header, this is where the component spec is written to
headerBufferPosition - headerBufferPosition[0] points to the position in headerBuffer[0] where the component spec should be written to. When this method completes, headerBufferPosition[0] points to the end of the header data in headerDataBuffer[0]
dataBuffer - dataBuffer[0] holds the buffer for the data
dataBufferPosition - dataBufferPosition[0] points to the position in dataBuffer[0] where the data should be written to. When this method completes, dataBufferPosition[0] points to the end of the data in dataBuffer[0]


Copyright © 2007-2009. All Rights Reserved.