本文整理了Java中groovy.lang.Binding.getVariables()
方法的一些代码示例,展示了Binding.getVariables()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Binding.getVariables()
方法的具体详情如下:
包路径:groovy.lang.Binding
类名称:Binding
方法名:getVariables
暂无
代码示例来源:origin: jenkinsci/jenkins
/**
* Sets the binding (the variables available in the scope of the BeanBuilder)
* @param b The Binding instance
*/
public void setBinding(Binding b) {
this.binding = b.getVariables();
}
代码示例来源:origin: org.codehaus.groovy/groovy
private Map doGetVariables() {
return super.getVariables();
}
代码示例来源:origin: org.codehaus.groovy/groovy
public Object getVariable(String name) {
return context.getVariables().get(name);
}
代码示例来源:origin: apache/groovy
@SuppressWarnings("unchecked")
private static void storeBindingVars(ScriptEngine self, Binding binding) {
Set<Map.Entry<?, ?>> vars = binding.getVariables().entrySet();
for (Map.Entry<?, ?> me : vars) {
self.put(me.getKey().toString(), me.getValue());
}
}
代码示例来源:origin: groovy/groovy-core
@Override
public Map getVariables() {
lazyInit();
return super.getVariables();
}
代码示例来源:origin: groovy/groovy-core
@SuppressWarnings("unchecked")
private Map collectParams(HttpServletRequest request) {
Map params = new LinkedHashMap();
for (Enumeration names = request.getParameterNames(); names.hasMoreElements();) {
String name = (String) names.nextElement();
if (!super.getVariables().containsKey(name)) {
String[] values = request.getParameterValues(name);
if (values.length == 1) {
params.put(name, values[0]);
} else {
params.put(name, values);
}
}
}
return params;
}
代码示例来源:origin: org.codehaus.groovy/groovy
private Object invokePropertyOrMissing(Object object, String methodName, Object[] originalArguments, boolean fromInsideClass, boolean isCallToSuper) {
// if no method was found, try to find a closure defined as a field of the class and run it
Object value = null;
final MetaProperty metaProperty = this.getMetaProperty(methodName, false);
if (metaProperty != null)
value = metaProperty.getProperty(object);
else {
if (object instanceof Map)
value = ((Map)object).get(methodName);
}
if (value instanceof Closure) { // This test ensures that value != this If you ever change this ensure that value != this
Closure closure = (Closure) value;
MetaClass delegateMetaClass = closure.getMetaClass();
return delegateMetaClass.invokeMethod(closure.getClass(), closure, CLOSURE_DO_CALL_METHOD, originalArguments, false, fromInsideClass);
}
if (object instanceof Script) {
Object bindingVar = ((Script) object).getBinding().getVariables().get(methodName);
if (bindingVar != null) {
MetaClass bindingVarMC = ((MetaClassRegistryImpl) registry).getMetaClass(bindingVar);
return bindingVarMC.invokeMethod(bindingVar, CLOSURE_CALL_METHOD, originalArguments);
}
}
return invokeMissingMethod(object, methodName, originalArguments, null, isCallToSuper);
}
代码示例来源:origin: org.codehaus.groovy/groovy
Map variables = context.getVariables();
MetaClass mc = getMetaClass(object);
for (Object o : variables.entrySet()) {
代码示例来源:origin: apache/nifi
Map bindings = script.getBinding().getVariables();
代码示例来源:origin: groovy/groovy-core
public void testCreateScriptWithNullClass() {
Script script = InvokerHelper.createScript(null, new Binding(bindingVariables));
assertEquals(bindingVariables, script.getBinding().getVariables());
}
代码示例来源:origin: groovy/groovy-core
public void testCreateScriptWithScriptClass() {
GroovyClassLoader classLoader = new GroovyClassLoader();
String controlProperty = "text";
String controlValue = "I am a script";
String code = controlProperty + " = '" + controlValue + "'";
GroovyCodeSource codeSource = new GroovyCodeSource(code, "testscript", "/groovy/shell");
Class scriptClass = classLoader.parseClass(codeSource, false);
Script script = InvokerHelper.createScript(scriptClass, new Binding(bindingVariables));
assertEquals(bindingVariables, script.getBinding().getVariables());
script.run();
assertEquals(controlValue, script.getProperty(controlProperty));
}
}
代码示例来源:origin: org.codehaus.groovy/groovy-jsr223
@SuppressWarnings("unchecked")
private static void storeBindingVars(ScriptEngine self, Binding binding) {
Set<Map.Entry<?, ?>> vars = binding.getVariables().entrySet();
for (Map.Entry<?, ?> me : vars) {
self.put(me.getKey().toString(), me.getValue());
}
}
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
/**
* Sets the binding (the variables available in the scope of the BeanBuilder)
* @param b The Binding instance
*/
public void setBinding(Binding b) {
this.binding = b.getVariables();
}
代码示例来源:origin: org.jvnet.hudson.main/hudson-core
/**
* Sets the binding (the variables available in the scope of the BeanBuilder)
* @param b The Binding instance
*/
public void setBinding(Binding b) {
this.binding = b.getVariables();
}
代码示例来源:origin: io.snamp/scripting
@SuppressWarnings("unchecked")
@Override
public Map getVariables() {
return ImmutableMap.builder()
.putAll(first.getVariables())
.putAll(second.getVariables())
.build();
}
代码示例来源:origin: Jasig/uPortal
@Override
public Object remove(Object key) {
final String name = (String) key;
if (context.containsBean(name)) {
throw new IllegalArgumentException("Can't remove variable to named '" + name + "'.");
}
return super.getVariables().remove(key);
}
代码示例来源:origin: zycgit/hasor
@SuppressWarnings("unchecked")
private static void storeBindingVars(ScriptEngine self, Binding binding) {
Set<Map.Entry> vars = binding.getVariables().entrySet();
for (Map.Entry me : vars) {
self.put(me.getKey().toString(), me.getValue());
}
}
}
代码示例来源:origin: freeplane/freeplane
private void updateBoundVariables() {
boundVariables = getBinding().getVariables();
final Object boundScript = boundVariables.remove("script");
if(boundScript != null)
script = boundScript;
// this is important: we need this reference no matter if "node" is overridden later by the user
node = (NodeRO) boundVariables.get("node");
controller = (ControllerRO) boundVariables.get("c");
}
代码示例来源:origin: org.grails/grails-web-jsp
@Override
public Object getAttribute(String name) {
Assert.notNull(name, "Attribute name cannot be null");
if (pageScope.getVariables().containsKey(name)) {
return pageScope.getVariable(name);
}
return null;
}
代码示例来源:origin: org.elasticsearch.module/lang-groovy
@SuppressWarnings("unchecked")
public GroovyScript(CompiledScript compiledScript, Script script, @Nullable LeafSearchLookup lookup, ESLogger logger) {
this.compiledScript = compiledScript;
this.script = script;
this.lookup = lookup;
this.logger = logger;
this.variables = script.getBinding().getVariables();
}
内容来源于网络,如有侵权,请联系作者删除!