org.fudgemsg
Class FudgeMsg

java.lang.Object
  extended by org.fudgemsg.FudgeMsgBase
      extended by org.fudgemsg.FudgeMsg
All Implemented Interfaces:
Serializable, Iterable<FudgeField>, FudgeFieldContainer, MutableFudgeFieldContainer

public class FudgeMsg
extends FudgeMsgBase
implements MutableFudgeFieldContainer

A mutable message in the Fudge system.

The message consists of a list of Fudge fields. This class holds the entire message in memory.

Applications are recommended to store and manipulate a FudgeFieldContainer instance or a MutableFudgeFieldContainer rather than this class for future flexibility.

This class is mutable and not thread-safe.

See Also:
Serialized Form

Constructor Summary
protected FudgeMsg(FudgeContext fudgeContext)
          Constructor taking a Fudge context.
protected FudgeMsg(FudgeFieldContainer fields, FudgeContext fudgeContext)
          Constructor taking a set of fields and a Fudge context.
 
Method Summary
 void add(FudgeField field)
          Adds a field to this container.
 void add(Integer ordinal, Object value)
          Adds a field to this container with an ordinal, no name, and type determined by the context's type dictionary.
 void add(String name, Integer ordinal, FudgeFieldType<?> type, Object value)
          Adds a field to this container with the given name, ordinal, and type.
 void add(String name, Integer ordinal, Object value)
          Adds a field to this container with the given name, ordinal and type determined by the context's type dictionary.
 void add(String name, Object value)
          Adds a field to this container with a name, no ordinal, and type determined by the context's type dictionary.
 void clear()
          Removes all fields from the message.
protected  FudgeFieldType<?> determineTypeFromValue(Object value)
          Resolves an arbitrary Java object to an underlying Fudge type (if possible).
 boolean equals(Object obj)
          Checks if this message equals another.
 Iterator<FudgeField> iterator()
          Gets an iterator over the list of fields in this container.
 void remove(Short ordinal)
          Removes all fields with the given ordinal.
 void remove(String name)
          Removes all fields with the given name.
 void remove(String name, Short ordinal)
          Removes all fields matching both the name and ordinal supplied.
 void setNamesFromTaxonomy(FudgeTaxonomy taxonomy)
          Resolves any field ordinals to field names from the given taxonomy.
 
Methods inherited from class org.fudgemsg.FudgeMsgBase
fieldNameEquals, fieldOrdinalEquals, getAllByName, getAllByOrdinal, getAllFieldNames, getAllFields, getBoolean, getBoolean, getByIndex, getByName, getByOrdinal, getByte, getByte, getDouble, getDouble, getFields, getFieldValue, getFirstTypedValue, getFirstTypedValue, getFloat, getFloat, getFudgeContext, getInt, getInt, getLong, getLong, getMessage, getMessage, getNumFields, getShort, getShort, getString, getString, getValue, getValue, getValue, getValue, hasField, hasField, hashCode, isEmpty, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.fudgemsg.FudgeFieldContainer
getAllByName, getAllByOrdinal, getAllFieldNames, getAllFields, getBoolean, getBoolean, getByIndex, getByName, getByOrdinal, getByte, getByte, getDouble, getDouble, getFieldValue, getFloat, getFloat, getInt, getInt, getLong, getLong, getMessage, getMessage, getNumFields, getShort, getShort, getString, getString, getValue, getValue, getValue, getValue, hasField, hasField, isEmpty
 

Constructor Detail

FudgeMsg

protected FudgeMsg(FudgeContext fudgeContext)
Constructor taking a Fudge context.

Parameters:
fudgeContext - the FudgeContext to use for type resolution and other services

FudgeMsg

protected FudgeMsg(FudgeFieldContainer fields,
                   FudgeContext fudgeContext)
Constructor taking a set of fields and a Fudge context.

The fields from the container are copied into this message, creating a new field for each supplied field.

Parameters:
fields - the initial set of fields, not null
fudgeContext - the context to use for type resolution and other services, not null
Method Detail

add

public void add(FudgeField field)
Adds a field to this container.

Specified by:
add in interface MutableFudgeFieldContainer
Parameters:
field - the field to add, not null

add

public void add(String name,
                Object value)
Adds a field to this container with a name, no ordinal, and type determined by the context's type dictionary.

Specified by:
add in interface MutableFudgeFieldContainer
Parameters:
name - the name of the field, null for none
value - the field value, not null

add

public void add(Integer ordinal,
                Object value)
Adds a field to this container with an ordinal, no name, and type determined by the context's type dictionary.

Specified by:
add in interface MutableFudgeFieldContainer
Parameters:
ordinal - the ordinal for the field, null for none
value - the field value, not null

add

public void add(String name,
                Integer ordinal,
                Object value)
Adds a field to this container with the given name, ordinal and type determined by the context's type dictionary.

Specified by:
add in interface MutableFudgeFieldContainer
Parameters:
name - the name of the field, null for none
ordinal - the ordinal index for the field, null for none
value - the field value, not null

add

public void add(String name,
                Integer ordinal,
                FudgeFieldType<?> type,
                Object value)
Adds a field to this container with the given name, ordinal, and type.

Specified by:
add in interface MutableFudgeFieldContainer
Parameters:
name - the name of the field, null for none
ordinal - the ordinal for the field, null for none
type - the field type, not null
value - the field value, not null

determineTypeFromValue

protected FudgeFieldType<?> determineTypeFromValue(Object value)
Resolves an arbitrary Java object to an underlying Fudge type (if possible).

Parameters:
value - the object to resolve, null returns the indicator type
Returns:
the field type, null if no intrinsic type (or registered secondary type) is available

setNamesFromTaxonomy

public void setNamesFromTaxonomy(FudgeTaxonomy taxonomy)
Resolves any field ordinals to field names from the given taxonomy.

Overrides:
setNamesFromTaxonomy in class FudgeMsgBase
Parameters:
taxonomy - the taxonomy to use, null ignored

iterator

public Iterator<FudgeField> iterator()
Gets an iterator over the list of fields in this container.

A container is ordered and the returned iterator reflects that order.

Specified by:
iterator in interface Iterable<FudgeField>
Specified by:
iterator in interface FudgeFieldContainer
Overrides:
iterator in class FudgeMsgBase
Returns:
the iterator of fields, may be unmodifiable, not null

remove

public void remove(Short ordinal)
Removes all fields with the given ordinal.

Specified by:
remove in interface MutableFudgeFieldContainer
Parameters:
ordinal - ordinal index of fields, null matches fields without an ordinal

remove

public void remove(String name)
Removes all fields with the given name.

Specified by:
remove in interface MutableFudgeFieldContainer
Parameters:
name - name of the fields, null matches fields without a name

remove

public void remove(String name,
                   Short ordinal)
Removes all fields matching both the name and ordinal supplied.

Specified by:
remove in interface MutableFudgeFieldContainer
Parameters:
name - the name of the fields to remove
ordinal - the ordinal of the fields to remove

clear

public void clear()
Removes all fields from the message.

Specified by:
clear in interface MutableFudgeFieldContainer

equals

public boolean equals(Object obj)
Checks if this message equals another.

The check is performed on the entire list of fields in the message.

Overrides:
equals in class FudgeMsgBase
Parameters:
obj - the object to compare to, null returns false
Returns:
true if equal


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