Changes

Jump to navigation Jump to search
1,017 bytes added ,  15:53, 8 July 2021
{{Mark|Updated with Version 9.6:}}
* New option {{Option|WRAPJAVA}}.
* {{Code|array(*)}} type added.
* {{Code|xs:integer}} values are converted to {{Code|long}} values.
===Conversion to XQuery===
The result of a Java call is converted conversion back to XQuery, as depicted in can be controlled with the second and third column of the table{{Option|WRAPJAVA}} option.The following values exist:
As there * {{Code|some}} (the default): Java values are too many differences between converted to XQuery , as shown in the second and third column of the table.* {{Code|none}}: The conversion to XQuery items is enforced: Additional to the default conversions, values of type {{Code|Iterator}} and {{Code|Iterable}} (including lists, sets and Java typescollections) are converted to sequences, and maps are converted to XQuery maps. If no bidirectional mapping conversion is possible, an error is raised. The chosen mapping is a compromise between usability and conformity* {{Code|all}}: All values (excluding those inheriting the internal type {{Code|org.basex.query.value.Value}}) will be returned as wrapped Java objects. This way, they can be passed on to other Java functions without intermediate conversions. The With {{Function|Conversion|convert:from-java}} function , the conversion of a wrapped Java object can be enforced as well. The option can be used best specified as pragma. In the following example, the result of the first function – a char array – is wrapped and passed on to convert more complex data structures a {{Code|CharBuffer}} function: <syntaxhighlight lang="xquery">(# db:wrapjava all #) { Q{java.lang.Character}toChars(xs:int(33)) => Q{java.nio.CharBuffer}wrap()}</syntaxhighlight> Without the pragma, the single-value array would be converted to XQueryan {{Code|xs:unsignedShort}} item and the second function call would fail.
{| class="wikitable"
! Expected or returned Java type
! XQuery output
|- valign="top"
| <code>item()*</code> (no conversion)
| <code>org.basex.query.value.Value</code>
| <code>item()*</code> (no conversion)
|- valign="top"
| <code>empty-sequence()</code>
| <code>null</code>
| <code>empty-sequence()</code>
|- valign="top"
| <code>item()*</code> (no conversion)
| <code>org.basex.query.value.Value</code>
| <code>item()*</code> (no conversion)
|- valign="top"
| <code>xs:string</code>, <code>xs:untypedAtomic</code>
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu