public final class Comment extends InlineStory
To learn more, visit the Working with Comments documentation article.
A comment is an annotation which is anchored to a region of text or to a position in text. A comment can contain an arbitrary amount of block-level content.
If a Comment object occurs on its own, the comment is anchored to the position of the Comment object.
To anchor a comment to a region of text three objects are required: Comment, CommentRangeStart and CommentRangeEnd. All three objects need to share the same getId() value.
Comment is an inline-level node and can only be a child of Paragraph.
CommentRangeStart,
CommentRangeEnd| Constructor and Description |
|---|
Comment(DocumentBase doc)
Initializes a new instance of the Comment class.
|
Comment(DocumentBase doc,
java.lang.String author,
java.lang.String initial,
java.util.Date dateTime)
Initializes a new instance of the Comment class.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
accept(DocumentVisitor visitor)
Accepts a visitor.
|
Comment |
addReply(java.lang.String author,
java.lang.String initial,
java.util.Date dateTime,
java.lang.String text)
Adds a reply to this comment.
|
Comment |
getAncestor()
Returns the parent Comment object.
|
java.lang.String |
getAuthor()
Gets the author name for a comment.
|
java.util.Date |
getDateTime()
Gets the date and time that the comment was made.
|
boolean |
getDone()
Gets flag indicating that the comment has been marked done.
|
int |
getId()
Gets the comment identifier.
|
int |
getIdInternal() |
java.lang.String |
getInitial()
Gets the initials of the user associated with a specific comment.
|
int |
getNodeType()
Returns NodeType.Comment.
|
int |
getParentIdInternal() |
CommentCollection |
getReplies()
Returns a collection of
Comment objects that are immediate children of the specified comment. |
int |
getStoryType()
Returns StoryType.Comments.
|
void |
removeAllReplies()
Removes all replies to this comment.
|
void |
removeMoveRevisions() |
void |
removeReply(Comment reply)
Removes the specified reply to this comment.
|
void |
setAuthor(java.lang.String value)
Sets the author name for a comment.
|
void |
setDateTime(java.util.Date value)
Gets the date and time that the comment was made.
|
void |
setDone(boolean value)
Sets flag indicating that the comment has been marked done.
|
void |
setIdInternal(int value) |
void |
setInitial(java.lang.String value)
Sets the initials of the user associated with a specific comment.
|
void |
setParentIdInternal(int value) |
void |
setText(java.lang.String text)
This is a convenience method that allows to easily set text of the comment.
|
clearRunAttrs, ensureMinimum, fetchInheritedRunAttr, getDirectRunAttr, getDocument_IInline, getFirstParagraph, getFont, getLastParagraph, getParagraphs, getParentParagraph_IInline, getParentParagraph, getTables, isDeleteRevision, isInsertRevision, isMoveFromRevision, isMoveToRevision, removeRunAttr, setRunAttracceptChildren, acceptCore, appendChild, coreRemoveSelfOnly, getChild, getChildNodes, getChildNodes, getContainer, getCount, getCurrentNode, getFirstChild, getLastChild, getNextMatchingNode, getText, hasChildNodes, indexOf, insertAfter, insertBefore, isComposite, iterator, prependChild, removeAllChildren, removeChild, removeSmartTags, selectNodes, selectSingleNodedd, deepClone, getAncestor, getAncestor, getCustomNodeId, getDocument, getNextSibling, getParentNode, getPreviousSibling, getRange, memberwiseClone, nextPreOrder, nodeTypeToString, previousPreOrder, remove, setCustomNodeId, toString, toString, toString, visitorActionToBoolpublic Comment(DocumentBase doc)
When Comment is created, it belongs to the specified document, but is not yet part of the document and ParentNode is null.
To append Comment to the document use InsertAfter or InsertBefore on the paragraph where you want the comment inserted.
After creating a comment, don't forget to set its getAuthor() / setAuthor(java.lang.String), getInitial() / setInitial(java.lang.String) and getDateTime() / setDateTime(java.util.Date) properties.
doc - The owner document.public Comment(DocumentBase doc, java.lang.String author, java.lang.String initial, java.util.Date dateTime)
doc - The owner document.author - The author name for the comment. Cannot be null.initial - The author initials for the comment. Cannot be null.dateTime - The date and time for the comment.public final int getNodeType()
getNodeType in class NodeNodeType constants.public final int getStoryType()
getStoryType in class InlineStoryStoryType constants.public final int getId()
The comment identifier allows to anchor a comment to a region of text in the document. The region must be demarcated using the CommentRangeStart and CommentRangeEnd object sharing the same identifier value as the Comment object.
You would use this value when looking for the CommentRangeStart and CommentRangeEnd nodes that are linked to this comment.
Comment identifiers are supposed to be unique across a document and Aspose.Words automatically maintains comment identifiers when loading, saving and combining documents.
public final int getIdInternal()
public final void setIdInternal(int value)
public final int getParentIdInternal()
public final void setParentIdInternal(int value)
public final java.lang.String getInitial()
Cannot be null.
Default is empty string.
public final void setInitial(java.lang.String value)
Cannot be null.
Default is empty string.
value - The initials of the user associated with a specific comment.public final java.util.Date getDateTime()
Default is 03.01.0001.
public final void setDateTime(java.util.Date value)
Default is 03.01.0001.
value - The date and time that the comment was made.public final java.lang.String getAuthor()
Cannot be null.
Default is empty string.
public final void setAuthor(java.lang.String value)
Cannot be null.
Default is empty string.
value - The author name for a comment.public final boolean accept(DocumentVisitor visitor) throws java.lang.Exception
Enumerates over this node and all of its children. Each node calls a corresponding method on DocumentVisitor.
For more info see the Visitor design pattern.
public final Comment addReply(java.lang.String author, java.lang.String initial, java.util.Date dateTime, java.lang.String text) throws java.lang.Exception
author - The author name for the reply.initial - The author initials for the reply.dateTime - The date and time for the reply.text - The reply text.Comment node for the reply.java.lang.Exceptionpublic final void removeReply(Comment reply) throws java.lang.Exception
reply - The comment node of the deleting reply.java.lang.Exceptionpublic final void removeAllReplies()
throws java.lang.Exception
java.lang.Exceptionpublic final void setText(java.lang.String text)
This method allows to quickly set text of a comment from a string. The string can contain paragraph breaks, this will create paragraphs of text in the comment accordingly. If you want to insert more complex elements into the comment, for example bookmarks or tables or apply rich formatting, then you need to use the appropriate node classes to build up the comment text.
text - The new text of the comment.public final Comment getAncestor()
public final CommentCollection getReplies()
Comment objects that are immediate children of the specified comment.Comment objects that are immediate children of the specified comment.public final boolean getDone()
public final void setDone(boolean value)
value - Flag indicating that the comment has been marked done.public final void removeMoveRevisions()