com.google.appengine.api.datastore
Class KeyFactory.Builder
- java.lang.Object
-
- com.google.appengine.api.datastore.KeyFactory.Builder
-
- Enclosing class:
- KeyFactory
public static final class KeyFactory.Builder extends java.lang.ObjectHelper class that aids in the construction ofKeyswith ancestors. Initialize theBuilderwith the topmost ancestor in your key path and then add children using theaddChild(java.lang.String, java.lang.String)overload that best suits your needs. When finished adding children, callgetKey()to retrieve yourKeyorgetString()to retrieve yourKeyencoded as a websafeString.Examples:
import com.google.appengine.api.datastore.KeyFactory.Builder; ... Key key = new Builder("Person", 88).addChild("Address", 24).getKey(); String keyStr = new Builder("Photo Album", "Vacation").addChild("Photo", 1424).getString();
-
-
Constructor Summary
Constructors Constructor and Description Builder(Key key)Create aBuilder, establishing the providedKeyas the topmost ancestor.Builder(java.lang.String kind, long id)Create aBuilder, establishing aKeyconstructed from the provided kind and id as the topmost ancestor.Builder(java.lang.String kind, java.lang.String name)Create aBuilder, establishing aKeyconstructed from the provided kind and name as the topmost ancestor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description KeyFactory.BuilderaddChild(java.lang.String kind, long id)KeyFactory.BuilderaddChild(java.lang.String kind, java.lang.String name)KeygetKey()java.lang.StringgetString()
-
-
-
Constructor Detail
-
Builder
public Builder(java.lang.String kind, java.lang.String name)Create aBuilder, establishing aKeyconstructed from the provided kind and name as the topmost ancestor.- Parameters:
kind- the kind of the topmost ancestorname- the name of the topmost ancestor inkind, as an arbitrary string unique across root entities of thiskind
-
Builder
public Builder(java.lang.String kind, long id)Create aBuilder, establishing aKeyconstructed from the provided kind and id as the topmost ancestor.- Parameters:
kind- the kind of the topmost ancestorid- the numeric identifier of the topmost ancestor inkind, unique across root entities of this kind, must not be zero
-
-
Method Detail
-
addChild
public KeyFactory.Builder addChild(java.lang.String kind, java.lang.String name)
Add aKeyconstructed from the provided kind and name as the child of theKeymost recently added to theBuilder.- Parameters:
kind- the kind of the childname- the name of the child inkind, as an arbitrary string unique across entities of thiskindwith the same parent- Returns:
this
-
addChild
public KeyFactory.Builder addChild(java.lang.String kind, long id)
Add aKeyconstructed from the provided kind and id as the child of theKeymost recently added to theBuilder.- Parameters:
kind- the kind of the childid- the numeric identifier of the child inkind, unique across entities of this kind with the same parent, must not be zero- Returns:
this
-
getString
public java.lang.String getString()
- Returns:
- The most recently added
Key, encoded as a websafeString.
-
-