// Copyright 2000-2003, FreeHEP.
package hep.graphics.heprep.ref;

import java.io.*;
import java.util.*;

import hep.graphics.heprep.*;
import hep.graphics.heprep.util.*;

/**
 *
 * @author M.Donszelmann
 *
 * @version $Id: DefaultHepRepAttDef.java,v 1.17 2004/07/05 22:09:46 duns Exp $
 */

public class DefaultHepRepAttDef implements HepRepAttDef, Serializable {
    public static final String cvsId = "$Id: DefaultHepRepAttDef.java,v 1.17 2004/07/05 22:09:46 duns Exp $";

    private String desc, category, extra;
    private String name;
    private String lowerCaseName;

    public DefaultHepRepAttDef(String name, String desc, String category, String extra) {
        this.name = name.intern();
        this.lowerCaseName = name.toLowerCase().intern();
        this.desc = (desc == null) ? null : desc.intern();
        this.category = (category == null) ? null : category.intern();
        this.extra = (extra == null) ? null : extra.intern();
    }

    public HepRepAttDef copy() throws CloneNotSupportedException {
        return new DefaultHepRepAttDef(name, desc, category, extra);
    }

    void replace(DefaultHepRepAttDef def) {
        name = def.name;
        lowerCaseName = def.lowerCaseName;
        desc = def.desc;
        category = def.category;
        extra = def.extra;
    }

    public String getName() {
        return name;
    }

    public String getLowerCaseName() {
        return lowerCaseName;
    }

    public String getDescription() {
        return desc;
    }

    public String getCategory() {
        return category;
    }

    public String getExtra() {
        return extra;
    }
    
/* Disabled for FREEHEP-386
    public boolean equals(Object o) {
        if (o == this) return true;
        if (o instanceof HepRepAttDef) {
            HepRepAttDef def = (HepRepAttDef)o;
            boolean r = getLowerCaseName().equals(def.getLowerCaseName())
                     && getDescription().equals(def.getDescription())
                     && getCategory().equals(def.getCategory())
                     && getExtra().equals(def.getExtra());
            if (HepRepUtil.debug() && !r) {
                System.out.println(this+" != "+def);
            }
            return r;
        }
        return false;
    }
    
    public int hashCode() {
        return getLowerCaseName().hashCode() + getDescription().hashCode() + getCategory().hashCode() + getExtra().hashCode();
    }
*/
    
    public String toString() {
        return getClass()+" ["+
               "name(lcase)="+getLowerCaseName()+", "+
               "description="+getDescription()+", "+
               "category="+getCategory()+", "+
               "extra="+getExtra()+"]";
    }
}

