/* Generated by Together */

package cobalt.deployment.descriptor.xml;

import java.util.Iterator;
import java.io.File;
import java.io.FileOutputStream;
import java.io.BufferedOutputStream;
import java.io.IOException;

import org.w3c.dom.Node;
import org.apache.xerces.dom.NodeImpl;
import org.w3c.dom.Element;
import org.apache.xerces.dom.ElementImpl;
import org.w3c.dom.Document;
import org.apache.xerces.dom.DocumentImpl;

import cobalt.deployment.descriptor.*;
import cobalt.deployment.util.XmlUtil;

/**
 * Title:        Application client xml
 * Description:  J2EE standard application client xml description
 * Copyright:    Copyright (c) 2001
 * Company:      ETRI
 * @author YeonJun Choi
 * @version 1.0
 */

public class ApplicationClientNode extends ElementNode {
	public ApplicationClientNode(Document doc) {
        super((DocumentImpl)doc, "application-client");
    }
    public ApplicationDescriptor getDescriptor() {
        return null;
    }
    public void setDescriptor(ApplicationClientDescriptor descriptor) {
        Document doc = getOwnerDocument();
        XmlUtil.appendApplicationDescriptorNode((DocumentImpl)doc, this, descriptor);
        XmlUtil.appendEnvDescriptorNode((DocumentImpl)doc, this, descriptor.getEnvs().iterator());
        XmlUtil.appendEjbReferenceNode((DocumentImpl)doc, this, descriptor.getEjbReferences().values().iterator());
        XmlUtil.appendResourceReferenceDescriptorNode((DocumentImpl)doc, this, descriptor.getResources().iterator());

    }

    public void writeNodeToFile(File file) throws IOException {
		BufferedOutputStream fos = new BufferedOutputStream(new FileOutputStream(file));
		fos.write(getXmlString().getBytes());
        fos.close();
    }
}
