/*
 * (C) Copyright IBM Corp. 1997-1998  All rights reserved.
 *
 * US Government Users Restricted Rights Use, duplication or
 * disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
 *
 * The program is provided "as is" without any warranty express or
 * implied, including the warranty of non-infringement and the implied
 * warranties of merchantibility and fitness for a particular purpose.
 * IBM will not be liable for any damages suffered by you as a result
 * of using the Program. In no event will IBM be liable for any
 * special, indirect or consequential damages or lost profits even if
 * IBM has been advised of the possibility of their occurrence. IBM
 * will not be liable for any third party claims against you.
 */

package com.ibm.xml.parser;

import org.w3c.dom.*;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.io.UnsupportedEncodingException;

/**
 * The TXComment class implements the Comment interface as defined by the Document Object Model (DOM).
 * <p>A TXComment Node represents the content of a comment, i.e. all the characters between the 
 * starting <CODE>&apos;&lt;!--&apos;</CODE> and ending <CODE>&apos;--&gt;&apos;</CODE>. 
 *
 * @version 1.1
 * @author TAMURA Kent &lt;kent@trl.ibm.co.jp&gt;
 * @see org.w3c.dom.Comment
 * @see com.ibm.xml.parser.Child
 */
public class TXComment extends Child implements Comment {
    
            String  data    =   null;
    
    /**
     * Constructor.
     * @param data      The actual content of the Comment Node.
     */
    public TXComment(String data) {
        this.data = data;
    }

    /**
     * Clone this Comment Node using the appropriate factory.  
     * <p>This method is defined by Child.
     * @return          Cloned Comment Node.
     * @see com.ibm.xml.parser.Child#clone
     */
    public synchronized Object clone() {
        checkFactory();
        TXComment comm = factory.createComment(this.data);
        comm.setFactory(getFactory());
        return comm;
    }
    
    /**
     * Returns that this object is a Comment Node. 
     * <p>This method is defined by DOM.
     * @return          Comment Node indicator.
     */
    public int getNodeType() {
        return Node.COMMENT;
    }
    
    /**
     * Returns the actual content of the Comment Node.
     * @return          The actual content of the Comment Node, or <var>null</var> if no data.
     * @see #setData         
     */
    public String getData() {
        return this.data;
    }

    /**
     * Sets the actual content of the Comment Node.
     * @param data      The actual content of the Comment Node.
     * @see #getData         
     */
    public void setData(String data) {
        this.data = data;
        clearDigest();
    }

    /**
     * Return all text associated with this Node without considering entities.                                           
     * <p>This method is defined by Child.
     * @return          Always returns <var>""</var>.
     * @see com.ibm.xml.parser.Child#toString
     */
    public String getText() {
        return "";
    }
}
