nashorn/docs/source/InvokeScriptMethod.java
changeset 27361 86c4ddb4797b
parent 16212 363737d0d757
--- a/nashorn/docs/source/InvokeScriptMethod.java	Mon Nov 03 09:49:52 2014 +0100
+++ b/nashorn/docs/source/InvokeScriptMethod.java	Mon Nov 03 11:47:41 2014 +0100
@@ -29,26 +29,29 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import javax.script.*;
+import javax.script.Invocable;
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
 
+@SuppressWarnings("javadoc")
 public class InvokeScriptMethod {
-    public static void main(String[] args) throws Exception {
-        ScriptEngineManager manager = new ScriptEngineManager();
-        ScriptEngine engine = manager.getEngineByName("nashorn");
+    public static void main(final String[] args) throws Exception {
+        final ScriptEngineManager manager = new ScriptEngineManager();
+        final ScriptEngine engine = manager.getEngineByName("nashorn");
 
         // JavaScript code in a String. This code defines a script object 'obj'
         // with one method called 'hello'.
-        String script = "var obj = new Object(); obj.hello = function(name) { print('Hello, ' + name); }";
+        final String script = "var obj = new Object(); obj.hello = function(name) { print('Hello, ' + name); }";
         // evaluate script
         engine.eval(script);
 
         // javax.script.Invocable is an optional interface.
         // Check whether your script engine implements or not!
         // Note that the JavaScript engine implements Invocable interface.
-        Invocable inv = (Invocable) engine;
+        final Invocable inv = (Invocable) engine;
 
         // get script object on which we want to call the method
-        Object obj = engine.get("obj");
+        final Object obj = engine.get("obj");
 
         // invoke the method named "hello" on the script object "obj"
         inv.invokeMethod(obj, "hello", "Script Method !!" );