Java Code

Events are identified in the system by their names as specified by the value attribute of the event-class and event-type elements. However simply using text in application code to reference events would be error prone. In particular, an event is fully identified by its type as well as its class. Thus, using string literals to reference an event could be ambiguous, as an event type is only unique when qualified by its associated event class.

Below is an example of the generated constants file for an event class, the class name is the same as the event class, the attributes are the event types. This prevents the use of incompatible values.

Figure 1. Generated event Java constants
package curam.util.testmodel.events;
  /**
   * Generated EVENT_CLASS_ONE events file.
   * Some event class.
   *
   */
  public final class EVENT_CLASS_ONE {

    /** Some event type. */
    public static final
      curam.util.events.struct.EventKey EVENT_TYPE_ONE
        = new curam.util.events.struct.EventKey();

    static {
      EVENT_TYPE_ONE.eventClass = "CLASS1";
      EVENT_TYPE_ONE.eventType = "EVENT1";
    }

    /** Another event type. */
    public static final
      curam.util.events.struct.EventKey EVENT_TYPE_TWO
        = new curam.util.events.struct.EventKey();

    static {
      EVENT_TYPE_TWO.eventClass = "CLASS1";
      EVENT_TYPE_TWO.eventType = "EVENT2";
    }
  }