1
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
4
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
5
<meta name="Author" content="Norris Boyd">
6
<meta name="GENERATOR" content="Mozilla/4.75 [en] (WinNT; U) [Netscape]">
7
<title>Rhino Examples</title>
9
<body bgcolor="#FFFFFF">
13
Rhino Examples</h1></center>
14
Examples have been provided that show how to control the JavaScript engine
15
and to implement scriptable host objects. All the examples are in the cvs
16
tree at <tt><a href="http://lxr.mozilla.org/mozilla/source/js/rhino/examples/">mozilla/js/rhino/examples</a></tt>.
20
The <tt><a href="http://lxr.mozilla.org/mozilla/source/js/rhino/examples/unique.js">unique.js</a></tt>
21
script allows printing unique lines from a file.
22
<p>The <tt><a href="http://lxr.mozilla.org/mozilla/source/js/rhino/examples/liveConnect.js">liveConnect.js</a></tt>
23
script shows a sample usage of LiveConnect (Java-to-JavaScript connectivity).
24
<p>The <tt><a href="http://lxr.mozilla.org/mozilla/source/js/rhino/examples/jsdoc.js">jsdoc.js</a></tt>
25
script is a JavaScript analog to Java's <tt>javadoc</tt>. It makes heavy
26
use of regular expressions.
27
<p>The <tt><a href="http://lxr.mozilla.org/mozilla/source/js/rhino/examples/checkParam.js">checkParam.js</a></tt>
28
script is a useful tool to check that <tt>@param</tt> tags in Java documentation
29
comments match the parameters in the corresponding Java method.
30
<p>The <tt><a href="http://lxr.mozilla.org/mozilla/source/js/rhino/examples/enum.js">enum.js</a></tt>
31
script is a good example of using a JavaAdapter to implement a Java interface
32
using a JavaScript object.
33
<p>The <a href="http://lxr.mozilla.org/mozilla/source/js/rhino/examples/NervousText.js">NervousText.js</a>
34
script is a JavaScript implementation of the famous NervousText applet
35
using JavaScript compiled to Java classes using <a href="jsc.html">jsc</a>.
36
It can be run in the HTML page <a href="http://lxr.mozilla.org/mozilla/source/js/rhino/examples/NervousText.html">NervousText.html</a>.
39
Controlling the JavaScript Engine</h2>
42
The RunScript class</h4>
43
<tt><a href="http://lxr.mozilla.org/mozilla/source/js/rhino/examples/RunScript.java">RunScript.java</a></tt>
44
is a simple program that executes a script from the command line.
46
The Control class</h4>
47
<tt><a href="http://lxr.mozilla.org/mozilla/source/js/rhino/examples/Control.java">Control.java</a></tt>
48
is a program that executes a simple script and then manipulates the result.
51
<tt><a href="http://lxr.mozilla.org/mozilla/source/js/rhino/examples/Shell.java">Shell.java</a></tt>
52
is a program that executes JavaScript programs; it is a simplified version
53
of the shell in the <tt>tools</tt> package. The programs may be specified
54
as files on the command line or by typing interactively while the shell
57
<b>Multithreaded Script Execution</b></h4>
58
<tt><a href="http://lxr.mozilla.org/mozilla/source/js/rhino/examples/DynamicScopes.java">DynamicScopes.java</a></tt>
59
is a program that creates a single global scope object and then shares
60
it across multiple threads. Sharing the global scope allows both information
61
to be shared across threads, and amortizes the cost of Context.initStandardObjects
62
by only performing that expensive operation once.
65
Implementing Host Objects</h2>
66
First check out the <a href="http://www.mozilla.org/rhino/tutorial.html">tutorial</a>
67
if you haven't already.
69
The Foo class - Extending ScriptableObject</h4>
70
<tt><a href="http://lxr.mozilla.org/mozilla/source/js/rhino/examples/Foo.java">Foo.java</a></tt>
71
is a simple JavaScript host object that includes a property with an associated
72
action and a variable argument method.
75
The Matrix class - Implementing Scriptable</h4>
76
<tt><a href="http://lxr.mozilla.org/mozilla/source/js/rhino/examples/Matrix.java">Matrix.java</a></tt>
77
provides a simple multidimensional array by implementing the Scriptable
81
The File class - An advanced example</h4>
82
<tt><a href="http://lxr.mozilla.org/mozilla/source/js/rhino/examples/File.java">File.java</a></tt>
83
extends ScriptableObject to provide a means of reading and writing files
84
from JavaScript. A more involved example of host object definition.
87
<br><a href="index.html">back to top</a>
1
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
4
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
5
<meta name="Author" content="Norris Boyd">
6
<meta name="GENERATOR" content="Mozilla/4.75 [en] (WinNT; U) [Netscape]">
7
<title>Rhino Examples</title>
9
<body bgcolor="#FFFFFF">
13
Rhino Examples</h1></center>
14
Examples have been provided that show how to control the JavaScript engine
15
and to implement scriptable host objects. All the examples are in the cvs
16
tree at <tt><a href="http://lxr.mozilla.org/mozilla/source/js/rhino/examples/">mozilla/js/rhino/examples</a></tt>.
20
The <tt><a href="http://lxr.mozilla.org/mozilla/source/js/rhino/examples/unique.js">unique.js</a></tt>
21
script allows printing unique lines from a file.
22
<p>The <tt><a href="http://lxr.mozilla.org/mozilla/source/js/rhino/examples/liveConnect.js">liveConnect.js</a></tt>
23
script shows a sample usage of LiveConnect (Java-to-JavaScript connectivity).
24
<p>The <tt><a href="http://lxr.mozilla.org/mozilla/source/js/rhino/examples/jsdoc.js">jsdoc.js</a></tt>
25
script is a JavaScript analog to Java's <tt>javadoc</tt>. It makes heavy
26
use of regular expressions.
27
<p>The <tt><a href="http://lxr.mozilla.org/mozilla/source/js/rhino/examples/checkParam.js">checkParam.js</a></tt>
28
script is a useful tool to check that <tt>@param</tt> tags in Java documentation
29
comments match the parameters in the corresponding Java method.
30
<p>The <tt><a href="http://lxr.mozilla.org/mozilla/source/js/rhino/examples/enum.js">enum.js</a></tt>
31
script is a good example of using a JavaAdapter to implement a Java interface
32
using a JavaScript object.
33
<p>The <a href="http://lxr.mozilla.org/mozilla/source/js/rhino/examples/NervousText.js">NervousText.js</a>
34
script is a JavaScript implementation of the famous NervousText applet
35
using JavaScript compiled to Java classes using <a href="jsc.html">jsc</a>.
36
It can be run in the HTML page <a href="http://lxr.mozilla.org/mozilla/source/js/rhino/examples/NervousText.html">NervousText.html</a>.
39
Controlling the JavaScript Engine</h2>
42
The RunScript class</h4>
43
<tt><a href="http://lxr.mozilla.org/mozilla/source/js/rhino/examples/RunScript.java">RunScript.java</a></tt>
44
is a simple program that executes a script from the command line.
46
The Control class</h4>
47
<tt><a href="http://lxr.mozilla.org/mozilla/source/js/rhino/examples/Control.java">Control.java</a></tt>
48
is a program that executes a simple script and then manipulates the result.
51
<tt><a href="http://lxr.mozilla.org/mozilla/source/js/rhino/examples/Shell.java">Shell.java</a></tt>
52
is a program that executes JavaScript programs; it is a simplified version
53
of the shell in the <tt>tools</tt> package. The programs may be specified
54
as files on the command line or by typing interactively while the shell
56
<h4>PrimitiveWrapFactory</h4>
57
<a href="http://lxr.mozilla.org/mozilla/source/js/rhino/examples/PrimitiveWrap
58
Factory.java">PrimitiveWrapFactory.java</a> is an example of a WrapFactory that
59
can be used to control the wrapping behavior of the Rhino engine on calls to Jav
62
<b>Multithreaded Script Execution</b></h4>
63
<tt><a href="http://lxr.mozilla.org/mozilla/source/js/rhino/examples/DynamicScopes.java">DynamicScopes.java</a></tt>
64
is a program that creates a single global scope object and then shares
65
it across multiple threads. Sharing the global scope allows both information
66
to be shared across threads, and amortizes the cost of Context.initStandardObjects
67
by only performing that expensive operation once.
70
Implementing Host Objects</h2>
71
First check out the <a href="http://www.mozilla.org/rhino/tutorial.html">tutorial</a>
72
if you haven't already.
74
The Foo class - Extending ScriptableObject</h4>
75
<tt><a href="http://lxr.mozilla.org/mozilla/source/js/rhino/examples/Foo.java">Foo.java</a></tt>
76
is a simple JavaScript host object that includes a property with an associated
77
action and a variable argument method.
80
The Matrix class - Implementing Scriptable</h4>
81
<tt><a href="http://lxr.mozilla.org/mozilla/source/js/rhino/examples/Matrix.java">Matrix.java</a></tt>
82
provides a simple multidimensional array by implementing the Scriptable
86
The File class - An advanced example</h4>
87
<tt><a href="http://lxr.mozilla.org/mozilla/source/js/rhino/examples/File.java">File.java</a></tt>
88
extends ScriptableObject to provide a means of reading and writing files
89
from JavaScript. A more involved example of host object definition.
92
<br><a href="index.html">back to top</a>