Package com.kii.cloud.storage
Class KiiObject
- java.lang.Object
-
- com.kii.cloud.storage.KiiBaseObject
-
- com.kii.cloud.storage.KiiObject
-
- All Implemented Interfaces:
android.os.Parcelable,FileHolder
public final class KiiObject extends KiiBaseObject implements FileHolder, android.os.Parcelable
Provide arbitrary key-value Object CRUD operation on KiiCloud. KiiObject has following reserve keys which can not be used as the key of setter methods
Reserve keys
- _kiireserved_uri
-
-
Field Summary
Fields Modifier and Type Field Description static android.os.Parcelable.Creator<KiiObject>CREATORGenerates instances of Parcelable class from a Parcel.-
Fields inherited from class com.kii.cloud.storage.KiiBaseObject
mJSON, mJSONPatch
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description KiiACLacl()Get the ACL handle of this KiiObject.static KiiObjectcreateByUri(android.net.Uri uri)Instantiate KiiObject from the Uri.
After instantiate, callrefresh()to fetch properties.voiddelete()Delete KiiObject from KiiCloud.intdelete(KiiObjectCallBack callBack)Asynchronous call fordelete().voiddeleteBody()Delete the body of the KiiObject from KiiCloud.intdeleteBody(KiiObjectCallBack callBack)Asynchronous call fordeleteBody().intdescribeContents()voiddownloadBody(java.io.File destFile)Download the body of the KiiObject from KiiCloud.voiddownloadBody(java.io.File destFile, KiiObjectBodyCallback callback)Asynchronous call fordownloadBody(File).KiiDownloaderdownloader(android.content.Context context, java.io.File dest)InstantiateKiiDownloader.java.lang.StringgetBodyContentType()The content type of object body.longgetCreatedTime()Get the created time on ServerGeoPointgetGeoPoint(java.lang.String key)Get the GeoPoint of this object tied to the specified key.GeoPointgetGeoPoint(java.lang.String key, GeoPoint fallback)Get the GeoPoint of this object tied to the specified key.longgetModifedTime()Get the modified time on Serverstatic booleanisValidObjectID(java.lang.String objectID)Check if given ID is valid for object ID.java.lang.StringpublishBody()Publish the KiiObject attached file and return the file URL.voidpublishBody(KiiObjectPublishCallback callback)Asynchronous call forpublishBody().java.lang.StringpublishBodyExpiresAt(long expiresAt)Publish the KiiObject attached file and return the file URL.voidpublishBodyExpiresAt(long expiresAt, KiiObjectPublishCallback callback)Asynchronous call forpublishBodyExpiresAt(long).java.lang.StringpublishBodyExpiresIn(int expiresIn)Publish the KiiObject attached file and return the file URL.voidpublishBodyExpiresIn(int expiresIn, KiiObjectPublishCallback callback)Asynchronous call forpublishBodyExpiresIn(int).voidrefresh()Get latest KiiObject form KiiCloud and refresh properties.
Any update has not saved will be overwritten.intrefresh(KiiObjectCallBack callBack)Asynchronous call forrefresh().
Background task will be initiated to execute the task.voidsave()Create or update the KiiObject on KiiCloud.voidsave(boolean overWrite)Create or update the KiiObject on KiiCloud.intsave(KiiObjectCallBack callBack)Asynchronous call forsave().intsave(KiiObjectCallBack callback, boolean overWrite)Asynchronous call forsave(boolean).
Background task will be initiated to execute the task.voidsaveAllFields(boolean overWrite)Create or update the KiiObject on KiiCloud.intsaveAllFields(KiiObjectCallBack callback, boolean overWrite)Asynchronous call forsaveAllFields(boolean).voidset(java.lang.String key, GeoPoint value)Set GeoPoint to this object with the specified key.voidset(java.lang.String key, java.lang.String value)Create/Update the key/value string of the KiiObject.voidset(java.lang.String key, org.json.JSONObject value)Create/Update the key/value.org.json.JSONObjecttoJSON()Returns JSON representation of this KiiObject.java.lang.StringtoString()Returns String representation of JSONObject get fromtoJSON()android.net.UritoUri()Retruns URI of this KiiObject.voiduploadBody(java.io.File sourceFile, java.lang.String contentType)Upload the body of the KiiObject to KiiCloud.voiduploadBody(java.io.File sourceFile, java.lang.String contentType, KiiObjectBodyCallback callback)Asynchronous call foruploadBody(File, String).KiiUploaderuploader(android.content.Context context, java.io.File source)InstantiateKiiUploaderwith local file.voidwriteToParcel(android.os.Parcel dest, int flags)-
Methods inherited from class com.kii.cloud.storage.KiiBaseObject
getBoolean, getBoolean, getByteArray, getDouble, getDouble, getInt, getInt, getJsonArray, getJSONArray, getJSONObject, getJSONOfArbitraryFields, getLong, getLong, getObject, getObject, getString, getString, getUri, has, keySet, remove, removeReserveProperty, set, set, set, set, set, set, set
-
-
-
-
Field Detail
-
CREATOR
public static final android.os.Parcelable.Creator<KiiObject> CREATOR
Generates instances of Parcelable class from a Parcel.
-
-
Method Detail
-
createByUri
@NonNull public static KiiObject createByUri(@NonNull android.net.Uri uri)
Instantiate KiiObject from the Uri.
After instantiate, callrefresh()to fetch properties.- Parameters:
uri- Uri of the KiiObject to instantiate.- Returns:
- instance of KiiObject.
- Throws:
java.lang.IllegalArgumentException- when passed uri is empty or null or invalid
-
save
@WorkerThread public void save() throws java.io.IOException, BadRequestException, ConflictException, ForbiddenException, NotFoundException, UnauthorizedException, UndefinedExceptionCreate or update the KiiObject on KiiCloud. This call is same as {@link KiiObject#save(true)}
NOTE: This api access to server. Should not be executed in UI/Main thread.
NOTE: This API can not create new KiiObject on cloud when instantiated byKiiBucket.object(String), but can only update. If you want to create new KiiObject with it, please usesaveAllFields(boolean)orsaveAllFields(KiiObjectCallBack, boolean)instead.- Throws:
java.io.IOException- When network related error has happened.UndefinedExceptionNotFoundExceptionForbiddenExceptionConflictExceptionBadRequestExceptionUnauthorizedExceptionjava.lang.IllegalStateException- When KiiClient is not initialized.- See Also:
save(boolean),save(KiiObjectCallBack)
-
save
@WorkerThread public void save(boolean overWrite) throws java.io.IOException, BadRequestException, ConflictException, ForbiddenException, NotFoundException, UnauthorizedException, UndefinedExceptionCreate or update the KiiObject on KiiCloud. When call this method for the object that has not saved on cloud, will send all fields. Call this method for the object that has saved on cloud, Update only updated fields. Do not send fields that has not updated locally. To send all fields regardless of updates, callsaveAllFields(boolean).
NOTE: This api access to server. Should not be executed in UI/Main thread.
NOTE: This API can not create new KiiObject on cloud when instantiated byKiiBucket.object(String), but can only update. If you want to create new KiiObject with it, please usesaveAllFields(boolean)orsaveAllFields(KiiObjectCallBack, boolean)instead.- Parameters:
overWrite- If false, it will fail to update when there are updates on server object.
If true, it will success regardless of updates on server object.
Note:
From SDK version 2.1.19, saving KiiObject without refreshing is enabled (SDK does not throw IllegalStateException).- If overwrite is true:
- A KiiObject is created/updated successfully. Whole KiiObject with the same ID will be updated with new data.
- Otherwise:
- If a KiiObject with the same ID exists in cloud, SDK throws ConflictException.
- If a KiiObject with the same ID does not exist in cloud, new KiiObject will be created.
- If overwrite is true:
- Throws:
java.io.IOException- When network related error has happenedUndefinedExceptionNotFoundExceptionForbiddenExceptionConflictExceptionBadRequestExceptionUnauthorizedExceptionjava.lang.IllegalStateException- When KiiClient is not initialized.- See Also:
save(KiiObjectCallBack, boolean),saveAllFields(boolean)
-
saveAllFields
@WorkerThread public void saveAllFields(boolean overWrite) throws java.io.IOException, BadRequestException, ConflictException, ForbiddenException, NotFoundException, UnauthorizedException, UndefinedExceptionCreate or update the KiiObject on KiiCloud. When call this method for the object that has not saved on cloud, will send all fields. Call this method for the object that has saved on cloud, Update all field of this object.
NOTE: This api access to server. Should not be executed in UI/Main thread.- Parameters:
overWrite- If false, it will fail to update when there are updates on server object.
if true, it will success regardless of updates on server object.
Note:
From SDK version 2.1.19, saving KiiObject without refreshing is enabled (SDK does not throw IllegalStateException).- If overwrite is true:
- A KiiObject is created/updated successfully. Whole KiiObject with the same ID will be updated with new data.
- Otherwise:
- If a KiiObject with the same ID exists in cloud, SDK throws ConflictException.
- If a KiiObject with the same ID does not exist in cloud, new KiiObject will be created.
- If overwrite is true:
- Throws:
java.io.IOException- When network related error has happenedUndefinedExceptionNotFoundExceptionForbiddenExceptionConflictExceptionBadRequestExceptionUnauthorizedExceptionjava.lang.IllegalStateException- When KiiClient is not initialized.- See Also:
save(boolean),saveAllFields(KiiObjectCallBack, boolean)
-
save
public int save(@Nullable KiiObjectCallBack callback, boolean overWrite)Asynchronous call forsave(boolean).
Background task will be initiated to execute the task.
NOTE: This API can not create new KiiObject on cloud when instantiated byKiiBucket.object(String), but can only update. If you want to create new KiiObject with it, please usesaveAllFields(boolean)orsaveAllFields(KiiObjectCallBack, boolean)instead.- Parameters:
callBack- notifies events.- Returns:
- id used for cancel this operation. see also
Kii.cancelTask(int)
-
saveAllFields
public int saveAllFields(@Nullable KiiObjectCallBack callback, boolean overWrite)Asynchronous call forsaveAllFields(boolean). Background task will be initiated to execute the task.- Parameters:
callBack- notifies events.- Returns:
- id used for cancel this operation. see also
Kii.cancelTask(int)
-
delete
@WorkerThread public void delete() throws java.io.IOException, BadRequestException, UnauthorizedException, ForbiddenException, ConflictException, NotFoundException, UndefinedExceptionDelete KiiObject from KiiCloud.
NOTE: This api access to server. Should not be executed in UI/Main thread.- Throws:
java.io.IOException- When network related error has happened.UndefinedExceptionNotFoundExceptionConflictExceptionForbiddenExceptionBadRequestExceptionUnauthorizedExceptionjava.lang.IllegalStateException- Thrown If SDK is not initialized or KiiObject is not exists in the cloud.- See Also:
delete(KiiObjectCallBack)
-
publishBody
@WorkerThread @NonNull public java.lang.String publishBody() throws java.io.IOException, BadRequestException, UnauthorizedException, ForbiddenException, ConflictException, NotFoundException, UndefinedExceptionPublish the KiiObject attached file and return the file URL. URL will not be expired.
NOTE: This API access to server. Should not be executed in UI/Main thread.- Returns:
- the URL for the KiiObject attached file.
- Throws:
java.io.IOException- When network related error has happened.UndefinedExceptionNotFoundExceptionConflictExceptionForbiddenException- Thrown if the KiiObject is not existed in the cloud.BadRequestExceptionUnauthorizedExceptionjava.lang.IllegalStateException- Thrown if
- SDK is not initialized.
- KiiObject does not have objectID.- See Also:
publishBody(KiiObjectPublishCallback)
-
publishBodyExpiresAt
@WorkerThread @NonNull public java.lang.String publishBodyExpiresAt(long expiresAt) throws java.io.IOException, BadRequestException, UnauthorizedException, ForbiddenException, ConflictException, NotFoundException, UndefinedExceptionPublish the KiiObject attached file and return the file URL. URL will be expired on the specified expire time.
NOTE: This API access to server. Should not be executed in UI/Main thread.- Parameters:
expiresAt- A time of expired date in milliseconds (Since January 1, 1970 00:00:00 UTC).- Returns:
- the URL for the KiiObject attached file.
- Throws:
java.io.IOException- When network related error has happenedUndefinedExceptionNotFoundException- Thrown if the KiiObject is not existed in the cloud.ConflictExceptionForbiddenExceptionBadRequestException- Thrown if expiresAt is past time.UnauthorizedExceptionjava.lang.IllegalStateException- Thrown if
- SDK is not initialized.
- KiiObject does not have objectID.- See Also:
publishBodyExpiresAt(long, KiiObjectPublishCallback)
-
publishBodyExpiresIn
@WorkerThread @NonNull public java.lang.String publishBodyExpiresIn(int expiresIn) throws java.io.IOException, BadRequestException, UnauthorizedException, ForbiddenException, ConflictException, NotFoundException, UndefinedExceptionPublish the KiiObject attached file and return the file URL. URL will be expired on the specified expire time.
NOTE: This API access to server. Should not be executed in UI/Main thread.- Parameters:
expiresIn- The period time in seconds the publication URL has to be available, after that it will expire.- Returns:
- the URL for the KiiObject attached file.
- Throws:
java.io.IOException- When network related error has happenedUndefinedExceptionNotFoundException- Thrown if the KiiObject is not existed in the cloud.ConflictExceptionForbiddenExceptionBadRequestExceptionUnauthorizedExceptionjava.lang.IllegalArgumentException- Thrown if expiresIn is negative or 0.java.lang.IllegalStateException- Thrown if
- SDK is not initialized.
- KiiObject does not have objectID.- See Also:
publishBodyExpiresIn(int, KiiObjectPublishCallback)
-
uploadBody
@WorkerThread public void uploadBody(@NonNull java.io.File sourceFile, @Nullable java.lang.String contentType) throws java.io.IOException, BadRequestException, UnauthorizedException, ForbiddenException, ConflictException, NotFoundException, UndefinedExceptionUpload the body of the KiiObject to KiiCloud.
This API is suitable for uploading small size file to cloud. If you want to upload big size file, please consider to use ResumableTransfer interface (KiiUploader) instead.
NOTE: This API access to server. Should not be executed in UI/Main thread.
NOTE: If target KiiObject is not created, please callsave()orsaveAllFields(boolean)before uploading.
NOTE: After this operation, KiiObject version will be updated. If you want to usesave(boolean)with overwrite=false argument, please dorefresh()before saving.- Parameters:
sourceFile- File to upload or update. When the attached file is existed in cloud, it will be replaced with this file.contentType- Content type of the object body. If null is passed, content type is determined from file extension by using android.webkit.MimeTypeMap.- Throws:
java.io.IOException- When network related error has happened.UndefinedExceptionNotFoundException- Thrown if the KiiObject is not existed in the cloud.ConflictExceptionForbiddenExceptionBadRequestExceptionUnauthorizedExceptionjava.lang.IllegalArgumentException- Thrown if
- sourceFile is null.
- sourceFile doesn't exist in the device.
- sourceFile is not a file, but a directory.java.lang.IllegalStateException- Thrown if
- SDK is not initialized.
- KiiObject does not have objectID.- See Also:
uploadBody(File, String, KiiObjectBodyCallback)
-
downloadBody
@WorkerThread public void downloadBody(@NonNull java.io.File destFile) throws java.io.IOException, BadRequestException, UnauthorizedException, ForbiddenException, ConflictException, NotFoundException, UndefinedExceptionDownload the body of the KiiObject from KiiCloud.
This API is suitable for downloading small size file to cloud. If you want to download big size file, please consider to use ResumableTransfer interface (KiiDownloader) instead.
NOTE: This API access to server. Should not be executed in UI/Main thread.- Parameters:
destFile- Destination file to download. If file destination is existed, file is overwritten with downloaded file.- Throws:
java.io.IOException- When network related error has happened.UndefinedExceptionNotFoundException- Thrown if the KiiObject is not existed in the cloud.ConflictExceptionForbiddenExceptionBadRequestExceptionUnauthorizedExceptionjava.lang.IllegalArgumentException- Thrown if
- destFile is null.
- destFile is not a file, but a directory.java.lang.IllegalStateException- Thrown if
- SDK is not initialized.
- KiiObject does not have objectID.- See Also:
downloadBody(File, KiiObjectBodyCallback)
-
deleteBody
@WorkerThread public void deleteBody() throws java.io.IOException, BadRequestException, UnauthorizedException, ForbiddenException, ConflictException, NotFoundException, UndefinedExceptionDelete the body of the KiiObject from KiiCloud.
NOTE: This api access to server. Should not be executed in UI/Main thread.- Throws:
java.io.IOException- When network related error has happened.UndefinedExceptionNotFoundExceptionConflictExceptionForbiddenExceptionBadRequestExceptionUnauthorizedExceptionjava.lang.IllegalStateException- Thrown If SDK is not initialized or KiiObject is not exists in the cloud.- See Also:
deleteBody(KiiObjectCallBack)
-
refresh
@WorkerThread public void refresh() throws java.io.IOException, BadRequestException, UnauthorizedException, ForbiddenException, ConflictException, NotFoundException, UndefinedExceptionGet latest KiiObject form KiiCloud and refresh properties.
Any update has not saved will be overwritten. To store local updates on KiiCloud, usesave()
NOTE: This api access to server. Should not be executed in UI/Main thread.- Throws:
java.io.IOException- When network related error has happened.UndefinedExceptionNotFoundExceptionConflictExceptionForbiddenExceptionBadRequestExceptionUnauthorizedExceptionjava.lang.IllegalStateException- Thrown If
- SDK is not initialized. - KiiObject is not exists in the cloud.- See Also:
refresh(KiiObjectCallBack)
-
save
public int save(@Nullable KiiObjectCallBack callBack)Asynchronous call forsave(). Background task will be initiated to execute the task.
NOTE: This API can not create new KiiObject on cloud when instantiated byKiiBucket.object(String), but can only update. If you want to create new KiiObject with it, please usesaveAllFields(boolean)orsaveAllFields(KiiObjectCallBack, boolean)instead.- Parameters:
callBack- notifies events- Returns:
- id used for cancel this operation. see also
Kii.cancelTask(int)
-
delete
public int delete(@Nullable KiiObjectCallBack callBack)Asynchronous call fordelete(). A background task will be initiated to execute the task.- Parameters:
callBack- notifies events- Returns:
- id used for cancel this operation. see also
Kii.cancelTask(int)
-
publishBody
public void publishBody(@NonNull KiiObjectPublishCallback callback)Asynchronous call forpublishBody(). A background task will be initiated to execute the task.- Parameters:
callback- is the implementation for the Callback- Throws:
java.lang.IllegalArgumentException- when callback is null.
-
publishBodyExpiresAt
public void publishBodyExpiresAt(long expiresAt, @NonNull KiiObjectPublishCallback callback)Asynchronous call forpublishBodyExpiresAt(long). A background task will be initiated to execute the task.- Parameters:
expireTime- A expire time of publish URL in milliseconds (Since January 1, 1970 00:00:00 UTC).callback- is the implementation for the Callback- Throws:
java.lang.IllegalArgumentException- when callback is null.
-
publishBodyExpiresIn
public void publishBodyExpiresIn(int expiresIn, @Nullable KiiObjectPublishCallback callback)Asynchronous call forpublishBodyExpiresIn(int). A background task will be initiated to execute the task.- Parameters:
expiresIn- The period time in seconds the publication URL has to be available, after that it will expire.callback- is the implementation for the Callback
-
uploadBody
@WorkerThread public void uploadBody(@NonNull java.io.File sourceFile, @Nullable java.lang.String contentType, @Nullable KiiObjectBodyCallback callback)Asynchronous call foruploadBody(File, String). A background task will be initiated to execute the task.
NOTE: If target KiiObject is not created, please callsave()orsaveAllFields(boolean)before uploading. NOTE: After this operation, KiiObject version will be updated. If you want to usesave(boolean)with overwrite=false argument, please dorefresh()before saving.- Parameters:
sourceFile- File to upload or update. When the attached file is existed in cloud, it will be replaced with this file.contentType- Content type of the object body. If null is passed, content type is determined from file extension by using android.webkit.MimeTypeMap.callback- Notifies events.
-
downloadBody
public void downloadBody(@NonNull java.io.File destFile, @Nullable KiiObjectBodyCallback callback)Asynchronous call fordownloadBody(File). A background task will be initiated to execute the task.- Parameters:
destFile- Destination file to download. If file destination is existed, file is overwritten with downloaded file.callback- Notifies events.
-
deleteBody
public int deleteBody(@Nullable KiiObjectCallBack callBack)Asynchronous call fordeleteBody(). A background task will be initiated to execute the task.- Parameters:
callBack- notifies events- Returns:
- id used for cancel this operation. see also
Kii.cancelTask(int)
-
refresh
public int refresh(@Nullable KiiObjectCallBack callBack)Asynchronous call forrefresh().
Background task will be initiated to execute the task.- Parameters:
callBack- notifies events.- Returns:
- id used for cancel this operation. see also
Kii.cancelTask(int)
-
toUri
@Nullable public android.net.Uri toUri()
Retruns URI of this KiiObject.
The format is- Application scope object: kiicloud://buckets/{name of bucket}/objects/{id of the object}
- User scope object: kiicloud://users/{id of the user}/buckets/{name of bucket}/objects/{id of the object}
- Group scope object: kiicloud://groups/{id of the group}/buckets/{name of bucket}/objects/{id of the object}
- Returns:
- URI of this KiiObject null if KiiObject has not saved on cloud.
-
getModifedTime
public long getModifedTime()
Get the modified time on Server- Returns:
- A long represents creation date in milliseconds (Since January 1, 1970 00:00:00 UTC).
-1 when the object has not saved or has not fetch this property yet when this object has instantiate bycreateByUri(Uri) - See Also:
refresh()
-
getCreatedTime
public long getCreatedTime()
Get the created time on Server- Returns:
- A long represents creation date in milliseconds (Since January 1, 1970 00:00:00 UTC).
-1 when the object has not saved or has not fetch this property yet when this object has instantiate bycreateByUri(Uri) - See Also:
refresh()
-
acl
@NonNull public KiiACL acl()
Get the ACL handle of this KiiObject.- Returns:
- ACL of this KiiObject
- See Also:
KiiACL
-
set
public void set(@NonNull java.lang.String key, @NonNull GeoPoint value)Set GeoPoint to this object with the specified key.- Parameters:
key- name of the field.value- GeoPoint to be tied to the specified key- Throws:
java.lang.IllegalArgumentException- when key is empty, null, any reserve key or value is null.
-
set
public void set(@NonNull java.lang.String key, @NonNull org.json.JSONObject value)Create/Update the key/value.- Overrides:
setin classKiiBaseObject- Parameters:
key- is Key stringvalue- is JSONObject- Throws:
java.lang.IllegalArgumentException- when key or value is empty or nullIllegalKiiBaseObjectFormatException- if value contains illegal syntax
-
set
public void set(@NonNull java.lang.String key, @NonNull java.lang.String value)Create/Update the key/value string of the KiiObject. KiiCloud perform indexing of the value string which maximum length is 190 characters. Provided string value that exceeds maximum length, will not be indexed.(i.e. The object won't match with the query by this key, and sort by this key won't be applied for the object not indexed.)- Overrides:
setin classKiiBaseObject- Parameters:
key- is Key stringvalue- is Value string- Throws:
java.lang.IllegalArgumentException- when key is empty, null, any reserve key or value is nullIllegalKiiBaseObjectFormatException- if value contains illegal syntax
-
getGeoPoint
@NonNull public GeoPoint getGeoPoint(@NonNull java.lang.String key)
Get the GeoPoint of this object tied to the specified key.- Parameters:
key- name of the field.- Returns:
- GeoPoint tied to the key.
- Throws:
java.lang.IllegalArgumentException- when key is empty, null.IllegalKiiBaseObjectFormatException- specified key is not exists in the object.- See Also:
getGeoPoint(String, GeoPoint)
-
getGeoPoint
@Nullable public GeoPoint getGeoPoint(@NonNull java.lang.String key, @Nullable GeoPoint fallback)
Get the GeoPoint of this object tied to the specified key. If specified key is not exists, fallback will be returned.- Parameters:
key- name of the field.fallback- return if geo point does not exist for the specified key.- Returns:
- GeoPoint tied to the key.
- Throws:
java.lang.IllegalArgumentException- when key is empty, null.- See Also:
getGeoPoint(String)
-
toJSON
@NonNull public org.json.JSONObject toJSON()
Returns JSON representation of this KiiObject. The JSONObject contains key/value from local cache. To get the latest key/value from cloud, callingrefresh()is necessary prior calling this method. On refresh, it replaces the local cache with the cloud one. The properties of KiiUser will not be changed by operating returned JSONObject. Value ofgetModifedTime()andgetCreatedTime()will be mapped to key "_modified" and "_created" respectively and the value oftoUri()will be mapped to the reserved key "_kiireserved_uri". If the object is not saved, value of "_kiireserved_uri" will be org.json.JSONObject#NULL. For the key/value that is set byKiiBaseObject.set(String, byte[]), JSONObject contains encoded(Base64) string of the value(byte[]).
NOTE: These two keys("_modified" and "_created") always set by the cloud and can not be used in the setter methods of KiiObject.- Returns:
- JSONObject JSONObject represents this KiiObject.
-
toString
@NonNull public java.lang.String toString()
Returns String representation of JSONObject get fromtoJSON()- Overrides:
toStringin classjava.lang.Object
-
uploader
@NonNull public KiiUploader uploader(@NonNull android.content.Context context, @NonNull java.io.File source)
InstantiateKiiUploaderwith local file.- Parameters:
context- is the application environmentsource- file to be uploaded.- Returns:
- KiiUploader instance
- Throws:
java.lang.IllegalArgumentException- Thrown if context or file is null.
-
downloader
@NonNull public KiiDownloader downloader(@NonNull android.content.Context context, @NonNull java.io.File dest) throws InvalidHolderException
InstantiateKiiDownloader.- Parameters:
context-dest- destination file.- Returns:
- KiiDownloader instance
- Throws:
InvalidHolderException- thrown if this KiiObject has not saved on Kii cloud or deleted.java.lang.IllegalArgumentException- Thrown if context or dest file is null.
-
describeContents
public int describeContents()
- Specified by:
describeContentsin interfaceandroid.os.Parcelable
-
writeToParcel
public void writeToParcel(android.os.Parcel dest, int flags)- Specified by:
writeToParcelin interfaceandroid.os.Parcelable
-
isValidObjectID
public static boolean isValidObjectID(@Nullable java.lang.String objectID)Check if given ID is valid for object ID. Valid pattern: ^[a-zA-Z0-9-_\\.]{2,100}$- Parameters:
objectID- ID to be checked.- Returns:
- true if given ID is valid, false otherwise.
-
getBodyContentType
@Nullable public java.lang.String getBodyContentType()
The content type of object body. null by default. The value will be set automatically after successful of upload/download object body operation such asuploadBody(File, String)ordownloadBody(File).- Returns:
- The content type of the body.
-
-