001package org.jsoup.nodes;
002
003import java.io.IOException;
004
005/**
006 A comment node.
007
008 @author Jonathan Hedley, jonathan@hedley.net */
009public class Comment extends LeafNode {
010    private static final String COMMENT_KEY = "comment";
011
012    /**
013     Create a new comment node.
014     @param data The contents of the comment
015     */
016    public Comment(String data) {
017        value = data;
018    }
019
020    /**
021     Create a new comment node.
022     @param data The contents of the comment
023     @param baseUri base URI not used. This is a leaf node.
024     @deprecated
025     */
026    public Comment(String data, String baseUri) {
027        this(data);
028    }
029
030    public String nodeName() {
031        return "#comment";
032    }
033
034    /**
035     Get the contents of the comment.
036     @return comment content
037     */
038    public String getData() {
039        return coreValue();
040    }
041
042        void outerHtmlHead(Appendable accum, int depth, Document.OutputSettings out) throws IOException {
043        if (out.prettyPrint())
044            indent(accum, depth, out);
045        accum
046                .append("<!--")
047                .append(getData())
048                .append("-->");
049    }
050
051        void outerHtmlTail(Appendable accum, int depth, Document.OutputSettings out) {}
052
053    @Override
054    public String toString() {
055        return outerHtml();
056    }
057}