/* JFox, the OpenSource J2EE Application Server
 *
 * Distributable under GNU LGPL license by gun.org
 * more details please visit http://www.huihoo.org/jfox
 */

package org.jfox.framework.deploy;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.jfox.framework.util.XmlUtils;
import org.w3c.dom.Element;
import org.w3c.dom.Node;

/**
 * @author <a href="mailto:young_yy@hotmail.com">Young Yang</a>
 */

public class PropertyDescriptor implements Descriptor {
    private List params = new ArrayList();
    private String name = "";

    public void processXML(Node node) throws ComponentDescriptionException {
        setName(XmlUtils.getAtrributeValueOf(node, "name"));
        Iterator paramDescriptors = XmlUtils.getElementsByTagName((Element) node, "param");
        while(paramDescriptors.hasNext()) {
            Element paramElement = (Element) paramDescriptors.next();
            ParameterDescriptor pd = new ParameterDescriptor();
            pd.processXML(paramElement);
            addParamDescriptor(pd);
        }
    }

    private void addParamDescriptor(ParameterDescriptor pd) {
        params.add(pd);
    }

    public ParameterDescriptor[] getParamDescriptors() {
        return (ParameterDescriptor[]) params.toArray(new ParameterDescriptor[params.size()]);
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public static void main(String[] args) {

    }
}

