net.sf.okapi.common

## Class BaseContext

- java.lang.Object
- - net.sf.okapi.common.BaseContext

- All Implemented Interfaces:
    IContext
  Direct Known Subclasses:
    BatchItemContext, ExecutionContext

      public class BaseContext
      extends java.lang.Object
      implements IContext

  Basic implementation of the `IContext` interface.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `BaseContext()` Creates an empty context.
    `BaseContext(java.util.Map<java.lang.String,java.lang.Object> properties)` Creates a BaseContext object and copy a map of properties.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `clearAnnotations()` Removes all annotations from this context.
    `void` | `clearProperties()` Removes all properties from this context.
    `<A extends IAnnotation> A` | `getAnnotation(java.lang.Class<A> type)` Gets the annotation of a given type for this context.
    `boolean` | `getBoolean(java.lang.String name)` Gets a boolean property of this context.
    `int` | `getInteger(java.lang.String name)` Gets an integer property of this context.
    `java.lang.Object` | `getObject(java.lang.String name)` Gets an object property of this context.
    `java.util.Map<java.lang.String,java.lang.Object>` | `getProperties()` Gets the map of the existing properties for this context.
    `java.lang.String` | `getString(java.lang.String name)` Gets a string property of this context.
    `void` | `removeProperty(java.lang.String name)` Removes a given property from this context.
    `void` | `setAnnotation(IAnnotation annotation)` Sets an annotation for this context.
    `void` | `setBoolean(java.lang.String name, boolean value)` Sets a boolean property for this context.
    `void` | `setInteger(java.lang.String name, int value)` Sets an integer property for this context.
    `void` | `setObject(java.lang.String name, java.lang.Object value)` Sets an object property for this context.
    `void` | `setString(java.lang.String name, java.lang.String value)` Sets a string property for this context.

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

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

- - ### Constructor Detail

    - #### BaseContext

          public BaseContext()

      Creates an empty context.

    - #### BaseContext

          public BaseContext(java.util.Map<java.lang.String,java.lang.Object> properties)

      Creates a BaseContext object and copy a map of properties.
      Parameters:
        `properties` - the map of properties to copy.

  - ### Method Detail

    - #### getString

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

      Description copied from interface: `IContext`
      Gets a string property of this context.
      Specified by:
        `getString` in interface `IContext`
      Parameters:
        `name` - the name of the property to retrieve.
      Returns:
        the value of the property or null if it not defined.

    - #### setString

          public void setString(java.lang.String name,
                       java.lang.String value)

      Description copied from interface: `IContext`
      Sets a string property for this context. If the property is already defined its value will be overwritten.
      Specified by:
        `setString` in interface `IContext`
      Parameters:
        `name` - the name of the property to set.
        `value` - the value to set.

    - #### getBoolean

          public boolean getBoolean(java.lang.String name)

      Description copied from interface: `IContext`
      Gets a boolean property of this context.
      Specified by:
        `getBoolean` in interface `IContext`
      Parameters:
        `name` - the name of the property to retrieve.
      Returns:
        the value of the property or false if it is not defined.

    - #### setBoolean

          public void setBoolean(java.lang.String name,
                        boolean value)

      Description copied from interface: `IContext`
      Sets a boolean property for this context. If the property is already defined its value will be overwritten.
      Specified by:
        `setBoolean` in interface `IContext`
      Parameters:
        `name` - the name of the property to set.
        `value` - the value to set.

    - #### getInteger

          public int getInteger(java.lang.String name)

      Description copied from interface: `IContext`
      Gets an integer property of this context.
      Specified by:
        `getInteger` in interface `IContext`
      Parameters:
        `name` - the name of the property to retrieve.
      Returns:
        the value of the property or 0 if it is not defined.

    - #### setInteger

          public void setInteger(java.lang.String name,
                        int value)

      Description copied from interface: `IContext`
      Sets an integer property for this context. If the property is already defined its value will be overwritten.
      Specified by:
        `setInteger` in interface `IContext`
      Parameters:
        `name` - the name of the property to set.
        `value` - the value to set.

    - #### getObject

          public java.lang.Object getObject(java.lang.String name)

      Description copied from interface: `IContext`
      Gets an object property of this context.
      Specified by:
        `getObject` in interface `IContext`
      Parameters:
        `name` - the name of the property to retrieve.
      Returns:
        the value of the property or null if it is not defined.

    - #### setObject

          public void setObject(java.lang.String name,
                       java.lang.Object value)

      Description copied from interface: `IContext`
      Sets an object property for this context. If the property is already defined its value will be overwritten.
      Specified by:
        `setObject` in interface `IContext`
      Parameters:
        `name` - the name of the property to set.
        `value` - the value to set.

    - #### removeProperty

          public void removeProperty(java.lang.String name)

      Description copied from interface: `IContext`
      Removes a given property from this context. If the property does not exist nothing happens.
      Specified by:
        `removeProperty` in interface `IContext`
      Parameters:
        `name` - the name of the property to remove.

    - #### getProperties

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

      Description copied from interface: `IContext`
      Gets the map of the existing properties for this context.
      Specified by:
        `getProperties` in interface `IContext`
      Returns:
        the map of the properties for this context. May be empty but not null.

    - #### clearProperties

          public void clearProperties()

      Description copied from interface: `IContext`
      Removes all properties from this context.
      Specified by:
        `clearProperties` in interface `IContext`

    - #### getAnnotation

          public <A extends IAnnotation> A getAnnotation(java.lang.Class<A> type)

      Description copied from interface: `IContext`
      Gets the annotation of a given type for this context.
      Specified by:
        `getAnnotation` in interface `IContext`
      Type Parameters:
        `A` - the class type.
      Parameters:
        `type` - the type of the annotation to retrieve.
      Returns:
        the annotation for the given type, or null if it is not defined.

    - #### setAnnotation

          public void setAnnotation(IAnnotation annotation)

      Description copied from interface: `IContext`
      Sets an annotation for this context.
      Specified by:
        `setAnnotation` in interface `IContext`
      Parameters:
        `annotation` - the annotation to set. If one of this type already exists it will be overwritten.

    - #### clearAnnotations

          public void clearAnnotations()

      Description copied from interface: `IContext`
      Removes all annotations from this context.
      Specified by:
        `clearAnnotations` in interface `IContext`