Groovy 2.2.1

groovy.lang
[Java] Class Binding

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

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 multithreaded context.

Authors:
James Strachan
Version:
\$Revision\$


Constructor Summary
Binding()

Binding(Map variables)

Binding(String[] args)

A helper constructor used in main(String[]) method calls

 
Method Summary
Object getProperty(String property)

Overloaded to make variables appear as bean properties or via the subscript operator

Object getVariable(String name)

@param name the name of the variable to lookup

Map getVariables()

boolean hasVariable(String name)

Simple check for whether the binding contains a particular variable or not.

void setProperty(String property, Object newValue)

@todo we should check if we have the property with the metaClass instead of try/catch

void setVariable(String name, Object value)

Sets the value of the given variable

 
Methods inherited from class GroovyObjectSupport
getMetaClass, getProperty, invokeMethod, setMetaClass, setProperty
 
Methods inherited from class Object
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll
 

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

getProperty

public Object getProperty(String property)
Overloaded to make variables appear as bean properties or via the subscript operator


getVariable

public Object getVariable(String name)
Parameters:
name - the name of the variable to lookup
Returns:
the variable value


getVariables

public Map getVariables()


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


setProperty

public void setProperty(String property, Object newValue)
todo:
we should check if we have the property with the metaClass instead of try/catch


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


 

Copyright © 2003-2013 The Codehaus. All rights reserved.