// Copyright 2004, FreeHEP.
package hep.graphics.heprep1.adapter;

import java.awt.*;
import java.util.*;

import hep.graphics.heprep.HepRepAttDef;
import hep.graphics.heprep.HepRepDefinition;

/**
 *
 * @author Mark Donszelmann
 * @version $Id: HepRepDefinitionAdapter.java,v 1.3 2004/07/30 14:51:52 duns Exp $
 */
public abstract class HepRepDefinitionAdapter extends HepRepAttributeAdapter implements HepRepDefinition {

    private hep.graphics.heprep1.HepRepAttribute parentAttribute;
    private hep.graphics.heprep1.HepRepAttribute attribute;

    public HepRepDefinitionAdapter(hep.graphics.heprep1.HepRepAttribute attribute) {
        this(null, attribute);
    }

    public HepRepDefinitionAdapter(hep.graphics.heprep1.HepRepAttribute parentAttribute, hep.graphics.heprep1.HepRepAttribute attribute) {
        super(parentAttribute, attribute);
        this.parentAttribute = parentAttribute;
        this.attribute = attribute;

        HepRepAdapterFactory factory = HepRepAdapterFactory.getFactory();
        for (Enumeration e=attribute.getAttDefs(); e.hasMoreElements(); ) {
            addAttDef(factory.createHepRepAttDef((hep.graphics.heprep1.HepRepAttDef)e.nextElement()));
        }
        if (parentAttribute != null) {
            for (Enumeration e=parentAttribute.getAttDefs(); e.hasMoreElements(); ) {
                addAttDef(factory.createHepRepAttDef((hep.graphics.heprep1.HepRepAttDef)e.nextElement()));
            }
        }  
    }
        
    public abstract HepRepAttDef getAttDef(String name);
}