Class Comment
- java.lang.Object
-
- com.github.javaparser.ast.Node
-
- com.github.javaparser.ast.comments.Comment
-
- All Implemented Interfaces:
NodeWithRange<Node>
,NodeWithTokenRange<Node>
,Observable
,Visitable
,HasParentNode<Node>
,Cloneable
- Direct Known Subclasses:
BlockComment
,JavadocComment
,LineComment
public abstract class Comment extends Node
Abstract class for all AST nodes that represent comments.- Author:
- Julio Vilmar Gesser
- See Also:
BlockComment
,LineComment
,JavadocComment
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.github.javaparser.ast.Node
Node.ObserverRegistrationMode, Node.Parsedness
-
-
Field Summary
-
Fields inherited from class com.github.javaparser.ast.Node
ABSOLUTE_BEGIN_LINE, ABSOLUTE_END_LINE, NODE_BY_BEGIN_POSITION, prettyPrinterNoCommentsConfiguration
-
-
Constructor Summary
Constructors Constructor Description Comment(TokenRange tokenRange, String content)
This constructor is used by the parser and is considered private.Comment(String content)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description LineComment
asLineComment()
Comment
clone()
Optional<Node>
getCommentedNode()
String
getContent()
Return the text of the comment.CommentMetaModel
getMetaModel()
boolean
isLineComment()
boolean
isOrphan()
boolean
remove()
Try to remove this node from the parentboolean
remove(Node node)
boolean
replace(Node node, Node replacementNode)
Comment
setCommentedNode(Node commentedNode)
Sets the commentedNodeComment
setContent(String content)
Sets the text of the comment.-
Methods inherited from class com.github.javaparser.ast.Node
addOrphanComment, customInitialization, equals, getAllContainedComments, getChildNodes, getChildNodesByType, getComment, getData, getNodeLists, getNodesByType, getOrphanComments, getParentNode, getParentNodeForChildren, getParsed, getRange, getTokenRange, hasComment, hashCode, isRegistered, notifyPropertyChange, register, register, registerForSubtree, removeComment, removeForced, removeOrphanComment, replace, setAsParentNodeOf, setAsParentNodeOf, setBlockComment, setComment, setData, setLineComment, setParentNode, setParsed, setRange, setTokenRange, toString, toString, tryAddImportToParentCompilationUnit, unregister
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.github.javaparser.HasParentNode
getAncestorOfType
-
Methods inherited from interface com.github.javaparser.ast.nodeTypes.NodeWithRange
containsWithin, getBegin, getEnd, isPositionedAfter, isPositionedBefore
-
-
-
-
Constructor Detail
-
Comment
public Comment(String content)
-
Comment
@Generated("com.github.javaparser.generator.core.node.MainConstructorGenerator") public Comment(TokenRange tokenRange, String content)
This constructor is used by the parser and is considered private.
-
-
Method Detail
-
getContent
@Generated("com.github.javaparser.generator.core.node.PropertyGenerator") public String getContent()
Return the text of the comment.- Returns:
- text of the comment
-
setContent
@Generated("com.github.javaparser.generator.core.node.PropertyGenerator") public Comment setContent(String content)
Sets the text of the comment.- Parameters:
content
- the text of the comment to set
-
isLineComment
public boolean isLineComment()
-
asLineComment
public LineComment asLineComment()
-
setCommentedNode
public Comment setCommentedNode(Node commentedNode)
Sets the commentedNode- Parameters:
commentedNode
- the commentedNode, can be null- Returns:
- this, the Comment
-
isOrphan
public boolean isOrphan()
-
remove
public boolean remove()
Description copied from class:Node
Try to remove this node from the parent
-
remove
@Generated("com.github.javaparser.generator.core.node.RemoveMethodGenerator") public boolean remove(Node node)
-
clone
@Generated("com.github.javaparser.generator.core.node.CloneGenerator") public Comment clone()
-
getMetaModel
@Generated("com.github.javaparser.generator.core.node.GetMetaModelGenerator") public CommentMetaModel getMetaModel()
- Overrides:
getMetaModel
in classNode
- Returns:
- get JavaParser specific node introspection information.
-
replace
@Generated("com.github.javaparser.generator.core.node.ReplaceMethodGenerator") public boolean replace(Node node, Node replacementNode)
-
-