KeyFactory (Google App Engine API for Java)

com.google.appengine.api.datastore

Class KeyFactory

  • java.lang.Object
    • com.google.appengine.api.datastore.KeyFactory


  • public class KeyFactory
    extends java.lang.Object
    This class enables direct creation of Key objects, both in the root entity group (no parent) and as the child of a given parent. Keys can also be created indirectly by putting named Entities into the datastore, which will allocate a new key. See Entity.Entity(String, String) for details.

    This class also has methods for encoding and decoding Key objects to and from strings. Clients should not make any assumptions about the encoding format, except that it is a websafe string that does not need to be quoted when used in HTML or in URLs.

    See Also:
    Entity
    • Method Detail

      • createKey

        public static Key createKey(java.lang.String kind,
                                    long id)
        Creates a new Key having no parent from its kind and ID.
        Parameters:
        kind - the kind of the key to create
        id - the numeric identifier of the key in kind, unique across all root entities of this kind, must not be zero
      • createKey

        public static Key createKey(Key parent,
                                    java.lang.String kind,
                                    long id)
        Creates a new Key with the provided parent from its kind and ID.
        Parameters:
        parent - the parent of the key to create, can be null
        kind - the kind of the key to create
        id - the numeric identifier of the key in kind, unique across all entities of this kind with the same parent, must not be zero
      • createKey

        public static Key createKey(java.lang.String kind,
                                    java.lang.String name)
        Creates a new Key having no parent from its kind and name.
        Parameters:
        kind - the kind of the key to create
        name - the name of the key in kind, as an arbitrary string unique across all root entities of this kind
      • createKey

        public static Key createKey(Key parent,
                                    java.lang.String kind,
                                    java.lang.String name)
        Creates a new Key with the provided parent from its kind and name.
        Parameters:
        parent - the parent of the key to create, can be null