private String execute(final PreciseShardingValue shardingValue) { Closure<?> result = closure.rehydrate(new Expando(), null, null); result.setResolveStrategy(Closure.DELEGATE_ONLY); result.setProperty(shardingValue.getColumnName(), shardingValue.getValue()); return result.call().toString(); }
@Override public void setProperty(String s, Object o) { this.target.setProperty(s, o); }
public void setProperty(String property, Object newValue) { Closure.this.setProperty(property, newValue); }
public void setProperty(String property, Object newValue) { Closure.this.setProperty(property, newValue); }
public void setProperty(String property, Object newValue) { Closure.this.setProperty(property, newValue); }
public static String toString(Closure closure) { PrintWriter oldWriter = (PrintWriter) closure.getProperty("out"); StringWriter newWriter = new StringWriter(); closure.setProperty("out", new PrintWriter(newWriter)); closure.call(); closure.setProperty("out", oldWriter); return newWriter.toString(); }
public static String toString(String name, Closure<?> closure, Map<String, Object> groovyVariablesBound) { // boolean enabled = log.isInfoEnabled(); // if(enabled) { // int count = closureDepth.get().incrementAndGet(); // String tabs = generate(count); // if(groovyVariablesBound == null) // groovyVariablesBound = new HashMap<>(); // log.info(tabs+"closure '"+name+"' nestLevel="+count+" {"); // for(Entry<String, Object> entry : groovyVariablesBound.entrySet()) { // log.info(tabs+" "+entry.getKey()+"="+entry.getValue()); // } // } PrintWriter oldWriter = (PrintWriter) closure.getProperty(GroovyTemplateSuperclass.OUT_PROPERTY_NAME); StringWriter newWriter = new StringWriter(); closure.setProperty(GroovyTemplateSuperclass.OUT_PROPERTY_NAME, new PrintWriter(newWriter)); closure.call(); closure.setProperty(GroovyTemplateSuperclass.OUT_PROPERTY_NAME, oldWriter); // // if(enabled) { // int count = closureDepth.get().getAndDecrement(); // String tabs = generate(count); // log.info(tabs+"} // end "+name); // // } return newWriter.toString(); }
public static void _set(Map<?, ?> args, Closure body, PrintWriter out, ExecutableTemplate template, int fromLine) { // Simple case : #{set title:'Yop' /} for (Map.Entry<?, ?> entry : args.entrySet()) { Object key = entry.getKey(); if (!key.toString().equals("arg")) { BaseTemplate.layoutData.get().put( key, (entry.getValue() != null && entry.getValue() instanceof String) ? __safe(template.template, entry.getValue()) : entry.getValue()); return; } } // Body case Object name = args.get("arg"); if (name != null && body != null) { Object oldOut = body.getProperty("out"); StringWriter sw = new StringWriter(); body.setProperty("out", new PrintWriter(sw)); body.call(); BaseTemplate.layoutData.get().put(name, sw.toString()); body.setProperty("out", oldOut); } }
private Closure<?> cloneClosure(final List<String> columnNames, final List<Comparable> values) { Closure<?> result = closureTemplate.rehydrate(new Expando(), null, null); result.setResolveStrategy(Closure.DELEGATE_ONLY); result.setProperty("log", closureTemplate.getProperty("log")); for (int i = 0; i < values.size(); i++) { result.setProperty(columnNames.get(i), new ShardingValueWrapper(values.get(i))); } return result; } }
@Override protected Map<String, Object> convertTagArgs(Map<Object, Object> tagArgs, Map<String, Object> pageArgs, Closure<?> body, String srcLocation) { if(tagArgs.get("body") != null) throw new IllegalArgumentException("tag "+getName()+" must not define an argument of 'body' as that is reserved for the actual body"); Map<String, Object> copy = new HashMap<>(); Map<String, Object> closureProps = new HashMap<>(); for(Map.Entry<Object, Object> entry : tagArgs.entrySet()) { String key = entry.getKey().toString(); copy.put(key, entry.getValue()); if(body != null) { body.setProperty(key, entry.getValue()); closureProps.put(key, entry.getValue()); } } String bodyStr = ""; if(body != null) { bodyStr = ClosureUtil.toString(getName(), body, closureProps); } copy.put("body", bodyStr); return copy; }
copyOfTagArgs.put(key, entry.getValue()); if(body != null) body.setProperty(key, entry.getValue()); closureProps.put(key, entry.getValue()); body.setProperty("field", field); closureProps.put("field", field); bodyStr = ClosureUtil.toString(getName(), body, closureProps);
body.setProperty("field", field); body.call();
private String execute(final PreciseShardingValue shardingValue) { Closure<?> result = closure.rehydrate(new Expando(), null, null); result.setResolveStrategy(Closure.DELEGATE_ONLY); result.setProperty(shardingValue.getColumnName(), shardingValue.getValue()); return result.call().toString(); }
myBody.setProperty(argNames.get(i).toString(), arg);
myBody.setProperty(argNames.get(i).toString(), arg);