com.ibm.openpages.api.trigger

## Class AbstractEventHandler

- java.lang.Object
- - com.ibm.openpages.api.trigger.AbstractEventHandler

- Direct Known Subclasses:
    DefaultEventHandler

      public abstract class AbstractEventHandler
      extends java.lang.Object

  Base abstract class for event handlers. Most event handlers should extend `DefaultEventHandler`. One or more event handlers can be configured per Rule.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractEventHandler()` Default constructor
    `AbstractEventHandler(java.util.Map<java.lang.String,java.lang.String> attributes)` Constructor with the Map of all attributes of the event handler.

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.util.HashMap<java.lang.String,java.lang.String>` | `getAttributes()` Returns a Map containing the event handler's attributes and their values.
    `java.util.HashMap<java.lang.String,java.lang.String>` | `getRuleAttributes()` Returns a Map containing rule attributes and their values.
    `abstract boolean` | `handleEvent(AbstractEvent event)` Abstract method to handle an event.
    `void` | `setAttributes(java.util.HashMap<java.lang.String,java.lang.String> attributes)` Sets the Map of all attributes of the event handler.
    `void` | `setRuleAttributes(java.util.HashMap<java.lang.String,java.lang.String> ruleAttributes)` Sets the attributes from rule containing this event handler, for the event handler to access.
    `void` | `throwException(java.lang.String message, java.util.List<java.lang.Object> parameters, java.lang.Throwable cause, Context apiContext)` Allows the trigger to throw a formatted exception object and stop the execution of the current operation.

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### AbstractEventHandler

          public AbstractEventHandler()

      Default constructor

    - #### AbstractEventHandler

          public AbstractEventHandler(java.util.Map<java.lang.String,java.lang.String> attributes)

      Constructor with the Map of all attributes of the event handler.
      Parameters:
        `attributes` - a Map of attributes that provide configuration to the Event Handler

  - ### Method Detail

    - #### handleEvent

          public abstract boolean handleEvent(AbstractEvent event)
                                       throws java.lang.Exception

      Abstract method to handle an event. Definition of this method is specific to the event handler implementations.
      Parameters:
        `event` - the event for the event handler to handle
      Returns:
        true if the event was handled successfully
      Throws:
        `java.lang.Exception`

    - #### setAttributes

          public void setAttributes(java.util.HashMap<java.lang.String,java.lang.String> attributes)

      Sets the Map of all attributes of the event handler. The definition of what attributes are used by the event handler is specific to the event handler implementations.
      Parameters:
        `attributes` - a Map of attributes that provide configuration to the event handler

    - #### getAttributes

          public java.util.HashMap<java.lang.String,java.lang.String> getAttributes()

      Returns a Map containing the event handler's attributes and their values.
      Returns:
        a Map of event handler attributes.

    - #### getRuleAttributes

          public java.util.HashMap<java.lang.String,java.lang.String> getRuleAttributes()

      Returns a Map containing rule attributes and their values.
      Returns:
        a Map of rule attributes

    - #### setRuleAttributes

          public void setRuleAttributes(java.util.HashMap<java.lang.String,java.lang.String> ruleAttributes)

      Sets the attributes from rule containing this event handler, for the event handler to access.
      Parameters:
        `ruleAttributes` - a Map of attributes that provide configuration to rule, which can be used by the event handler

    - #### throwException

          public void throwException(java.lang.String message,
                                     java.util.List<java.lang.Object> parameters,
                                     java.lang.Throwable cause,
                                     Context apiContext)
                              throws GRCTriggerException

      Allows the trigger to throw a formatted exception object and stop the execution of the current operation. For the trigger exception message to be displayed in the UI front-end, it must be thrown in PRE position event handler.
      Parameters:
        `message` - (required) an application text key (e.g. "com.triggers.ext.MyMessage") or a string containing error message text "My Error Message". Parameters may be specified with braces surrounding the index of the parameter, such as "{0}, {1}, {2}...". See java.text.MessageFormat.
        `parameters` - (optional) a list containing objects to pass as message parameters. If a list is not specified, you can provide java.util.Collections.EMPTY_LIST.
        `cause` - (optional) original exception that caused the trigger to error.
        `apiContext` - (required) API context
      Throws:
        `GRCTriggerException`
      See Also:
        `java.text.MessageFormat, java.util.Collections#EMPTY_LIST`

Licensed Materials - Property of IBM
OpenPages with Watson (PID: 5725-D51)
© Copyright IBM Corporation 2013, 2022. All Rights Reserved.
US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.