groovy.lang

## Class Binding

- java.lang.Object
- - groovy.lang.GroovyObjectSupport
  - - groovy.lang.Binding

- All Implemented Interfaces:
    GroovyObject
  Direct Known Subclasses:
    FactoryBuilderSupport, ServletBinding

      public class Binding
      extends GroovyObjectSupport

  Represents the variable bindings of a script which can be altered from outside the script object or created outside of a script and passed into it.

  Binding instances are not supposed to be used in a multi-threaded context.

  Version:
    $Revision$
  Author:
    James Strachan

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `Binding()`
    `Binding(Map variables)`
    `Binding(String[] args)` A helper constructor used in main(String[]) method calls

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `Object` | `getProperty(String property)` Overloaded to make variables appear as bean properties or via the subscript operator
    `Object` | `getVariable(String name)`
    `Map` | `getVariables()`
    `boolean` | `hasVariable(String name)` Simple check for whether the binding contains a particular variable or not.
    `void` | `setProperty(String property, Object newValue)` Overloaded to make variables appear as bean properties or via the subscript operator
    `void` | `setVariable(String name, Object value)` Sets the value of the given variable

    - ### Methods inherited from class groovy.lang.GroovyObjectSupport

      `getMetaClass, invokeMethod, setMetaClass`

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

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

- - ### Constructor Detail

    - #### Binding

          public Binding()

    - #### Binding

          public Binding(Map variables)

    - #### Binding

          public Binding(String[] args)

      A helper constructor used in main(String[]) method calls
      Parameters:
        `args` - are the command line arguments from a main()

  - ### Method Detail

    - #### getVariable

          public Object getVariable(String name)

      Parameters:
        `name` - the name of the variable to lookup
      Returns:
        the variable value

    - #### setVariable

          public void setVariable(String name,
                         Object value)

      Sets the value of the given variable
      Parameters:
        `name` - the name of the variable to set
        `value` - the new value for the given variable

    - #### hasVariable

          public boolean hasVariable(String name)

      Simple check for whether the binding contains a particular variable or not.
      Parameters:
        `name` - the name of the variable to check for

    - #### getVariables

          public Map getVariables()

    - #### getProperty

          public Object getProperty(String property)

      Overloaded to make variables appear as bean properties or via the subscript operator
      Specified by:
        `getProperty` in interface `GroovyObject`
      Overrides:
        `getProperty` in class `GroovyObjectSupport`
      Parameters:
        `property` - the name of the property of interest
      Returns:
        the given property

    - #### setProperty

          public void setProperty(String property,
                         Object newValue)

      Overloaded to make variables appear as bean properties or via the subscript operator
      Specified by:
        `setProperty` in interface `GroovyObject`
      Overrides:
        `setProperty` in class `GroovyObjectSupport`
      Parameters:
        `property` - the name of the property of interest
        `newValue` - the new value for the property