Package org.apache.tapestry5

## Interface EventContext

- All Known Implementing Classes:
    `AbstractEventContext`, `ArrayEventContext`, `EmptyEventContext`, `URLEventContext`

      public interface EventContext

  A collection of parameters that may eventually be passed to an event handler method. Includes the ability to coerce or encode parameters as needed.
  See Also:
    `TypeCoercer`, `ValueEncoder`

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `<T> T` | `get​(java.lang.Class<T> desiredType, int index)` | Extracts a parameter value and coerces or decodes it to the desired type.
    `int` | `getCount()` | Returns the number of parameter values that can be extracted.
    `boolean` | `isEmpty()` | Returns `true` if this context contains no elements.
    `java.lang.String[]` | `toStrings()` | Extracts the value of each context value as a string.
    `<T> java.util.Optional<T>` | `tryGet​(java.lang.Class<T> desiredType, int index)` | Tries to extract a parameter value and coerces or decodes it to the desired type.

- - ### Method Detail

    - #### getCount

          int getCount()

      Returns the number of parameter values that can be extracted.

    - #### isEmpty

          boolean isEmpty()

      Returns `true` if this context contains no elements.
      Since:
        5.8.2

    - #### get

          <T> T get​(java.lang.Class<T> desiredType,
                    int index)

      Extracts a parameter value and coerces or decodes it to the desired type.
      Parameters:
        `desiredType` - the type of value required
        `index` - identifies which parameter value to extract
      Returns:
        the value extracted and converted or coerced
      Throws:
        `java.lang.RuntimeException` - if the value can't be converted or the index is out of range

    - #### tryGet

          <T> java.util.Optional<T> tryGet​(java.lang.Class<T> desiredType,
                                           int index)

      Tries to extract a parameter value and coerces or decodes it to the desired type.
      Parameters:
        `desiredType` - the type of value required
        `index` - identifies which parameter value to extract
      Returns:
        the value extracted and converted or coerced, wrapped in an Optional, or `Optional.empty()` if index is out of bounds, or the value can't be converted.
      Since:
        5.8.2

    - #### toStrings

          java.lang.String[] toStrings()

      Extracts the value of each context value as a string.
      Returns:
        context values
      Since:
        5.2.0