org.apache.flume

## Class Context

- java.lang.Object
- - org.apache.flume.Context

-     public class Context
      extends Object

  The context is a key-value store used to pass configuration information throughout the system.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `Context()`
    `Context(Map<String,String> paramters)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `clear()` Removes all of the mappings from this map.
    `boolean` | `containsKey(String key)` Returns true if this Context contains a mapping for key.
    `Boolean` | `getBoolean(String key)` Gets value mapped to key, returning null if unmapped.
    `Boolean` | `getBoolean(String key, Boolean defaultValue)` Gets value mapped to key, returning defaultValue if unmapped.
    `Integer` | `getInteger(String key)` Gets value mapped to key, returning null if unmapped.
    `Integer` | `getInteger(String key, Integer defaultValue)` Gets value mapped to key, returning defaultValue if unmapped.
    `Long` | `getLong(String key)` Gets value mapped to key, returning null if unmapped.
    `Long` | `getLong(String key, Long defaultValue)` Gets value mapped to key, returning defaultValue if unmapped.
    `com.google.common.collect.ImmutableMap<String,String>` | `getParameters()` Gets a copy of the backing map structure.
    `String` | `getString(String key)` Gets value mapped to key, returning null if unmapped.
    `String` | `getString(String key, String defaultValue)` Gets value mapped to key, returning defaultValue if unmapped.
    `com.google.common.collect.ImmutableMap<String,String>` | `getSubProperties(String prefix)` Get properties which start with a prefix.
    `void` | `put(String key, String value)` Associates the specified value with the specified key in this context.
    `void` | `putAll(Map<String,String> map)` Associates all of the given map's keys and values in the Context.
    `String` | `toString()`

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

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

- - ### Constructor Detail

    - #### Context

          public Context()

    - #### Context

          public Context(Map<String,String> paramters)

  - ### Method Detail

    - #### getParameters

          public com.google.common.collect.ImmutableMap<String,String> getParameters()

      Gets a copy of the backing map structure.
      Returns:
        immutable copy of backing map structure

    - #### clear

          public void clear()

      Removes all of the mappings from this map.

    - #### getSubProperties

          public com.google.common.collect.ImmutableMap<String,String> getSubProperties(String prefix)

      Get properties which start with a prefix. When a property is returned, the prefix is removed the from name. For example, if this method is called with a parameter "hdfs." and the context contains: `{ hdfs.key = value, otherKey = otherValue }` this method will return a map containing: `{ key = value}` Note: The `prefix` must end with a period character. If not this method will raise an IllegalArgumentException.
      Parameters:
        `prefix` - key prefix to find and remove from keys in resulting map
      Returns:
        map with keys which matched prefix with prefix removed from keys in resulting map. If no keys are matched, the returned map is empty
      Throws:
        `IllegalArguemntException` - if the given prefix does not end with a period character.

    - #### putAll

          public void putAll(Map<String,String> map)

      Associates all of the given map's keys and values in the Context.

    - #### put

          public void put(String key,
                 String value)

      Associates the specified value with the specified key in this context. If the context previously contained a mapping for the key, the old value is replaced by the specified value.
      Parameters:
        `key` - key with which the specified value is to be associated
        `value` - to be associated with the specified key

    - #### containsKey

          public boolean containsKey(String key)

      Returns true if this Context contains a mapping for key. Otherwise, returns false.

    - #### getBoolean

          public Boolean getBoolean(String key,
                           Boolean defaultValue)

      Gets value mapped to key, returning defaultValue if unmapped.
      Parameters:
        `key` - to be found
        `defaultValue` - returned if key is unmapped
      Returns:
        value associated with key

    - #### getBoolean

          public Boolean getBoolean(String key)

      Gets value mapped to key, returning null if unmapped.

      Note that this method returns an object as opposed to a primitive. The configuration key requested may not be mapped to a value and by returning the primitive object wrapper we can return null. If the key does not exist the return value of this method is assigned directly to a primitive, a `NullPointerException` will be thrown.

      Parameters:
        `key` - to be found
      Returns:
        value associated with key or null if unmapped

    - #### getInteger

          public Integer getInteger(String key,
                           Integer defaultValue)

      Gets value mapped to key, returning defaultValue if unmapped.
      Parameters:
        `key` - to be found
        `defaultValue` - returned if key is unmapped
      Returns:
        value associated with key

    - #### getInteger

          public Integer getInteger(String key)

      Gets value mapped to key, returning null if unmapped.

      Note that this method returns an object as opposed to a primitive. The configuration key requested may not be mapped to a value and by returning the primitive object wrapper we can return null. If the key does not exist the return value of this method is assigned directly to a primitive, a `NullPointerException` will be thrown.

      Parameters:
        `key` - to be found
      Returns:
        value associated with key or null if unmapped

    - #### getLong

          public Long getLong(String key,
                     Long defaultValue)

      Gets value mapped to key, returning defaultValue if unmapped.
      Parameters:
        `key` - to be found
        `defaultValue` - returned if key is unmapped
      Returns:
        value associated with key

    - #### getLong

          public Long getLong(String key)

      Gets value mapped to key, returning null if unmapped.

      Note that this method returns an object as opposed to a primitive. The configuration key requested may not be mapped to a value and by returning the primitive object wrapper we can return null. If the key does not exist the return value of this method is assigned directly to a primitive, a `NullPointerException` will be thrown.

      Parameters:
        `key` - to be found
      Returns:
        value associated with key or null if unmapped

    - #### getString

          public String getString(String key,
                         String defaultValue)

      Gets value mapped to key, returning defaultValue if unmapped.
      Parameters:
        `key` - to be found
        `defaultValue` - returned if key is unmapped
      Returns:
        value associated with key

    - #### getString

          public String getString(String key)

      Gets value mapped to key, returning null if unmapped.
      Parameters:
        `key` - to be found
      Returns:
        value associated with key or null if unmapped

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

Copyright © 2009-2016 Apache Software Foundation. All Rights Reserved.