
package de.nightspawn.lmxp;

import java.util.*;

/**
    this class represents a data node in an XML Tree
 */
public class LMXPDataNode extends LMXPNode {

    private                 String                  Data;

    /**
        create a new empty DataNode
     */
    public LMXPDataNode() {
    }
    
    /**
        create a new empty DataNode with a parent
     */
    public LMXPDataNode(LMXPNode parent) {
        super(parent,"CDATA");
    }
    
    /**
        create a new DataNode with some data
     */
    public LMXPDataNode(String data) {
        setValue(data);
    }

    /**
        overwrite the closeNode method for we don't want to
        trim the value
     */
    public LMXPNode closeNode() {
        return this.getParent();
    }

    /**
        overwrite the addChild function for data nodes don't have any
     */
    public void addChild(LMXPNode n) {
        return;
    }

    /**
        overwrite the delChild function
     */
    public void delChild(LMXPNode n) {
        return;
    }

    /**
        overwrite the addattribute function
     */
    public void addAttribute(String name, String value) {
        return;
    }

    /**
        overwrite the toXML function
     */
    public String toXML(int id) {
        String xml = new String();
        String pre = LMXPNode.getPre(id);
        xml = xml.concat(pre+"<![CDATA["+this.getValue()+"]]>\n");
        return xml;
    }

     

}
