Package com.kii.cloud.storage
Class KiiBucket
- java.lang.Object
-
- com.kii.cloud.storage.KiiBucket
-
- All Implemented Interfaces:
KiiBaseBucket
,KiiSubscribable
- Direct Known Subclasses:
KiiEncryptedBucket
public class KiiBucket extends java.lang.Object implements KiiBaseBucket, KiiSubscribable
KiiBucket is a representation of bucket. This class has methods for accessing KiiCloud.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description KiiACL
acl()
Get the ACL handle of this KiiBucket.int
count()
Execute count aggregation of all clause query on current bucket.void
count(CountCallBack callback)
Asynchronous call forcount()
.int
count(KiiQuery query)
Execute count aggregation of specified query on current bucket.void
count(KiiQuery query, CountCallBack callback)
Asynchronous call forcount(KiiQuery)
.void
delete()
Delete the bucket.int
delete(KiiBucketCallBack<KiiBucket> callBack)
Asynchronous call fordelete()
.java.lang.String
getName()
Returns bucket name.protected java.lang.String
getQualifiedBucketName()
KiiRTransferManager
getTransferManager()
Get transfer manager of this bucket.static boolean
isValidBucketName(java.lang.String name)
Checks whether the bucket name is valid or not.
Valid bucket name definition is: Not null or empty Matches ^[a-zA-Z0-9-_]{2,64}$KiiObject
object()
Create a KiiObject whose scope is this bucket.KiiObject
object(java.lang.String objectID)
Instantiate KiiObject specifying its ID.int
query(KiiQueryCallBack<KiiObject> callBack, KiiQuery query)
Asynchronous call forquery(KiiQuery)
.KiiQueryResult<KiiObject>
query(KiiQuery query)
The query operation returns a list of KiiObject that matches the query expression.
-
-
-
Method Detail
-
object
@NonNull public KiiObject object()
Create a KiiObject whose scope is this bucket.- Returns:
- KiiObject whose scope is this bucket.
-
object
@NonNull public KiiObject object(@NonNull java.lang.String objectID)
Instantiate KiiObject specifying its ID. If the object has not exist on KiiCloud,KiiObject.saveAllFields(boolean)
orKiiObject.saveAllFields(com.kii.cloud.storage.callback.KiiObjectCallBack, boolean)
will create new Object which has ID specified in the argument. If the object exist in KiiCloud, references the existing object which has specified ID. useKiiObject.refresh()
to retrieve the contents of KiiObject.- Parameters:
objectID
- ID of KiiObject you want to instantiate.- Returns:
- KiiObject instance.
- Throws:
java.lang.IllegalArgumentException
- objectID is null or not acceptable. Refer toKiiObject.isValidObjectID(String)
for details of acceptable string.
-
query
@WorkerThread @NonNull public KiiQueryResult<KiiObject> query(@Nullable KiiQuery query) throws java.io.IOException, BadRequestException, UnauthorizedException, ForbiddenException, ConflictException, NotFoundException, UndefinedException
The query operation returns a list of KiiObject that matches the query expression. If the query is null, all the KiiObject whose score is this bucket will be returned.
NOTE: This api access to server. Should not be executed in UI/Main thread.- Parameters:
query
- to be executed. If null, it inquires all object in the bucket.- Returns:
- KiiQueryResult
KiiQueryResult.getResult()
list of KiiObject that matches the query.KiiQueryResult.hasNext()
to check if there are any more resultKiiQueryResult.getNextKiiQuery()
to get the query to read next batch - Throws:
java.io.IOException
- When network related error has happenedUndefinedException
NotFoundException
ConflictException
ForbiddenException
UnauthorizedException
BadRequestException
- See Also:
query(KiiQueryCallBack, KiiQuery)
-
count
public int count() throws java.io.IOException, BadRequestException, UnauthorizedException, ForbiddenException, ConflictException, NotFoundException, UndefinedException
Execute count aggregation of all clause query on current bucket.
NOTE: This api access to server. Should not be executed in UI/Main thread.- Returns:
- int number of objects in the bucket.
- Throws:
java.io.IOException
- When network related error has happenedUndefinedException
NotFoundException
ConflictException
ForbiddenException
UnauthorizedException
BadRequestException
-
count
@WorkerThread public int count(@Nullable KiiQuery query) throws java.io.IOException, BadRequestException, UnauthorizedException, ForbiddenException, ConflictException, NotFoundException, UndefinedException
Execute count aggregation of specified query on current bucket. Query generated fromKiiQueryResult.getNextKiiQuery()
is not supported,BadRequestException
will be thrown in this case.
NOTE: This api access to server. Should not be executed in UI/Main thread.- Parameters:
query
- to be executed. If null, the operation will be same ascount()
.- Returns:
- int number of objects that match the specified query.
- Throws:
java.io.IOException
- When network related error has happened.UndefinedException
NotFoundException
ConflictException
ForbiddenException
UnauthorizedException
BadRequestException
- When the query is not supported.
-
count
public void count(@NonNull CountCallBack callback)
Asynchronous call forcount()
. A background task will be initiated to execute the task.- Parameters:
callback
- is the implementation for the CallBack.- Throws:
java.lang.IllegalArgumentException
- when specified callback is null.
-
count
public void count(@Nullable KiiQuery query, @NonNull CountCallBack callback)
Asynchronous call forcount(KiiQuery)
. A background task will be initiated to execute the task.- Parameters:
query
- to be executed.callback
- is the implementation for the CallBack.- Throws:
java.lang.IllegalArgumentException
- when specified callback is null.
-
getQualifiedBucketName
protected java.lang.String getQualifiedBucketName()
-
delete
@WorkerThread public void delete() throws java.io.IOException, BadRequestException, ConflictException, ForbiddenException, NotFoundException, UnauthorizedException, UndefinedException
Delete the bucket.
NOTE: This api access to server. Should not be executed in UI/Main thread.- Throws:
java.io.IOException
- When network related error has happenedUndefinedException
NotFoundException
ConflictException
ForbiddenException
BadRequestException
UnauthorizedException
- See Also:
delete(KiiBucketCallBack)
-
delete
public int delete(@NonNull KiiBucketCallBack<KiiBucket> 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)
-
query
public int query(@NonNull KiiQueryCallBack<KiiObject> callBack, @Nullable KiiQuery query)
Asynchronous call forquery(KiiQuery)
. A background task will be initiated to execute the task.- Parameters:
callBack
- is the implementation for the CallBackquery
- query to be executed. If null, it inquires all object in the bucket.- Returns:
- unique ID which is used to identify this Async Task
-
acl
@NonNull public KiiACL acl()
Get the ACL handle of this KiiBucket.- Returns:
- ACL of this KiiBucket
- See Also:
KiiACL
-
getName
@NonNull public java.lang.String getName()
Returns bucket name.- Returns:
- name of the bucket.
-
isValidBucketName
public static boolean isValidBucketName(@Nullable java.lang.String name)
Checks whether the bucket name is valid or not.
Valid bucket name definition is:- Not null or empty
- Matches ^[a-zA-Z0-9-_]{2,64}$
- Parameters:
name
- Name of the bucket.- Returns:
- true if valid otherwise false.
-
getTransferManager
@NonNull public KiiRTransferManager getTransferManager()
Get transfer manager of this bucket. ReturnedKiiRTransferManager
will provide the list of Ongoing/ Suspended Transfer tied to this bucket.- Returns:
KiiRTransferManager
bound to this bucket.
-
-