public class LCObject extends Object
Modifier and Type | Class and Description |
---|---|
static class |
LCObject.Hook |
Modifier and Type | Field and Description |
---|---|
protected LCACL |
acl |
protected String |
className |
protected String |
endpointClassName |
static String |
KEY_ACL |
static String |
KEY_CLASSNAME |
static String |
KEY_CREATED_AT |
static String |
KEY_IGNORE_HOOKS |
static String |
KEY_OBJECT_ID |
static String |
KEY_UPDATED_AT |
protected static LCLogger |
logger |
protected String |
objectId |
protected ConcurrentMap<String,cn.leancloud.ops.ObjectFieldOperation> |
operations |
protected ConcurrentMap<String,Object> |
serverData |
protected boolean |
totallyOverwrite |
protected static int |
UUID_LEN |
Constructor and Description |
---|
LCObject()
Default constructor.
|
LCObject(LCObject other)
Copy constructor.
|
LCObject(String className)
Constructor with class name.
|
Modifier and Type | Method and Description |
---|---|
void |
abortOperations()
abort all modify operations.
|
void |
add(String key,
Object value)
Add attribute.
|
void |
addAll(String key,
Collection<?> values)
Add collection attribute.
|
void |
addAllUnique(String key,
Collection<?> values)
Add unique collection attribute.
|
protected void |
addNewOperation(cn.leancloud.ops.ObjectFieldOperation op) |
void |
addUnique(String key,
Object value)
Add unique attribute.
|
void |
bitAnd(String key,
long value)
Modify integer attribute.
|
void |
bitOr(String key,
long value)
Modify integer attribute.
|
void |
bitXor(String key,
long value)
Modify integer attribute.
|
protected static <T extends LCObject> |
cast(LCObject object,
Class<T> clazz) |
boolean |
containsKey(String key)
Contain specified key.
|
static <T extends LCObject> |
createWithoutData(Class<T> clazz,
String objectId)
Create a new instance with particular class and objectId.
|
static LCObject |
createWithoutData(String className,
String objectId)
Create a new instance with particular classname and objectId.
|
void |
decrement(String key)
Decrement one attribute.
|
void |
decrement(String key,
Number value)
Decrement one attribute.
|
void |
delete()
Delete current object in blocking mode.
|
void |
delete(LCUser asAuthenticatedUser)
Delete current object in blocking mode.
|
static void |
deleteAll(Collection<? extends LCObject> objects)
Delete all objects in blocking mode.
|
static void |
deleteAll(LCUser asAuthenticatedUser,
Collection<? extends LCObject> objects)
Delete all objects in blocking mode.
|
static io.reactivex.Observable<LCNull> |
deleteAllInBackground(Collection<? extends LCObject> objects)
Delete all objects in async mode.
|
static io.reactivex.Observable<LCNull> |
deleteAllInBackground(LCUser asAuthenticatedUser,
Collection<? extends LCObject> objects)
Delete all objects in async mode.
|
void |
deleteEventually()
Delete current object eventually.
|
void |
deleteEventually(LCUser asAuthenticatedUser)
Delete current object eventually.
|
io.reactivex.Observable<LCNull> |
deleteInBackground()
Delete current object in async mode.
|
io.reactivex.Observable<LCNull> |
deleteInBackground(LCUser asAuthenticatedUser)
Delete current object in async mode.
|
void |
disableAfterHook()
disable afterXXX Hooks
|
void |
disableBeforeHook()
disable beforeXXX Hooks
|
boolean |
equals(Object o) |
protected List<LCObject> |
extractCascadingObjects(Object o) |
protected List<LCFile> |
extractUnsavedFiles(Object o) |
LCObject |
fetch()
Fetch current object in blocking mode.
|
LCObject |
fetch(LCUser asAuthenticatedUser,
String includeKeys)
Fetch current object in blocking mode.
|
LCObject |
fetch(String includeKeys)
Fetch current object in blocking mode.
|
LCObject |
fetchIfNeeded()
Fetch current object in blocking mode.
|
io.reactivex.Observable<LCObject> |
fetchIfNeededInBackground()
Fetch current object if needed in async mode.
|
io.reactivex.Observable<LCObject> |
fetchIfNeededInBackground(LCUser asAuthenticatedUser,
String includeKeys)
Fetch current object if needed in async mode.
|
io.reactivex.Observable<LCObject> |
fetchIfNeededInBackground(String includeKeys)
Fetch current object if needed in async mode.
|
io.reactivex.Observable<LCObject> |
fetchInBackground()
Fetch current object in async mode.
|
io.reactivex.Observable<LCObject> |
fetchInBackground(LCUser asAuthenticatedUser,
String includeKeys)
Fetch current object in async mode.
|
io.reactivex.Observable<LCObject> |
fetchInBackground(String includeKeys)
Fetch current object in async mode.
|
protected LCACL |
generateACLFromServerData() |
protected io.reactivex.Observable<List<LCObject>> |
generateCascadingSaveObjects() |
protected JSONObject |
generateChangedParam()
save/update with server.
|
Object |
get(String key)
Get value of specified key.
|
LCACL |
getACL()
get ACL
|
boolean |
getBoolean(String key)
Get boolean value of specified key.
|
byte[] |
getBytes(String key)
Get bytes value of specified key.
|
String |
getClassName()
Get class name.
|
Date |
getCreatedAt()
Get createdAt date.
|
String |
getCreatedAtString()
Get createdAt string.
|
Date |
getDate(String key)
Get Date value of specified key.
|
double |
getDouble(String key)
Get double value of specified key.
|
int |
getInt(String key)
Get int value of specified key.
|
JSONArray |
getJSONArray(String key)
Get jsonarray value of specified key.
|
JSONObject |
getJSONObject(String key)
Get jsonobject value of specified key.
|
LCFile |
getLCFile(String key)
Get AVFile value of specified key.
|
LCGeoPoint |
getLCGeoPoint(String key)
Get AVGeoPoint value of specified key.
|
<T extends LCObject> |
getLCObject(String key)
Get AVObject value of specified key.
|
List |
getList(String key)
Get list value of specified key.
|
long |
getLong(String key)
Get long value of specified key.
|
Number |
getNumber(String key)
Get numeric value of specified key.
|
String |
getObjectId()
Get objectId.
|
static <T extends LCObject> |
getQuery(Class<T> clazz)
Get query for class.
|
<T extends LCObject> |
getRelation(String key)
Get AVRelation value of specified key.
|
String |
getRequestMethod()
Get request method.
|
String |
getRequestRawEndpoint()
Get request endpoint.
|
ConcurrentMap<String,Object> |
getServerData()
Get server data.
|
String |
getString(String key)
Get string value of specified key.
|
protected List<LCFile> |
getUnsavedFiles() |
Date |
getUpdatedAt()
Get updatedAt date.
|
String |
getUpdatedAtString()
Get updatedAt string.
|
String |
getUuid()
Get UUID.
|
boolean |
has(String key)
Contain specified key.
|
boolean |
hasCircleReference(Map<LCObject,Boolean> markMap)
judge operations' value include circle reference or not.
|
int |
hashCode() |
void |
ignoreHook(LCObject.Hook hook)
ignore specified Hook
|
void |
increment(String key)
Increment one attribute.
|
void |
increment(String key,
Number value)
Increment one attribute.
|
String |
internalClassName()
Get internal class name.
|
protected Object |
internalGet(String key) |
protected String |
internalId() |
protected void |
internalPut(String key,
Object value) |
boolean |
isDataAvailable()
Flag to indicate data is available or not.
|
boolean |
isFetchWhenSave()
Flag to fetchWhenSave.
|
protected void |
onDataSynchronized() |
protected void |
onSaveFailure() |
protected void |
onSaveSuccess() |
static LCObject |
parseLCObject(String objectString)
Create AVObject instance from json string which generated by AVObject.toString or AVObject.toJSONString.
|
void |
put(String key,
Object value)
Set attribute.
|
void |
refresh()
Refresh current object in blocking mode.
|
void |
refresh(LCUser asAuthenticatedUser,
String includeKeys)
Refresh current object in blocking mode.
|
void |
refresh(String includeKeys)
Refresh current object in blocking mode.
|
io.reactivex.Observable<LCObject> |
refreshInBackground()
Refresh current object in async mode.
|
io.reactivex.Observable<LCObject> |
refreshInBackground(LCUser asAuthenticatedUser)
Refresh current object in async mode.
|
io.reactivex.Observable<LCObject> |
refreshInBackground(LCUser asAuthenticatedUser,
String includeKeys)
Refresh current object in async mode.
|
io.reactivex.Observable<LCObject> |
refreshInBackground(String includeKeys)
Refresh current object in async mode.
|
static <T extends LCObject> |
registerSubclass(Class<T> clazz)
Register subclass to AVOSCloud SDK.It must be invocated before AVOSCloud.initialize.
|
void |
remove(String key)
Remove attribute.
|
void |
removeAll(String key,
Collection<?> values)
Remove all collection.
|
protected void |
removeOperationForKey(String key) |
protected void |
resetAll() |
protected void |
resetByRawData(LCObject LCObject) |
void |
resetServerData(Map<String,Object> data)
Reset server data with new data.
|
void |
save()
Save in blocking mode.
|
void |
save(LCUser asAuthenticatedUser)
Save in blocking mode.
|
static void |
saveAll(Collection<? extends LCObject> objects)
Save All objects in blocking mode.
|
static void |
saveAll(LCUser asAuthenticatedUser,
Collection<? extends LCObject> objects)
Save All objects in blocking mode.
|
static io.reactivex.Observable<JSONArray> |
saveAllInBackground(Collection<? extends LCObject> objects)
Save all objects in async mode.
|
static io.reactivex.Observable<JSONArray> |
saveAllInBackground(LCUser asAuthenticatedUser,
Collection<? extends LCObject> objects)
Save all objects in async mode.
|
void |
saveEventually()
Save eventually.
|
void |
saveEventually(LCUser asAuthenticatedUser)
Save eventually.
|
io.reactivex.Observable<? extends LCObject> |
saveInBackground()
Save object in background.
|
io.reactivex.Observable<? extends LCObject> |
saveInBackground(LCSaveOption option)
Save object in background.
|
io.reactivex.Observable<? extends LCObject> |
saveInBackground(LCUser asAuthenticatedUser)
Save object in background.
|
io.reactivex.Observable<? extends LCObject> |
saveInBackground(LCUser asAuthenticatedUser,
LCSaveOption option)
Save object in background.
|
void |
setACL(LCACL acl)
Set ACL
|
void |
setClassName(String name)
Set class name.
|
void |
setFetchWhenSave(boolean fetchWhenSave)
Set fetchWhenSave flag.
|
void |
setObjectId(String objectId)
Set objectId.
|
JSONObject |
toJSONObject()
Generate a new json object with server data.
|
String |
toJSONString()
Generate a json string.
|
String |
toString() |
protected void |
validFieldName(String key) |
protected static boolean |
verifyInternalId(String internalId) |
public static final String KEY_CREATED_AT
public static final String KEY_UPDATED_AT
public static final String KEY_OBJECT_ID
public static final String KEY_ACL
public static final String KEY_CLASSNAME
public static final String KEY_IGNORE_HOOKS
protected static final LCLogger logger
protected static final int UUID_LEN
protected String className
protected transient String endpointClassName
protected transient String objectId
protected ConcurrentMap<String,Object> serverData
protected transient ConcurrentMap<String,cn.leancloud.ops.ObjectFieldOperation> operations
protected transient LCACL acl
protected volatile boolean totallyOverwrite
public LCObject()
public LCObject(String className)
className
- class name.public LCObject(LCObject other)
other
- other instance.public String getClassName()
public String internalClassName()
public void setClassName(String name)
name
- class name.public Date getCreatedAt()
public String getCreatedAtString()
public Date getUpdatedAt()
public String getUpdatedAtString()
public String getObjectId()
public void setObjectId(String objectId)
objectId
- object id.public boolean isFetchWhenSave()
public void setFetchWhenSave(boolean fetchWhenSave)
fetchWhenSave
- flag.public String getUuid()
protected static boolean verifyInternalId(String internalId)
protected String internalId()
public boolean containsKey(String key)
key
- keypublic boolean has(String key)
key
- keypublic Object get(String key)
key
- specified key.public boolean getBoolean(String key)
key
- specified key.public byte[] getBytes(String key)
key
- specified key.public Date getDate(String key)
key
- specified key.public String getString(String key)
key
- specified key.public int getInt(String key)
key
- specified key.public long getLong(String key)
key
- specified key.public double getDouble(String key)
key
- specified key.public Number getNumber(String key)
key
- specified key.public List getList(String key)
key
- specified key.public JSONArray getJSONArray(String key)
key
- specified key.public JSONObject getJSONObject(String key)
key
- specified key.public LCGeoPoint getLCGeoPoint(String key)
key
- specified key.public LCFile getLCFile(String key)
key
- specified key.public <T extends LCObject> T getLCObject(String key)
T
- template typekey
- specified key.public <T extends LCObject> LCRelation<T> getRelation(String key)
T
- template typekey
- specified key.public ConcurrentMap<String,Object> getServerData()
protected void validFieldName(String key)
public boolean isDataAvailable()
public void add(String key, Object value)
key
- target key.value
- value object.public void addAll(String key, Collection<?> values)
key
- target key.values
- values collection.public void addUnique(String key, Object value)
key
- target key.value
- value object.public void addAllUnique(String key, Collection<?> values)
key
- target key.values
- value collection.public void put(String key, Object value)
key
- target key.value
- value object.public void remove(String key)
key
- target key.public void removeAll(String key, Collection<?> values)
key
- target keys.values
- value collection.public void increment(String key)
key
- target key.public void increment(String key, Number value)
key
- target key.value
- value object.public void decrement(String key)
key
- target key.public void decrement(String key, Number value)
key
- target key.value
- value object.public void bitAnd(String key, long value)
key
- target key.value
- value object.public void bitOr(String key, long value)
key
- target key.value
- value object.public void bitXor(String key, long value)
key
- target key.value
- value object.public void abortOperations()
protected void removeOperationForKey(String key)
protected void addNewOperation(cn.leancloud.ops.ObjectFieldOperation op)
protected JSONObject generateChangedParam()
protected io.reactivex.Observable<List<LCObject>> generateCascadingSaveObjects()
protected void onSaveSuccess()
protected void onSaveFailure()
protected void onDataSynchronized()
public io.reactivex.Observable<? extends LCObject> saveInBackground()
public io.reactivex.Observable<? extends LCObject> saveInBackground(LCUser asAuthenticatedUser)
asAuthenticatedUser
- explicit user for request authentication.public io.reactivex.Observable<? extends LCObject> saveInBackground(LCSaveOption option)
option
- save option.public io.reactivex.Observable<? extends LCObject> saveInBackground(LCUser asAuthenticatedUser, LCSaveOption option)
asAuthenticatedUser
- explicit user for request authentication.option
- save option.public boolean hasCircleReference(Map<LCObject,Boolean> markMap)
markMap
- markup map.public void save()
public void save(LCUser asAuthenticatedUser)
asAuthenticatedUser
- explicit user for request authentication.
in general, this method should be invoked in lean engine.public static void saveAll(Collection<? extends LCObject> objects) throws LCException
objects
- object collection.LCException
- error happened.public static void saveAll(LCUser asAuthenticatedUser, Collection<? extends LCObject> objects) throws LCException
asAuthenticatedUser
- explicit user for request authentication.objects
- object collection.LCException
- error happened.
in general, this method should be invoked in lean engine.public static io.reactivex.Observable<JSONArray> saveAllInBackground(Collection<? extends LCObject> objects)
objects
- object collection.public static io.reactivex.Observable<JSONArray> saveAllInBackground(LCUser asAuthenticatedUser, Collection<? extends LCObject> objects)
asAuthenticatedUser
- explicit user for request authentication.objects
- object collection.public void saveEventually() throws LCException
LCException
- error happened.public void saveEventually(LCUser asAuthenticatedUser) throws LCException
asAuthenticatedUser
- explicit user for request authentication.LCException
- error happened.
in general, this method should be invoked in lean engine.public void deleteEventually()
public void deleteEventually(LCUser asAuthenticatedUser)
asAuthenticatedUser
- explicit user for request authentication.
in general, this method should be invoked in lean engine.public io.reactivex.Observable<LCNull> deleteInBackground()
public io.reactivex.Observable<LCNull> deleteInBackground(LCUser asAuthenticatedUser)
asAuthenticatedUser
- explicit user for request authentication.public void delete()
public void delete(LCUser asAuthenticatedUser)
asAuthenticatedUser
- explicit user for request authentication.
in general, this method should be invoked in lean engine.public static void deleteAll(Collection<? extends LCObject> objects) throws LCException
objects
- object collection.LCException
- error happened.public static void deleteAll(LCUser asAuthenticatedUser, Collection<? extends LCObject> objects) throws LCException
asAuthenticatedUser
- explicit user for request authentication.objects
- object collection.LCException
- error happened.
in general, this method should be invoked in lean engine.public static io.reactivex.Observable<LCNull> deleteAllInBackground(Collection<? extends LCObject> objects)
objects
- object collection.public static io.reactivex.Observable<LCNull> deleteAllInBackground(LCUser asAuthenticatedUser, Collection<? extends LCObject> objects)
asAuthenticatedUser
- explicit user for request authentication.objects
- object collection.public void refresh()
public void refresh(String includeKeys)
includeKeys
- include keys, which object will be return together.public void refresh(LCUser asAuthenticatedUser, String includeKeys)
asAuthenticatedUser
- explicit user for request authentication.includeKeys
- include keys, which object will be return together.
in general, this method should be invoked in lean engine.public io.reactivex.Observable<LCObject> refreshInBackground()
public io.reactivex.Observable<LCObject> refreshInBackground(LCUser asAuthenticatedUser)
asAuthenticatedUser
- explicit user for request authentication.public io.reactivex.Observable<LCObject> refreshInBackground(String includeKeys)
includeKeys
- include keys, which object will be return together.public io.reactivex.Observable<LCObject> refreshInBackground(LCUser asAuthenticatedUser, String includeKeys)
asAuthenticatedUser
- explicit user for request authentication.includeKeys
- include keys, which object will be return together.public LCObject fetch()
public LCObject fetch(String includeKeys)
includeKeys
- include keys, which object will be return together.public LCObject fetch(LCUser asAuthenticatedUser, String includeKeys)
asAuthenticatedUser
- explicit user for request authentication.includeKeys
- include keys, which object will be return together.public io.reactivex.Observable<LCObject> fetchInBackground()
public io.reactivex.Observable<LCObject> fetchInBackground(String includeKeys)
includeKeys
- include keys, which object will be return together.public io.reactivex.Observable<LCObject> fetchInBackground(LCUser asAuthenticatedUser, String includeKeys)
asAuthenticatedUser
- explicit user for request authentication.includeKeys
- include keys, which object will be return together.public io.reactivex.Observable<LCObject> fetchIfNeededInBackground()
public io.reactivex.Observable<LCObject> fetchIfNeededInBackground(String includeKeys)
includeKeys
- include keys, which object will be return together.public io.reactivex.Observable<LCObject> fetchIfNeededInBackground(LCUser asAuthenticatedUser, String includeKeys)
asAuthenticatedUser
- explicit user for request authentication.includeKeys
- include keys, which object will be return together.public LCObject fetchIfNeeded()
protected void resetAll()
protected void resetByRawData(LCObject LCObject)
public void resetServerData(Map<String,Object> data)
data
- new data.public String getRequestRawEndpoint()
public String getRequestMethod()
public static <T extends LCObject> void registerSubclass(Class<T> clazz)
T
- template type.clazz
- The subclass.public LCACL getACL()
public void setACL(LCACL acl)
acl
- acl object.protected LCACL generateACLFromServerData()
public static <T extends LCObject> LCQuery<T> getQuery(Class<T> clazz)
T
- result type.clazz
- target class.public JSONObject toJSONObject()
public String toJSONString()
public static LCObject parseLCObject(String objectString)
objectString
- json string.public static LCObject createWithoutData(String className, String objectId)
className
- class nameobjectId
- object idpublic static <T extends LCObject> T createWithoutData(Class<T> clazz, String objectId) throws LCException
T
- template type.clazz
- class infoobjectId
- object idLCException
- error happened.public void disableBeforeHook()
public void disableAfterHook()
public void ignoreHook(LCObject.Hook hook)
hook
- target Hook.protected static <T extends LCObject> T cast(LCObject object, Class<T> clazz) throws Exception
Exception
Copyright © 2020, 美味书签(北京)信息技术有限公司 All rights reserved.