Package com.java7developer.chapter8

Source Code of com.java7developer.chapter8.UseGroovyShell

package com.java7developer.chapter8;

import groovy.lang.GroovyShell;
import groovy.lang.Binding;
import java.math.BigDecimal;

/**
* Code for listing 8_10
*/
public class UseGroovyShell {

  public static void main(String[] args) {
    Binding binding = new Binding();
    binding.setVariable("x", 2.4);
    binding.setVariable("y", 8);
    GroovyShell shell = new GroovyShell(binding);
    Object value = shell.evaluate("x + y");
    assert value.equals(new BigDecimal(10.4));
  }

}
TOP

Related Classes of com.java7developer.chapter8.UseGroovyShell

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.