com.googlecode.objectify.impl.save
Class LeafFieldSaver

java.lang.Object
  extended by com.googlecode.objectify.impl.save.FieldSaver
      extended by com.googlecode.objectify.impl.save.LeafFieldSaver
All Implemented Interfaces:
ConverterSaveContext, Saver

public class LeafFieldSaver
extends FieldSaver
implements ConverterSaveContext

Saver which knows how to save basic leaf values. Leaf values are things that go into the datastore: basic types or collections of basic types. Basically anything except an @Embedded.


Constructor Summary
LeafFieldSaver(Conversions conv, java.lang.Class<?> examinedClass, java.lang.reflect.Field field, boolean ignoreClassIndexing, boolean collectionize)
           
 
Method Summary
 java.lang.reflect.Field getField()
           
 boolean inEmbeddedCollection()
           
protected  java.lang.Object prepareForSave(java.lang.Object value)
          Converts the value into an object suitable for storing in the datastore.
 void saveValue(java.lang.Object value, com.google.appengine.api.datastore.Entity entity, Path path, boolean index)
          Actually save the value in the entity.
 
Methods inherited from class com.googlecode.objectify.impl.save.FieldSaver
save, setEntityProperty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LeafFieldSaver

public LeafFieldSaver(Conversions conv,
                      java.lang.Class<?> examinedClass,
                      java.lang.reflect.Field field,
                      boolean ignoreClassIndexing,
                      boolean collectionize)
Parameters:
field - must be a noncollection, nonarray type if collectionize is true
ignoreClassIndexing - see the FieldSaver javadocs
collectionize - when true will cause this leaf saver to persist simple basic types in a collection inside the entity property. If set is called multiple times, the collection will be appended to.
Method Detail

saveValue

public void saveValue(java.lang.Object value,
                      com.google.appengine.api.datastore.Entity entity,
                      Path path,
                      boolean index)
Description copied from class: FieldSaver
Actually save the value in the entity. This is the real value, already obtained from the POJO and checked against the @Unsaved mechanism..

Specified by:
saveValue in class FieldSaver
path - TODO

prepareForSave

protected java.lang.Object prepareForSave(java.lang.Object value)
Converts the value into an object suitable for storing in the datastore. This is the "parallel" method of LeafSetter; not that because outbound processing of arrays and collections is so simple, we don't have an object hierarchy to deal with that case.

Parameters:
value - can be any basic type or an array or collection of basic types
Returns:
something that can be saved in the datastore; note that arrays are always converted to collections.

inEmbeddedCollection

public boolean inEmbeddedCollection()
Specified by:
inEmbeddedCollection in interface ConverterSaveContext
Returns:
true if the field we are converting data for is inside an embedded collection.

getField

public java.lang.reflect.Field getField()
Specified by:
getField in interface ConverterSaveContext
Returns:
the field that is being saved.


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