// **********************************************************************
//
// Generated by the ORBacus IDL to Java Translator
//
// Copyright (c) 2000
// Object Oriented Concepts, Inc.
// Billerica, MA, USA
//
// All Rights Reserved
//
// **********************************************************************

// Version: 4.0.3

package edu.sc.seis.sod.model.event;

import edu.sc.seis.sod.model.common.ParameterRef;
import edu.sc.seis.sod.model.common.ParameterRefUtil;

//
// IDL:iris.edu/Fissures/IfEvent/EventAttr:1.0
//
/***/

public class EventAttrImpl  {
    
    /** The name of the event. There is no required format, however
     *it should be intelligible to a human. For most events
     *something like a stingified origin time and/or location
     *is acceptible, larger events with well-known names in the
     *literature may have more descriptive names such as Loma 
     *Prieta or Northridge.Uniqueness is not required, but 
     *is desirible. */

    public String name;

    //
    // IDL:iris.edu/Fissures/IfEvent/EventAttr/region:1.0
    //
    /** The Flinn Engdahl region that this earthquake occurs in.
     *Note that due to multiple Origins for a singe Event, there
     *may be more than one region that could be said to contain
     *the Event. Thus the region is informative, but should not
     *be considered definative.*/

    public FlinnEngdahlRegion region;

    //
    // IDL:iris.edu/Fissures/IfEvent/EventAttr/parm_ids:1.0
    //
    /** Ids for parameters that are associated with this event.*/

    public ParameterRef[] parm_ids;
    
    public EventAttrImpl(String name) {
        this(name,
             new FlinnEngdahlRegion(FlinnEngdahlType.GEOGRAPHIC_REGION, 0));
    }

    public EventAttrImpl(String name, FlinnEngdahlRegion region) {
        this(name, region, new ParameterRef[0]);
    }

    public EventAttrImpl(String name,
                         FlinnEngdahlRegion region,
                         ParameterRef[] params) {
        this.name = name;
        this.region = region;
        this.parm_ids = params;
    }

    protected EventAttrImpl() {
        this.parm_ids = new ParameterRef[0];
    }

    /** Only for use for CORBA object serialization. */
    public static EventAttrImpl createEmpty() {
        return new EventAttrImpl();
    }

    public int hashCode(){
        int result = 87;
        result = result*34 + name.hashCode();
        result = result*34 + region.hashCode();
        for (int i = 0; i < parm_ids.length; i++) {
            result += result *34 + ParameterRefUtil.hash(parm_ids[i]);
        }
        return result;
    }

    public boolean equals(Object o) {
        if(o == this){ return true; }
        else if(o instanceof EventAttrImpl){
            EventAttrImpl oAttr = (EventAttrImpl)o;
            if(oAttr.name.equals(name) &&
               region.equals(oAttr.region) &&
               ParameterRefUtil.areEqual(parm_ids, oAttr.parm_ids)){
                return true;
            }
        }
        return false;
    }

    public FlinnEngdahlRegion getRegion() { return region; }

    public String getName() { return name; }
}
