Package com.googlecode.objectify.util
Class DatastoreUtils
java.lang.Object
com.googlecode.objectify.util.DatastoreUtils
public class DatastoreUtils extends Object
Some static utility methods for interacting with basic datastore objects like keys and queries.
-
Method Summary
Modifier and TypeMethodDescriptionstatic com.google.appengine.api.datastore.Query
cloneQuery(com.google.appengine.api.datastore.Query orig)
Make a new Query object that is exactly like the old.static com.google.appengine.api.datastore.Key
Construct a Key from a Long or String idstatic <T> Key<T>
Construct a Key> from a Long or String idstatic <T> Key<T>
Construct a Key> from a Long or String idstatic List<com.google.appengine.api.datastore.Key>
createKeys(com.google.appengine.api.datastore.Key parent, String kind, Iterable<?> ids)
Make a list of keyscreateKeys(Key<?> parent, Class<T> kind, Iterable<?> ids)
Make a list of Key>sstatic <S> S
getId(com.google.appengine.api.datastore.Key key)
Gets the String or Long id from the key, or null if incompletestatic <S> S
Gets the String or Long id from the key, or null if incompletestatic com.google.appengine.api.datastore.Key
getKey(com.google.appengine.api.datastore.PropertyContainer container)
Unfortunately Entity and EmbeddedEntity do not share a common interface for getting key.static List<com.google.appengine.api.datastore.Key>
getRawKeys(Iterable<? extends Ref<?>> refs)
Turn a list of refs into a list of raw keys.static void
setContainerProperty(com.google.appengine.api.datastore.PropertyContainer entity, String propertyName, Object value, boolean index, SaveContext ctx, Path propPath)
Calls setProperty() or setUnindexedProperty() as determined by the index parameter.
-
Method Details
-
getRawKeys
public static List<com.google.appengine.api.datastore.Key> getRawKeys(Iterable<? extends Ref<?>> refs)Turn a list of refs into a list of raw keys. -
cloneQuery
public static com.google.appengine.api.datastore.Query cloneQuery(com.google.appengine.api.datastore.Query orig)Make a new Query object that is exactly like the old. Too bad Query isn't Cloneable. -
createKey
Construct a Key> from a Long or String id- Parameters:
id
- must be either Long or String
-
createKey
Construct a Key> from a Long or String id- Parameters:
id
- must be either Long or String
-
createKey
public static com.google.appengine.api.datastore.Key createKey(com.google.appengine.api.datastore.Key parent, String kind, Object id)Construct a Key from a Long or String id- Parameters:
id
- must be either Long or String
-
createKeys
public static List<com.google.appengine.api.datastore.Key> createKeys(com.google.appengine.api.datastore.Key parent, String kind, Iterable<?> ids)Make a list of keys- Parameters:
ids
- must contain either Long or String
-
createKeys
Make a list of Key>s- Parameters:
ids
- must contain either Long or String
-
getId
public static <S> S getId(com.google.appengine.api.datastore.Key key)Gets the String or Long id from the key, or null if incomplete -
getId
Gets the String or Long id from the key, or null if incomplete -
getKey
public static com.google.appengine.api.datastore.Key getKey(com.google.appengine.api.datastore.PropertyContainer container)Unfortunately Entity and EmbeddedEntity do not share a common interface for getting key. -
setContainerProperty
public static void setContainerProperty(com.google.appengine.api.datastore.PropertyContainer entity, String propertyName, Object value, boolean index, SaveContext ctx, Path propPath)Calls setProperty() or setUnindexedProperty() as determined by the index parameter. Also stuffs any values in the savecontext index.
-