org.springframework.batch.item

## Class ExecutionContext

- java.lang.Object
- - org.springframework.batch.item.ExecutionContext

- All Implemented Interfaces:
    java.io.Serializable

      public class ExecutionContext
      extends java.lang.Object
      implements java.io.Serializable

  Object representing a context for an `ItemStream`. It is a thin wrapper for a map that allows optionally for type safety on reads. It also allows for dirty checking by setting a 'dirty' flag whenever any put is called. Note that putting `null` value is equivalent to removing the entry for the given key.
  Author:
    Lucas Ward, Douglas Kaminsky
  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ExecutionContext()` Default constructor.
    `ExecutionContext(ExecutionContext executionContext)`
    `ExecutionContext(java.util.Map<java.lang.String,java.lang.Object> map)` Initializes a new execution context with the contents of another map.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `clearDirtyFlag()` Clears the dirty flag.
    `boolean` | `containsKey(java.lang.String key)` Indicates whether or not a key is represented in this context.
    `boolean` | `containsValue(java.lang.Object value)` Indicates whether or not a value is represented in this context.
    `java.util.Set<java.util.Map.Entry<java.lang.String,java.lang.Object>>` | `entrySet()` Returns the entry set containing the contents of this context.
    `boolean` | `equals(java.lang.Object obj)`
    `java.lang.Object` | `get(java.lang.String key)` Getter for the value represented by the provided key.
    `double` | `getDouble(java.lang.String key)` Typesafe Getter for the Double represented by the provided key.
    `double` | `getDouble(java.lang.String key, double defaultDouble)` Typesafe Getter for the Double represented by the provided key with default value to return if key is not represented.
    `int` | `getInt(java.lang.String key)` Typesafe Getter for the Integer represented by the provided key.
    `int` | `getInt(java.lang.String key, int defaultInt)` Typesafe Getter for the Integer represented by the provided key with default value to return if key is not represented.
    `long` | `getLong(java.lang.String key)` Typesafe Getter for the Long represented by the provided key.
    `long` | `getLong(java.lang.String key, long defaultLong)` Typesafe Getter for the Long represented by the provided key with default value to return if key is not represented.
    `java.lang.String` | `getString(java.lang.String key)` Typesafe Getter for the String represented by the provided key.
    `java.lang.String` | `getString(java.lang.String key, java.lang.String defaultString)` Typesafe Getter for the String represented by the provided key with default value to return if key is not represented.
    `int` | `hashCode()`
    `boolean` | `isDirty()` Indicates if context has been changed with a "put" operation since the dirty flag was last cleared.
    `boolean` | `isEmpty()` Indicates whether or not the context is empty.
    `void` | `put(java.lang.String key, java.lang.Object value)` Add an Object value to the context.
    `void` | `putDouble(java.lang.String key, double value)` Add a Double value to the context.
    `void` | `putInt(java.lang.String key, int value)` Adds an Integer value to the context.
    `void` | `putLong(java.lang.String key, long value)` Adds a Long value to the context.
    `void` | `putString(java.lang.String key, java.lang.String value)` Adds a String value to the context.
    `java.lang.Object` | `remove(java.lang.String key)` Removes the mapping for a key from this context if it is present.
    `int` | `size()` Returns number of entries in the context
    `java.lang.String` | `toString()`

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

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### ExecutionContext

          public ExecutionContext()

      Default constructor. Initializes a new execution context with an empty internal map.

    - #### ExecutionContext

          public ExecutionContext(java.util.Map<java.lang.String,java.lang.Object> map)

      Initializes a new execution context with the contents of another map.
      Parameters:
        `map` - Initial contents of context.

    - #### ExecutionContext

          public ExecutionContext(ExecutionContext executionContext)

      Parameters:
        `executionContext` -

  - ### Method Detail

    - #### putString

          public void putString(java.lang.String key,
                                java.lang.String value)

      Adds a String value to the context.
      Parameters:
        `key` - Key to add to context
        `value` - Value to associate with key

    - #### putLong

          public void putLong(java.lang.String key,
                              long value)

      Adds a Long value to the context.
      Parameters:
        `key` - Key to add to context
        `value` - Value to associate with key

    - #### putInt

          public void putInt(java.lang.String key,
                             int value)

      Adds an Integer value to the context.
      Parameters:
        `key` - Key to add to context
        `value` - Value to associate with key

    - #### putDouble

          public void putDouble(java.lang.String key,
                                double value)

      Add a Double value to the context.
      Parameters:
        `key` - Key to add to context
        `value` - Value to associate with key

    - #### put

          public void put(java.lang.String key,
                          java.lang.Object value)

      Add an Object value to the context. Putting `null` value for a given key removes the key.
      Parameters:
        `key` - Key to add to context
        `value` - Value to associate with key

    - #### isDirty

          public boolean isDirty()

      Indicates if context has been changed with a "put" operation since the dirty flag was last cleared. Note that the last time the flag was cleared might correspond to creation of the context.
      Returns:
        True if "put" operation has occurred since flag was last cleared

    - #### getString

          public java.lang.String getString(java.lang.String key)

      Typesafe Getter for the String represented by the provided key.
      Parameters:
        `key` - The key to get a value for
      Returns:
        The `String` value

    - #### getString

          public java.lang.String getString(java.lang.String key,
                                            java.lang.String defaultString)

      Typesafe Getter for the String represented by the provided key with default value to return if key is not represented.
      Parameters:
        `key` - The key to get a value for
        `defaultString` - Default to return if key is not represented
      Returns:
        The `String` value if key is represented, specified default otherwise

    - #### getLong

          public long getLong(java.lang.String key)

      Typesafe Getter for the Long represented by the provided key.
      Parameters:
        `key` - The key to get a value for
      Returns:
        The `Long` value

    - #### getLong

          public long getLong(java.lang.String key,
                              long defaultLong)

      Typesafe Getter for the Long represented by the provided key with default value to return if key is not represented.
      Parameters:
        `key` - The key to get a value for
        `defaultLong` - Default to return if key is not represented
      Returns:
        The `long` value if key is represented, specified default otherwise

    - #### getInt

          public int getInt(java.lang.String key)

      Typesafe Getter for the Integer represented by the provided key.
      Parameters:
        `key` - The key to get a value for
      Returns:
        The `Integer` value

    - #### getInt

          public int getInt(java.lang.String key,
                            int defaultInt)

      Typesafe Getter for the Integer represented by the provided key with default value to return if key is not represented.
      Parameters:
        `key` - The key to get a value for
        `defaultInt` - Default to return if key is not represented
      Returns:
        The `int` value if key is represented, specified default otherwise

    - #### getDouble

          public double getDouble(java.lang.String key)

      Typesafe Getter for the Double represented by the provided key.
      Parameters:
        `key` - The key to get a value for
      Returns:
        The `Double` value

    - #### getDouble

          public double getDouble(java.lang.String key,
                                  double defaultDouble)

      Typesafe Getter for the Double represented by the provided key with default value to return if key is not represented.
      Parameters:
        `key` - The key to get a value for
        `defaultDouble` - Default to return if key is not represented
      Returns:
        The `double` value if key is represented, specified default otherwise

    - #### get

          public java.lang.Object get(java.lang.String key)

      Getter for the value represented by the provided key.
      Parameters:
        `key` - The key to get a value for
      Returns:
        The value represented by the given key

    - #### isEmpty

          public boolean isEmpty()

      Indicates whether or not the context is empty.
      Returns:
        True if the context has no entries, false otherwise.
      See Also:
        `Map.isEmpty()`

    - #### clearDirtyFlag

          public void clearDirtyFlag()

      Clears the dirty flag.

    - #### entrySet

          public java.util.Set<java.util.Map.Entry<java.lang.String,java.lang.Object>> entrySet()

      Returns the entry set containing the contents of this context.
      Returns:
        A set representing the contents of the context
      See Also:
        `Map.entrySet()`

    - #### containsKey

          public boolean containsKey(java.lang.String key)

      Indicates whether or not a key is represented in this context.
      Parameters:
        `key` - Key to check existence for
      Returns:
        True if key is represented in context, false otherwise
      See Also:
        `Map.containsKey(Object)`

    - #### remove

          public java.lang.Object remove(java.lang.String key)

      Removes the mapping for a key from this context if it is present.
      See Also:
        `Map.remove(Object)`

    - #### containsValue

          public boolean containsValue(java.lang.Object value)

      Indicates whether or not a value is represented in this context.
      Parameters:
        `value` - Value to check existence for
      Returns:
        True if value is represented in context, false otherwise
      See Also:
        `Map.containsValue(Object)`

    - #### equals

          public boolean equals(java.lang.Object obj)

      Overrides:
        `equals` in class `java.lang.Object`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `java.lang.Object`

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`

    - #### size

          public int size()

      Returns number of entries in the context
      Returns:
        Number of entries in the context
      See Also:
        `Map.size()`