org.fudgemsg
Class FudgeSize

java.lang.Object
  extended by org.fudgemsg.FudgeSize

public class FudgeSize
extends Object

Utility for calculating the size of a Fudge message.

These utilities calculate the size of a stream without constructing a full message.

This class is a static utility with no shared state.


Constructor Summary
FudgeSize()
           
 
Method Summary
static
<T> int
calculateFieldSize(FudgeField field)
          Calculates the size of a field (field header and value payload) in the Fudge stream in bytes when no taxonomy is used.
static
<T> int
calculateFieldSize(FudgeFieldType<T> type, T value)
          Calculates the size of a field (field header and value payload) in the Fudge stream in bytes when no taxonomy is used.
static
<T> int
calculateFieldSize(FudgeTaxonomy taxonomy, FudgeField field)
          Calculates the size of a field (field header and value payload) in the Fudge stream in bytes.
static
<T> int
calculateFieldSize(FudgeTaxonomy taxonomy, Short ordinal, String name, FudgeFieldType<T> type, T value)
          Calculates the size of a field (field header and value payload) in the Fudge stream in bytes.
static
<T> int
calculateFieldSize(Short ordinal, FudgeFieldType<T> type, T value)
          Calculates the size of a field (field header and value payload) in the Fudge stream in bytes when no taxonomy is used.
static
<T> int
calculateFieldSize(Short ordinal, String name, FudgeFieldType<T> type, T value)
          Calculates the size of a field (field header and value payload) in the Fudge stream in bytes when no taxonomy is used.
static
<T> int
calculateFieldSize(String name, FudgeFieldType<T> type, T value)
          Calculates the size of a field (field header and value payload) in the Fudge stream in bytes when no taxonomy is used.
static int calculateMessageEnvelopeSize(FudgeFieldContainer fields)
          Calculates the size of a message including the envelope header when no taxonomy is used.
static int calculateMessageEnvelopeSize(FudgeMsgEnvelope envelope)
          Calculates the size of a message including the envelope header when no taxonomy is used.
static int calculateMessageEnvelopeSize(FudgeTaxonomy taxonomy, FudgeFieldContainer fields)
          Calculates the size of a message including the envelope header.
static int calculateMessageEnvelopeSize(FudgeTaxonomy taxonomy, FudgeMsgEnvelope envelope)
          Calculates the size of a message including the envelope header.
static int calculateMessageSize(FudgeFieldContainer fields)
          Calculates the size of a message as the sum of the fields when no taxonomy is used.
static int calculateMessageSize(FudgeTaxonomy taxonomy, FudgeFieldContainer fields)
          Calculates the size of a message as the sum of the fields.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FudgeSize

public FudgeSize()
Method Detail

calculateFieldSize

public static <T> int calculateFieldSize(FudgeTaxonomy taxonomy,
                                         Short ordinal,
                                         String name,
                                         FudgeFieldType<T> type,
                                         T value)
Calculates the size of a field (field header and value payload) in the Fudge stream in bytes.

The calculation takes account of the value being reduced to fit in a smaller space.

Type Parameters:
T - the underlying Java type of the field data
Parameters:
taxonomy - the taxonomy in use, null if no taxonomy
ordinal - the field ordinal, null if no ordinal
name - the field name, null if no name
type - the Fudge field type, not null
value - the field value
Returns:
the number of bytes

calculateFieldSize

public static <T> int calculateFieldSize(FudgeTaxonomy taxonomy,
                                         FudgeField field)
Calculates the size of a field (field header and value payload) in the Fudge stream in bytes.

The calculation takes account of the value being reduced to fit in a smaller space.

Type Parameters:
T - the underlying Java type of the field data
Parameters:
taxonomy - the taxonomy in use, null if no taxonomy
field - the field to calculate a size for, not null
Returns:
the number of bytes

calculateFieldSize

public static <T> int calculateFieldSize(FudgeField field)
Calculates the size of a field (field header and value payload) in the Fudge stream in bytes when no taxonomy is used.

The calculation takes account of the value being reduced to fit in a smaller space.

