org.fudgemsg.mapping
Class FudgeDeserializationContext

java.lang.Object
  extended by org.fudgemsg.mapping.FudgeDeserializationContext

public class FudgeDeserializationContext
extends Object

The central point for Fudge message to Java Object deserialization on a given stream. Note that the deserializer cannot process cyclic object graphs at the moment because of the way the builder interfaces are structured (i.e. we don't have access to an outer object until it's builder returned).

The object builder framework methods all take a deserialization context so that a deserializer can refer any sub-messages to this for construction if it does not have sufficient information to process them directly.


Constructor Summary
FudgeDeserializationContext(FudgeContext fudgeContext)
          Creates a new FudgeDeserializationContext for the given FudgeContext.
 
Method Summary
<T> T
fieldValueToObject(Class<T> clazz, FudgeField field)
          Converts a field value to a Java object with a specific type.
 Object fieldValueToObject(FudgeField field)
          Converts a field value to a Java object.
<T> T
fudgeMsgToObject(Class<T> clazz, FudgeFieldContainer message)
          Converts a Fudge message to a specific Java type.
 Object fudgeMsgToObject(FudgeFieldContainer message)
          Converts a Fudge message to a best guess Java object.
 FudgeContext getFudgeContext()
          Returns the associated FudgeContext.
 void reset()
          Resets the buffers used for object graph logics.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FudgeDeserializationContext

public FudgeDeserializationContext(FudgeContext fudgeContext)
Creates a new FudgeDeserializationContext for the given FudgeContext.

Parameters:
fudgeContext - the FudgeContext to use
Method Detail

reset

public void reset()
Resets the buffers used for object graph logics. Calling reset() on this context should match a call to FudgeSerializationContext.reset() on the context used by the serialiser to keep the states of both sender and receiver consistent.


getFudgeContext

public FudgeContext getFudgeContext()
Returns the associated FudgeContext.

Returns:
the FudgeContext.

fieldValueToObject

public Object fieldValueToObject(FudgeField field)
Converts a field value to a Java object. This may be a base Java type supported by the current FudgeTypeDictionary or if it is a sub-message will be expanded through fudgeMsgToObject(FudgeFieldContainer).

Parameters:
field - field to convert
Returns:
the deserialized object

fieldValueToObject

public <T> T fieldValueToObject(Class<T> clazz,
                                FudgeField field)
Converts a field value to a Java object with a specific type. This may be a base Java type supported by the current FudgeTypeDictionary or if it is a sub-message will be expanded through fudgeMsgToObject(Class,FudgeFieldContainer).

Type Parameters:
T - target Java type to decode to
Parameters:
clazz - class of the target Java type to decode to
field - value to decode
Returns:
the deserialized object

fudgeMsgToObject

public Object fudgeMsgToObject(FudgeFieldContainer message)
Converts a Fudge message to a best guess Java object. List and Map encodings are recognized and inflated. Any other encodings require field ordinal 0 to include possible class names to use.

Parameters:
message - message to deserialize
Returns:
the Java object

fudgeMsgToObject

public <T> T fudgeMsgToObject(Class<T> clazz,
                              FudgeFieldContainer message)
Converts a Fudge message to a specific Java type. The FudgeObjectDictionary is used to identify a builder to delegate to. If the message includes class names in ordinal 0, these will be tested for a valid builder and used if they will provide a subclass of the requested class.

Type Parameters:
T - target Java type to decode to
Parameters:
clazz - class of the target Java type to decode to
message - message to deserialise
Returns:
the deserialised Java object


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