public class Comment extends Node
Modifier and Type | Field and Description |
---|---|
static short |
CDATA
commentType constant denoting a comment of type CDATA (eg,
<![CDATA[ text ]]> ) |
static short |
DOCTYPE
commentType constant denoting comment of type DOCTYPE (eg,
) |
static short |
IRREGULAR
commentType constant denoting an irreglar HTML/XML comment (eg,
<! comment > ) |
static short |
PROCESSING_INSTRUCTION
commentType constant denoting a comment of type processing instruction (eg,
<?xml version="1.0" encoding="UTF-8"?> ) |
static short |
REGULAR
commentType constant denoting a reglar HTML/XML comment (eg,
<!-- comment --> ) |
COMMENT_TYPE, DOCUMENT_TYPE, ELEMENT_TYPE, TEXT_TYPE
Constructor and Description |
---|
Comment(String text,
short commentType)
Creates a Comment of the type denoted by the type constant, containing the specified text.
|
Modifier and Type | Method and Description |
---|---|
static String |
commentTypeToString(short commentType)
returns String representation of the commentType constant.
|
short |
getCommentType()
Returns the comment type constant associated with this comment.
|
String |
getText()
Retrieves the text content of the Comment.
|
void |
setText(String text)
Sets the text content of the Comment.
|
String |
toString()
Returns a String representation of the Comment.
|
delete, findNearestCommonAncestor, getParent, getType, isAfter, isBefore, isBetween, isBetween, nextNode, nextNodeSibling, nextNonDescendantNode, previousNode, previousNodeSibling, typeToString
public static final short IRREGULAR
<! comment >
)public static final short CDATA
<![CDATA[ text ]]>
)public static final short PROCESSING_INSTRUCTION
<?xml version="1.0" encoding="UTF-8"?>
)public static final short REGULAR
<!-- comment -->
)public static final short DOCTYPE
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
)public Comment(String text, short commentType)
text
- the text content; for comments of type REGULAR it is the text between <-- and --> for comments of type IRREGULAR it is the text between <! and >; for comments of type CDATA it is the text between <![CDATA[ and ]]>; for comments of type DOCTYPE it is the text between <!DOCTYPE and >; for comments of type PROCESSING_INSTRUCTION it is the text between < and >.commentType
- a comment type constant.public short getCommentType()
public void setText(String text)
text
- the text content; for comments of type REGULAR it is the text between <-- and --> for comments of type IRREGULAR it is the text between <! and >; for comments of type CDATA it is the text between <![CDATA[ and ]]>; for comments of type DOCTYPE it is the text between <!DOCTYPE and >; for comments of type PROCESSING_INSTRUCTION it is the text between < and >.public String getText()
public static String commentTypeToString(short commentType)