Type Parameters:
T - the underlying Java type of the field data
Parameters:
field - the field to calculate a size for, not null
Returns:
the number of bytes

calculateFieldSize

public static <T> int calculateFieldSize(Short ordinal,
                                         String name,
                                         FudgeFieldType<T> type,
                                         T value)
Calculates the size of a field (field header and value payload) in the Fudge stream in bytes when no taxonomy is used.

The calculation takes account of the value being reduced to fit in a smaller space.

Type Parameters:
T - the underlying Java type of the field data
Parameters:
ordinal - the field ordinal, null if no ordinal
name - the field name, null if no name
type - the Fudge field type, not null
value - the field value
Returns:
the number of bytes

calculateFieldSize

public static <T> int calculateFieldSize(Short ordinal,
                                         FudgeFieldType<T> type,
                                         T value)
Calculates the size of a field (field header and value payload) in the Fudge stream in bytes when no taxonomy is used.

The calculation takes account of the value being reduced to fit in a smaller space.

Type Parameters:
T - the underlying Java type of the field data
Parameters:
ordinal - the field ordinal, null if no ordinal
type - the Fudge field type, not null
value - the field value
Returns:
the number of bytes

calculateFieldSize

public static <T> int calculateFieldSize(String name,
                                         FudgeFieldType<T> type,
                                         T value)
Calculates the size of a field (field header and value payload) in the Fudge stream in bytes when no taxonomy is used.

The calculation takes account of the value being reduced to fit in a smaller space.

Type Parameters:
T - the underlying Java type of the field data
Parameters:
name - the field name, null if no name
type - the Fudge field type, not null
value - the field value
Returns:
the number of bytes

calculateFieldSize

public static <T> int calculateFieldSize(FudgeFieldType<T> type,
                                         T value)
Calculates the size of a field (field header and value payload) in the Fudge stream in bytes when no taxonomy is used.

The calculation takes account of the value being reduced to fit in a smaller space.

Type Parameters:
T - the underlying Java type of the field data
Parameters:
type - the Fudge field type, not null
value - the field value
Returns:
the number of bytes

calculateMessageSize

public static int calculateMessageSize(FudgeTaxonomy taxonomy,
                                       FudgeFieldContainer fields)
Calculates the size of a message as the sum of the fields.

Parameters:
taxonomy - the taxonomy in use, null if no taxonomy
fields - the fields to calculate a size for, not null
Returns:
the number of bytes

calculateMessageSize

public static int calculateMessageSize(FudgeFieldContainer fields)
Calculates the size of a message as the sum of the fields when no taxonomy is used.

Parameters:
fields - the fields to calculate a size for, not null
Returns:
the number of bytes

calculateMessageEnvelopeSize

public static int calculateMessageEnvelopeSize(FudgeTaxonomy taxonomy,
                                               FudgeFieldContainer fields)
Calculates the size of a message including the envelope header.

Parameters:
taxonomy - the taxonomy in use, null if no taxonomy
fields - the fields to calculate a size for, not null
Returns:
the number of bytes

calculateMessageEnvelopeSize

public static int calculateMessageEnvelopeSize(FudgeFieldContainer fields)
Calculates the size of a message including the envelope header when no taxonomy is used.

Parameters:
fields - the fields to calculate a size for, not null
Returns:
the number of bytes

calculateMessageEnvelopeSize

public static int calculateMessageEnvelopeSize(FudgeTaxonomy taxonomy,
                                               FudgeMsgEnvelope envelope)
Calculates the size of a message including the envelope header.

Parameters:
taxonomy - the taxonomy in use, null if no taxonomy
envelope - the message envelope to calculate a size for, not null
Returns:
the number of bytes

calculateMessageEnvelopeSize

public static int calculateMessageEnvelopeSize(FudgeMsgEnvelope envelope)
Calculates the size of a message including the envelope header when no taxonomy is used.

Parameters:
envelope - the message envelope to calculate a size for, not null
Returns:
the number of bytes


Copyright 2009-Present by OpenGamma Inc. and individual contributors
Released under the Apache License, Version 2.0