Groovy Documentation

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(java.util.Map variables)

Binding(java.lang.String[] args)

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

 
Method Summary
java.lang.Object getProperty(java.lang.String property)

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

java.lang.Object getVariable(java.lang.String name)

@param name the name of the variable to lookup

java.util.Map getVariables()

boolean hasVariable(java.lang.String name)

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

void setProperty(java.lang.String property, java.lang.Object newValue)

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

void setVariable(java.lang.String name, java.lang.Object value)

Sets the value of the given variable

 
Methods inherited from class GroovyObjectSupport
getMetaClass, getProperty, invokeMethod, setMetaClass, setProperty
 
Methods inherited from class java.lang.Object
java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()
 

Constructor Detail

Binding

public Binding()


Binding

public Binding(java.util.Map variables)


Binding

public Binding(java.lang.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 java.lang.Object getProperty(java.lang.String property)
Overloaded to make variables appear as bean properties or via the subscript operator


getVariable

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


getVariables

public java.util.Map getVariables()


hasVariable

public boolean hasVariable(java.lang.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(java.lang.String property, java.lang.Object newValue)
todo:
we should check if we have the property with the metaClass instead of try/catch


setVariable

public void setVariable(java.lang.String name, java.lang.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


 

Groovy Documentation