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

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

import hep.graphics.heprep.HepRepAttribute;
import hep.graphics.heprep.HepRepAttDef;
import hep.graphics.heprep.HepRepAttValue;
import hep.graphics.heprep.ref.DefaultHepRepAttribute;
import hep.graphics.heprep.ref.DefaultHepRepDefinition;

/**
 *
 * @author Mark Donszelmann
 * @version $Id: HepRepAttributeAdapter.java,v 1.4 2004/07/30 22:32:13 duns Exp $
 */
// NOTE we inherit here from Definition to make sure we can also use this AttributeAdapter for the DefinitionAdapter.
public abstract class HepRepAttributeAdapter extends DefaultHepRepDefinition {

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

    public HepRepAttributeAdapter(hep.graphics.heprep1.HepRepAttribute attribute) {
        this(null, attribute);
    }
    
    public HepRepAttributeAdapter(hep.graphics.heprep1.HepRepAttribute parentAttribute, hep.graphics.heprep1.HepRepAttribute attribute) {
        this.parentAttribute = parentAttribute;
        this.attribute = attribute;

        HepRepAdapterFactory factory = HepRepAdapterFactory.getFactory();
        for (Enumeration e=attribute.getAttValues(); e.hasMoreElements(); ) {
            addAttValue(factory.createHepRepAttValue((hep.graphics.heprep1.HepRepAttValue)e.nextElement()));
        }
        if (parentAttribute != null) {
            for (Enumeration e=parentAttribute.getAttValues(); e.hasMoreElements(); ) {
                addAttValue(factory.createHepRepAttValue((hep.graphics.heprep1.HepRepAttValue)e.nextElement()));
            }
        }                    
    }

    // NOTE implemented as null since this is not meant to be an HepRepDefinition.
    public HepRepAttDef getAttDef(String name) {
        return null;
    }
}
