Changes

Jump to navigation Jump to search
57 bytes added ,  17:42, 17 October 2017
=Module Imports=
Java code can also be integrated accessed by ''importing'' classes as modules. A new instance of the addressed class is will be created, which can then be accessed referenced in the query body.
The following, (side-effecting ) example returns the number of distinct values added to a hash set (the . The boolean values returned by {{Code|set:add()}} will be swallowed):
<pre class="brush:xquery">
import module namespace set = "java:java.util.HashSet";
prof:void(
for $s in ("one", "two", "one")
</pre>
The advantages of this approach is that the execution of imported code classes is executed faster more efficient than the execution of instances that are created at runtime via {{Code|new()}}. A drawback is that no arguments can be passed on to the class constructor. As a consequence, the import will fail fails if the addressed class has no default constructor, but at least one constructor with arguments and no default constructor.
=Context-Awareness=
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu