Comment objects represent a user-created comment on a file. They can be added directly to a file or they can be a reply to another comment.
- Get a Comment's Information
- Get the Comments on a File
- Add a Comment to a File
- Reply to a Comment
- Change a Comment's Message
- Delete a Comment
Calling getInfo() on a comment returns a snapshot of the comment's
info.
BoxComment comment = new BoxComment(api, "id");
BoxComment.Info info = comment.getInfo();You can get all of the comments on a file by calling the
getComments() method.
BoxFile file = new BoxFile(api, "id");
List<BoxComment.Info> comments = file.getComments();A comment can be added to a file with the addComment(String)
method.
BoxFile file = new BoxFile(api, "id");
file.addComment("This file is pretty cool.");The comment's message can also contain @mentions by using the string
@[userid:username] anywhere within the message, where userid and username are
the ID and username of the person being mentioned. [See the documentation]
(https://developers.box.com/docs/#comments-comment-object) on the
tagged_message field for more information on @mentions.
BoxFile file = new BoxFile(api, "id");
file.addComment("Message mentioning @[1234:user@box.com].");You can reply to a comment with the reply(String) method.
BoxComment comment = new BoxComment(api, "id");
comment.reply("A reply to another comment.");The message of a comment can be changed with the
changeMessage(String) method.
BoxComment comment = new BoxComment(api, "id");
comment.changeMessage("An edited message.");A comment can be deleted with the delete() method.
BoxComment comment = new BoxComment(api, "id");
comment.delete();