jhm 2003/09/12 07:15:17 Modified: docs/manual/OptionalTasks script.html Log: Link to documentation of "JavaAdapter". How to import classes outside of "java" namespace. Revision Changes Path 1.13 +18 -4 ant/docs/manual/OptionalTasks/script.html Index: script.html =================================================================== RCS file: /home/cvs/ant/docs/manual/OptionalTasks/script.html,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- script.html 16 Jun 2003 10:09:09 -0000 1.12 +++ script.html 12 Sep 2003 14:15:17 -0000 1.13 @@ -9,14 +9,14 @@ <h2><a name="script">Script</a></h2> <h3>Description</h3> -<p>Execute a script in a +<p>Execute a script in a <a href="http://jakarta.apache.org/bsf" target="_top">Apache BSF</a> supported language.</p> <p><b>Note:</b> This task depends on external libraries not included in the Ant distribution. See <a href="../install.html#librarydependencies">Library Dependencies</a> for more information.</p> <p>All items (tasks, targets, etc) of the running project are accessible from the script, using either their <code>name</code> or <code>id</code> attributes (as long as their names are considered -valid Java identifiers, that is). +valid Java identifiers, that is). The name "project" is a pre-defined reference to the Project, which can be used instead of the project name. The name "self" is a pre-defined reference to the actual <script>-Task instance.<br>From these objects you have access to the Ant Java API, see the @@ -26,6 +26,15 @@ <p>If you are using JavaScript a good resource is <a target="_blank" href="http://www.mozilla.org/rhino/doc.html"> http://www.mozilla.org/rhino/doc.html</a> as we are using their JavaScript interpreter.</p> <p>Scripts can do almost anything a task written in Java could do.</p> +<p>Rhino provides a special construct - the <i>JavaAdapter</i>. Whith that you can +create an object which implements several interfaces, extends classes and for which you +can overwrite methods. Because this is an undocumented feature (yet), here is the link +to an explanation: <a href="http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&newwindow=1&frame=right&th=610d2db45c0756bd&seekm=391EEC3C.5236D929%40yahoo.com#link2"> [EMAIL PROTECTED]: "Rhino, enum.js, JavaAdapter?"</a> by Norris Boyd in the newsgroup +<i>netscape.public.mozilla.jseng</i>.</p> + + + <h3>Parameters</h3> <table border="1" cellpadding="2" cellspacing="0"> <tr> @@ -178,7 +187,12 @@ </pre></blockquote> <p>We want to use the Java API. Because we donīt want always typing the package signature we do an import. Rhino knows to different methods for import statements: one for packages -and one for a single class. <br> +and one for a single class. By default only the <i>java</i> packages are available, so +<i>java.lang.System</i> can be directly imported with <code>importClass/importPackage</code>. +For other packages you have to prefix the full classified name with <i>Package</i>. +For example antīs <i>FileUtil</i> class can be imported with +<code>importClass(<b>Package</b>.org.apache.tools.ant.util.FileUtils)</code> +<br> The <script> task populates the Project instance under the name <i>project</i>, so we can use that reference. Another way is to use its given name or getting its reference from the task itself.<br> @@ -199,4 +213,4 @@ Reserved.</p> </body> -</html> +</html> \ No newline at end of file
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]