Comment.java 2.31 KB
/*
 * Decompiled with CFR 0_118.
 */
package com.adobe.xfa;

import com.adobe.xfa.*;
import com.adobe.xfa.ut.ExFull;
import com.adobe.xfa.ut.ResId;

import java.io.IOException;
import java.io.OutputStream;

public final class Comment
extends Node {
    private static final String mClassName = "comment";
    private final String mComment;
    private final Document mDoc;

    Comment(Document doc, String comment) {
        super(null, null);
        this.mComment = comment;
        this.mDoc = doc;
        if (doc != null) {
            this.mDoc.appendChild(this);
        }
    }

    public Comment(Element parent, Node prevSibling, String comment) {
        super(parent, prevSibling);
        this.mComment = comment;
        this.mDoc = null;
    }

    @Override
    public Node clone(Element parent) {
        if (parent != null) {
            return new Comment(parent, parent.getLastXMLChild(), this.mComment);
        }
        return new Comment(null, null, this.mComment);
    }

    @Override
    public String getClassAtom() {
        return "comment";
    }

    @Override
    public String getClassName() {
        return "comment";
    }

    @Override
    public String getData() {
        return this.mComment;
    }

    @Override
    public String getName() {
        return "#comment";
    }

    @Override
    public boolean isLeaf() {
        return true;
    }

    @Override
    public void postSave() {
    }

    @Override
    public void preSave(boolean bSaveXMLScript) {
    }

    @Override
    public void serialize(OutputStream outStream, DOMSaveOptions options, int level, Node prevSibling) throws IOException {
        if (level != 0 || prevSibling != null) {
            if (options.getDisplayFormat() == 2) {
                options.writeIndent(outStream, level);
            } else if (level == 0 && (options.getFormatOutside() || options.getDisplayFormat() == 1)) {
                outStream.write(Document.MarkupReturn);
            }
        }
        outStream.write(Document.MarkupCommentStart);
        String sValue = this.getData();
        outStream.write(sValue.getBytes("UTF-8"));
        outStream.write(Document.MarkupCommentEnd);
    }

    public void setScriptProperty(String sPropertyName, Arg propertyValue) {
        throw new ExFull(ResId.UNSUPPORTED_OPERATION, "Comment#setScriptProperty");
    }
}