com.googlecode.objectify.impl.conv
Class Conversions

java.lang.Object
  extended by com.googlecode.objectify.impl.conv.Conversions

public class Conversions
extends java.lang.Object

Manages all the converters used to translate between POJO fields and the types that the Datastore can actually persist. Essentially acts as an aggregator for all the Converter objects.

Note that this does NOT implement Converter; the return values of the methods are not the same when a conversion is not found.

THIS API IS EXPERIMENTAL. It may change significantly in minor point releases.


Constructor Summary
Conversions(ObjectifyFactory fact)
          Initialize the default set of converters.
 
Method Summary
 void add(Converter cvt)
          Add a new converter to the list.
 java.lang.Object forDatastore(java.lang.Object value, ConverterSaveContext ctx)
          Run the value through all the converters; the first converter that returns a non-null value produces the response for this method.
 java.lang.Object forPojo(java.lang.Object value, java.lang.Class<?> fieldType, ConverterLoadContext ctx, java.lang.Object onPojo)
          Run the value through all the converters; the first converter that returns a non-null value produces the response for this method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Conversions

public Conversions(ObjectifyFactory fact)
Initialize the default set of converters.

Method Detail

add

public void add(Converter cvt)
Add a new converter to the list. Converters are added in order but before the builtin conversions.


forDatastore

public java.lang.Object forDatastore(java.lang.Object value,
                                     ConverterSaveContext ctx)
Run the value through all the converters; the first converter that returns a non-null value produces the response for this method.

Returns:
the original value if no hits. This is different than the normal return value defined by the Converter interface.

forPojo

public java.lang.Object forPojo(java.lang.Object value,
                                java.lang.Class<?> fieldType,
                                ConverterLoadContext ctx,
                                java.lang.Object onPojo)
Run the value through all the converters; the first converter that returns a non-null value produces the response for this method.

Parameters:
fieldType - if null will simply return the value as-is; we can't do any conversion if we don't know the type!
Returns:
the converted object
Throws:
java.lang.IllegalArgumentException - if we weren't able to find a proper conversion


Copyright © 2011 Jeff Schnitzer and a gang of pirates. All Rights Reserved. Build version: 3.1