|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectcom.leanengine.LeanEntity
public class LeanEntity
LeanEntity is a basic data unit that can be stored on the server. It can be saved, retrieved, deleted and queried.
Entities can contain properties of various types: long, double, boolean, String and Date.
Future enhancements: new properties will be Entity reference, Blob, GeoPoint, Image..
Basic usage is to create a named entity via init(String) method and then use save() to store it
to server. Other methods are get(String), getAll(String) and delete().
All method have their asynchronous counterparts, designated by added 'InBackground' to method name, which allow
performing the method in the background thread.
| Field Summary | |
|---|---|
protected java.lang.Long |
accountID
|
protected java.lang.Long |
id
|
protected java.lang.String |
kind
|
protected java.util.Map<java.lang.String,java.lang.Object> |
properties
|
| Method Summary | |
|---|---|
void |
delete()
|
static void |
delete(java.lang.String kind,
long entityId)
Deletes an entity of the given kind an ID fro the server datastore.. |
java.lang.Object |
get(java.lang.String key)
Gets the property with the specified key. |
static LeanEntity |
get(java.lang.String kind,
long id)
Retrieves from server an entity of given kind and ID. |
java.lang.Long |
getAccountID()
Returns the user account ID that this entity belongs to. |
static LeanEntity[] |
getAll(java.lang.String kind)
Retrieves from server all entities of certain kind. |
static void |
getAllInBackground(java.lang.String kind,
NetworkCallback<LeanEntity> callback)
Retrieves from server all entities of certain kind. |
java.lang.Boolean |
getBoolean(java.lang.String key)
Gets the property with the specified key. |
java.util.Date |
getDate(java.lang.String key)
Gets the property with the specified key. |
java.lang.Double |
getDouble(java.lang.String key)
Gets the property with the specified key. |
java.lang.Long |
getId()
|
static void |
getInBackground(java.lang.String kind,
long id,
NetworkCallback<LeanEntity> callback)
Retrieves from server an entities of certain kind and ID. |
java.util.Set<java.lang.String> |
getKeySet()
Returns a Set of properties' keys . |
java.lang.String |
getKind()
|
java.lang.Long |
getLong(java.lang.String key)
Gets the property with the specified key. |
java.lang.String |
getString(java.lang.String key)
Gets the property with the specified key. |
java.lang.String |
getText(java.lang.String key)
Gets the property with the specified key. |
boolean |
hasProperty(java.lang.String key)
Checks if property with given key exists. |
static LeanEntity |
init(java.lang.String kind)
Static method to create an entity of given kind. |
boolean |
isEmpty()
Checks if entity contains any properties. |
void |
put(java.lang.String key,
boolean value)
Sets the property with given key to value. |
void |
put(java.lang.String key,
java.util.Date value)
Sets the property with given key to value. |
void |
put(java.lang.String key,
double value)
Sets the property with given key to value. |
void |
put(java.lang.String key,
long value)
Sets the property with given key to value. |
void |
put(java.lang.String key,
java.lang.String value)
Sets the property with given key to value. |
void |
putText(java.lang.String key,
java.lang.String value)
Sets the property with given key to value. |
long |
save()
Saves this entity to the server. |
void |
saveInBackground(NetworkCallback<java.lang.Long> callback)
Saves this entity to the server. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected final java.lang.String kind
protected java.lang.Long id
protected java.lang.Long accountID
protected java.util.Map<java.lang.String,java.lang.Object> properties
| Method Detail |
|---|
public static LeanEntity init(java.lang.String kind)
init() method do not have their id and accountID fields set,
even when they are saved to server.
kind - Tke kind of the entity.
public void saveInBackground(NetworkCallback<java.lang.Long> callback)
ID and accountID fields of this entity.
callback - NetworkCallback that on success returns ID of the saved Entity.
public long save()
throws LeanException
ID and accountID fields of this entity.
LeanException - In case of authentication, network and data parsing errors.
public static LeanEntity get(java.lang.String kind,
long id)
throws LeanException,
java.lang.IllegalArgumentException
kind - The kind of the Entity to be retrieved.id - ID of the Entity
id and of given kind.
java.lang.IllegalArgumentException - If parameter id or kind is null.
LeanException - If entity could not be found or in case of authentication, network and data
parsing errors.
public static void getInBackground(java.lang.String kind,
long id,
NetworkCallback<LeanEntity> callback)
kind - The kind of the Entity to be retrieved.id - ID of the Entitycallback - Callback to be invoked in case of result or error.
public static void getAllInBackground(java.lang.String kind,
NetworkCallback<LeanEntity> callback)
kind - The kind of the Entities to be retrieved.callback - Callback to be invoked in case of result or error.
public static LeanEntity[] getAll(java.lang.String kind)
throws LeanException
kind - The kind of the entities to be retrieved.
LeanException - In case of authentication, network and data parsing errors.
public static void delete(java.lang.String kind,
long entityId)
throws LeanException
kind - The kind of the entity to delete.entityId - The ID of the entity to delete.
LeanException - In case of authentication, network and data parsing errors.
public void delete()
throws LeanException
LeanExceptionpublic java.util.Set<java.lang.String> getKeySet()
Set of properties' keys .
Set of properties' keys.public java.lang.String getKind()
public java.lang.Long getId()
public java.lang.Long getAccountID()
Null if entity was not retrieved from server.public java.lang.Object get(java.lang.String key)
putXYZ(String, Object).
Object types are internally converted to types supported by LeanEngine server: //todo insert LE Docs link here
key - Key (name) of the property.
null if property with given key does not exist.public java.lang.String getString(java.lang.String key)
Null is returned if key does not exist or if property is not of type String.
put(String, String).
Object types are internally converted to types supported by LeanEngine server: //todo insert LE Docs link here
key - Key under which property was stored.
null if key does not exist or if property is not of type String.public java.lang.String getText(java.lang.String key)
Null is returned if key does not exist or if property is not of type String.
putText(String, String).
key - Key under which property was stored.
null if key does not exist or if property is not of type String.public java.lang.Long getLong(java.lang.String key)
Null is returned if key does not exist or if property is not of type Long.
put(String, long).
Object types are internally converted to types supported by LeanEngine server: //todo insert LE Docs link here
key - Key under which property was stored.
null if key does not exist or if property is not of type Long.public java.lang.Double getDouble(java.lang.String key)
Null is returned if key does not exist or if property is not of type Double.
put(String, double).
Object types are internally converted to types supported by LeanEngine server: //todo insert LE Docs link here
key - Key under which property was stored.
null if key does not exist or if property is not of type Double.public java.util.Date getDate(java.lang.String key)
Null is returned if key does not exist or if property is not of type Date.
put(String, java.util.Date).
Object types are internally converted to types supported by LeanEngine server: //todo insert LE Docs link here
key - Key under which property was stored.
null if key does not exist or if property is not of type Date.public java.lang.Boolean getBoolean(java.lang.String key)
Null is returned if key does not exist or if property is not of type Boolean.
put(String, boolean).
Vales are internally converted to types supported by LeanEngine server: //todo insert LE Docs link here
key - Key under which property was stored.
null if key does not exist or if property is not of type Boolean.
public void put(java.lang.String key,
long value)
key to value.
key - Key under which property will be stored.value - long value to be stored.
public void put(java.lang.String key,
double value)
key to value.
key - Key under which property will be stored.value - double value to be stored.
public void put(java.lang.String key,
java.lang.String value)
throws java.lang.IllegalArgumentException
key to value.
Value must be shorter that 500 Unicode characters. Use putText(String, String) if longer
string values need to be stored.
key - Key under which property will be stored.value - String value to be stored.
java.lang.IllegalArgumentException - If value is longer that 500 Unicode characters.
public void putText(java.lang.String key,
java.lang.String value)
key to value.
key - Key under which property will be stored.value - String value to be stored.
public void put(java.lang.String key,
java.util.Date value)
key to value.
key - Key under which property will be stored.value - Date value to be stored.
public void put(java.lang.String key,
boolean value)
key to value.
key - Key under which property will be stored.value - boolean value to be stored.public boolean hasProperty(java.lang.String key)
key exists.
key - Key of the property.
True if property exists, false otherwise.public boolean isEmpty()
True if entity is empty, i.e. contains no properties, false otherwise.
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||