groovy.lang
public class: Binding [javadoc |
source]
java.lang.Object
groovy.lang.GroovyObjectSupport
groovy.lang.Binding
All Implemented Interfaces:
GroovyObject
Direct Known Subclasses:
ObjectGraphBuilder, ServletBinding, FactoryBuilderSupport
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.
- author:
< - a href="mailto:james@coredevelopers.net">James Strachan
- version:
$ - Revision: 14401 $
| Method from groovy.lang.Binding Detail: |
public Object getProperty(String property) {
/** @todo we should check if we have the property with the metaClass instead of try/catch */
try {
return super.getProperty(property);
}
catch (MissingPropertyException e) {
return getVariable(property);
}
}
Overloaded to make variables appear as bean properties or via the subscript operator |
public Object getVariable(String name) {
if (variables == null)
throw new MissingPropertyException(name, this.getClass());
Object result = variables.get(name);
if (result == null && !variables.containsKey(name)) {
throw new MissingPropertyException(name, this.getClass());
}
return result;
}
|
public Map getVariables() {
if (variables == null)
variables = new LinkedHashMap();
return variables;
}
|
public void setProperty(String property,
Object newValue) {
/** @todo we should check if we have the property with the metaClass instead of try/catch */
try {
super.setProperty(property, newValue);
}
catch (MissingPropertyException e) {
setVariable(property, newValue);
}
}
Overloaded to make variables appear as bean properties or via the subscript operator |
public void setVariable(String name,
Object value) {
if (variables == null)
variables = new LinkedHashMap();
variables.put(name, value);
}
Sets the value of the given variable |