public final class BoxFolder extends BoxItem implements Iterable<BoxItem.Info>
Modifier and Type | Class and Description |
---|---|
class |
BoxFolder.Info
Contains information about a BoxFolder.
|
static class |
BoxFolder.Permission
Enumerates the possible permissions that a user can have on a folder.
|
static class |
BoxFolder.SyncState
Enumerates the possible sync states that a folder can have.
|
Modifier and Type | Field and Description |
---|---|
static String[] |
ALL_FIELDS
An array of all possible folder fields that can be requested when calling
getInfo() . |
Constructor and Description |
---|
BoxFolder(BoxAPIConnection api,
String id)
Constructs a BoxFolder for a folder with a given ID.
|
Modifier and Type | Method and Description |
---|---|
BoxCollaboration.Info |
collaborate(BoxCollaborator collaborator,
BoxCollaboration.Role role)
Adds a collaborator to this folder.
|
BoxCollaboration.Info |
collaborate(String email,
BoxCollaboration.Role role)
Adds a collaborator to this folder.
|
BoxFolder.Info |
copy(BoxFolder destination)
Copies this item to another folder.
|
BoxFolder.Info |
copy(BoxFolder destination,
String newName)
Copies this item to another folder and gives it a new name.
|
BoxFolder.Info |
createFolder(String name)
Creates a new child folder inside this folder.
|
BoxSharedLink |
createSharedLink(BoxSharedLink.Access access,
Date unshareDate,
BoxSharedLink.Permissions permissions)
Creates a new shared link for this item.
|
void |
delete(boolean recursive)
Deletes this folder, optionally recursively deleting all of its contents.
|
Iterable<BoxItem.Info> |
getChildren()
Returns an iterable containing the items in this folder.
|
Iterable<BoxItem.Info> |
getChildren(String... fields)
Returns an iterable containing the items in this folder and specifies which child fields to retrieve from the
API.
|
PartialCollection<BoxItem.Info> |
getChildrenRange(long offset,
long limit,
String... fields)
Retrieves a specific range of child items in this folder.
|
Collection<BoxCollaboration.Info> |
getCollaborations()
Gets information about all of the collaborations for this folder.
|
BoxFolder.Info |
getInfo()
Gets information about this item.
|
BoxFolder.Info |
getInfo(String... fields)
Gets information about this item that's limited to a list of specified fields.
|
static BoxFolder |
getRootFolder(BoxAPIConnection api)
Gets the current user's root folder.
|
Iterator<BoxItem.Info> |
iterator()
Returns an iterator over the items in this folder.
|
void |
move(BoxFolder destination)
Moves this folder to another folder.
|
void |
rename(String newName)
Renames this folder.
|
Iterable<BoxItem.Info> |
search(String query)
Searches this folder and all descendant folders using a given query.
|
void |
updateInfo(BoxFolder.Info info)
Updates the information about this folder with any info fields that have been modified locally.
|
BoxFile.Info |
uploadFile(FileUploadParams uploadParams)
Uploads a new file to this folder with custom upload parameters.
|
BoxFile.Info |
uploadFile(InputStream fileContent,
String name)
Uploads a new file to this folder.
|
BoxFile.Info |
uploadFile(InputStream fileContent,
String name,
long fileSize,
ProgressListener listener)
Uploads a new file to this folder while reporting the progress to a ProgressListener.
|
equals, getAPI, getID, hashCode
public static final String[] ALL_FIELDS
getInfo()
.public BoxFolder(BoxAPIConnection api, String id)
api
- the API connection to be used by the folder.id
- the ID of the folder.public static BoxFolder getRootFolder(BoxAPIConnection api)
api
- the API connection to be used by the folder.public BoxCollaboration.Info collaborate(BoxCollaborator collaborator, BoxCollaboration.Role role)
collaborator
- the collaborator to add.role
- the role of the collaborator.public BoxCollaboration.Info collaborate(String email, BoxCollaboration.Role role)
email
- the email address of the collaborator to add.role
- the role of the collaborator.public BoxSharedLink createSharedLink(BoxSharedLink.Access access, Date unshareDate, BoxSharedLink.Permissions permissions)
BoxItem
This method is a convenience method for manually creating a new shared link and applying it to this item with
BoxItem.Info.setSharedLink(com.box.sdk.BoxSharedLink)
. You may want to create the shared link manually so that it can be updated along with
other changes to the item's info in a single network request, giving a boost to performance.
createSharedLink
in class BoxItem
access
- the access level of the shared link.unshareDate
- the date and time at which the link will expire. Can be null to create a non-expiring link.permissions
- the permissions of the shared link. Can be null to use the default permissions.public Collection<BoxCollaboration.Info> getCollaborations()
public BoxFolder.Info getInfo()
BoxItem
public BoxFolder.Info getInfo(String... fields)
BoxItem
public void updateInfo(BoxFolder.Info info)
info
- the updated info.public BoxFolder.Info copy(BoxFolder destination)
BoxItem
public BoxFolder.Info copy(BoxFolder destination, String newName)
BoxItem
public BoxFolder.Info createFolder(String name)
name
- the new folder's name.public void delete(boolean recursive)
recursive
- true to recursively delete this folder's contents; otherwise false.public void move(BoxFolder destination)
destination
- the destination folder.public void rename(String newName)
newName
- the new name of the folder.public BoxFile.Info uploadFile(InputStream fileContent, String name)
fileContent
- a stream containing the contents of the file to upload.name
- the name to give the uploaded file.public BoxFile.Info uploadFile(InputStream fileContent, String name, long fileSize, ProgressListener listener)
fileContent
- a stream containing the contents of the file to upload.name
- the name to give the uploaded file.fileSize
- the size of the file used for determining the progress of the upload.listener
- a listener for monitoring the upload's progress.public BoxFile.Info uploadFile(FileUploadParams uploadParams)
uploadParams
- the custom upload parameters.public Iterable<BoxItem.Info> getChildren()
public Iterable<BoxItem.Info> getChildren(String... fields)
fields
- the fields to retrieve.public PartialCollection<BoxItem.Info> getChildrenRange(long offset, long limit, String... fields)
offset
- the index of the first child item to retrieve.limit
- the maximum number of children to retrieve after the offset.fields
- the fields to retrieve.public Iterator<BoxItem.Info> iterator()
iterator
in interface Iterable<BoxItem.Info>
public Iterable<BoxItem.Info> search(String query)
query
- the search query.