Changes

Jump to navigation Jump to search
64 bytes added ,  11:25, 27 July 2022
m
is->if
Please bear in mind that the execution of Java code may cause side effects that conflict with the functional nature of XQuery, or may introduce new security risks to your project.
{{Mark|Updated with Version 9.6Some more notes:}}
* With the middle dot notation, three adjacent dots can be used to specify array types.
* The path to the standard package {{Code|java.lang.}} can now be omitted.* Java objects are now wrapped into function items.
* Results of constructor calls are always returned as function item.
* A new option With {{Option|WRAPJAVA}} was added to control , it can be controlled how Java values are converted to XQuery.* The Mapping rules were refined and unified. The most important changes:** {{Code|array(*)}} type added.** {{Code|xs:integer}} values are converted to {{Code|long}} values.** {{Code|xs:unsignedShort}} values are converted to {{Code|char}} values.* All error messages were revised and improved.
=Identification=
=Module Imports=
A Java classes class can also be instantiated by ''importing'' them as a module: A new instance of the addressed class will be constructed, which can then be referenced in the query body.
In the (side-effecting) example below, a HashSet instance is created, values are added, and the size of the set is returned. As {{Code|set:add()}} returns boolean values, {{Function|Profiling|prof:void}} is used to swallow the values:
Before Java code is executed, the arguments are converted to Java values, depending on the addressed function or constructor parameters. The accepted Java types and the original XQuery types are depicted in the second and first column of the table below.
 
If a numeric value is supplied for which no exact matching is defined, it is cast to the appropriate type unless it exceeds its limits. The following two function calls are equivalent:
 
<syntaxhighlight lang="xquery">
(: exact match :)
Q{String}codePointAt('ABC', xs:int(1)),
(: xs:byte and xs:integer casts :)
Q{String}codePointAt('ABC', xs:byte(1)),
Q{String}codePointAt('ABC', 1)
</syntaxhighlight>
===Conversion to XQuery===
</syntaxhighlight>
If no conversion is defined, a string is returned, resulting from the {{Code|toString()}} method of the object. This method is also called is if the string representation of a Java item is requested:
<syntaxhighlight lang="xquery">
administrator, editor
31

edits

Navigation menu