@Override public Object getProperty(String property) { try { return delegate.getProperty(property); } catch (MissingPropertyException e) { return super.getProperty(property); } }
@Override public Object getProperty(String property) { try { return metaClass.getProperty(delegate,property); } catch (MissingPropertyException e) { return super.getProperty(property); } }
@Override public Object getProperty(String property) { try { return GroovyRuntimeUtil.getProperty($delegate, property); } catch (MissingPropertyException e) { return super.getProperty(property); } }
@Override public Object getProperty(final String property) { try { return InvokerHelper.getProperty(extension, property); } catch (Exception e) { return super.getProperty(property); } }
/** * Prints a newline to the current 'out' variable which should be a PrintWriter * or at least have a println() method defined on it. * If there is no 'out' property then print to standard out. */ public void println() { Object object; try { object = getProperty("out"); } catch (MissingPropertyException e) { System.out.println(); return; } InvokerHelper.invokeMethod(object, "println", ArgumentListExpression.EMPTY_ARRAY); }
/** * Prints the value to the current 'out' variable which should be a PrintWriter * or at least have a print() method defined on it. * If there is no 'out' property then print to standard out. */ public void print(Object value) { Object object; try { object = getProperty("out"); } catch (MissingPropertyException e) { DefaultGroovyMethods.print(System.out,value); return; } InvokerHelper.invokeMethod(object, "print", new Object[]{value}); }
/** * Prints the value and a newline to the current 'out' variable which should be a PrintWriter * or at least have a println() method defined on it. * If there is no 'out' property then print to standard out. */ public void println(Object value) { Object object; try { object = getProperty("out"); } catch (MissingPropertyException e) { DefaultGroovyMethods.println(System.out,value); return; } InvokerHelper.invokeMethod(object, "println", new Object[]{value}); }
/** * Prints a formatted string using the specified format string and arguments. * * @param format the format to follow * @param values an array of values to be formatted */ public void printf(String format, Object[] values) { Object object; try { object = getProperty("out"); } catch (MissingPropertyException e) { DefaultGroovyMethods.printf(System.out, format, values); return; } InvokerHelper.invokeMethod(object, "printf", new Object[] { format, values }); }
/** * Prints a formatted string using the specified format string and argument. * * @param format the format to follow * @param value the value to be formatted */ public void printf(String format, Object value) { Object object; try { object = getProperty("out"); } catch (MissingPropertyException e) { DefaultGroovyMethods.printf(System.out, format, value); return; } InvokerHelper.invokeMethod(object, "printf", new Object[] { format, value }); }
/** * Invoke a method (or closure in the binding) defined. * * @param name method to call * @param args arguments to pass to the method * @return value */ public Object invokeMethod(String name, Object args) { try { return super.invokeMethod(name, args); } // if the method was not found in the current scope (the script's methods) // let's try to see if there's a method closure with the same name in the binding catch (MissingMethodException mme) { try { if (name.equals(mme.getMethod())) { Object boundClosure = getProperty(name); if (boundClosure instanceof Closure) { return ((Closure) boundClosure).call((Object[])args); } else { throw mme; } } else { throw mme; } } catch (MissingPropertyException mpe) { throw mme; } } }
s.setProperty(lineCountName, ((BigInteger)s.getProperty(lineCountName)).add(BigInteger.ONE));
@Override public Object getProperty(String property) { try { return super.getProperty(property); } catch (MissingPropertyException e) { return null; } } }
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)); } }
@Override public final Object getProperty(String property) { if ("out".equals(property)) { return ((InvocationContext<?>)context).getWriter(); } else if ("context".equals(property)) { return context; } else { PipeLineClosure ret = Helper.resolveProperty(context, property); if (ret != null) { return ret; } try { return super.getProperty(property); } catch (MissingPropertyException e) { return null; } } } }
@Override public Object getProperty(String property) { try { return super.getProperty(property); } catch (MissingPropertyException e) { return null; } } }
@Override public Object getProperty(String property) { try { if (property.equals("actionBridge")) { return new ActionBridge(this); } return super.getProperty(property); } catch (MissingPropertyException mpe) { return null; } }
@Override protected void evaluationRequest(Script script) { Object property = null; if (getValueOptions() != null) { if (getValueOptions().contains("xVarName")) { property = script.getProperty("xVarName"); } if (property != null) { setxVarName((String) property); } } }
@Override public Double run(Double x) { getScript().setProperty(getXVarName(), x); getScript().run(); return (Double) getScript().getProperty("result"); }
@Override public Double[] run(@ParamInfo(name="", style="array", options="") Double[] x) { getScript().setProperty(getXVarName(), x); getScript().run(); return (Double[]) getScript().getProperty("result"); }
@Override public Double run(Double x, Double y, Double z) { getScript().setProperty(getXVarName(), x); getScript().setProperty(getYVarName(), y); getScript().setProperty(getZVarName(), z); getScript().run(); return (Double) getScript().getProperty("result"); }