Changes

Jump to navigation Jump to search
1,512 bytes added ,  15:36, 2 July 2021
no edit summary
| '''Errors'''
|{{Error|key|#Errors}} The specified key cannot be decoded to its original representation.
|}
 
=Java=
 
{{Mark|Introduced with Version 9.6}
 
==convert:from-java==
 
{| width='100%'
|-
| width='120' | '''Signatures'''
|{{Func|convert:from-java|$items as item()*|item()*}}
|-
| '''Summary'''
|Tries to convert Java objects to XQuery values. The supplied {{Code|$items}} are processed one by one:
* If an item is already an XQuery value (e.g., as result from the default mapping), it is returned unchanged.
* If an item wraps an {{Code|Iterable}} ({{Code|Collection}}, {{Code|List}}, {{Code|Set}}, others) or {{Code|Iterator}}, the contained objects are recursively converted to XQuery.
* If an item wraps a {{Code|Map}}, the entries are recursively converted to an XQuery map.
|-
| '''Examples'''
|Adds 1000 values to {{Code|HashSet}} and returns the number of distinct entries:
<syntaxhighlight lang="xquery">
declare namespace HashSet = 'java:java.util.HashSet';
let $set := HashSet:new()
return (
prof:void((1 to 1000) ! HashSet:add($set, . mod 10)),
count(convert:from-java($set))
)
</syntaxhighlight>
Creates a {{Code|Scanner}} instance and converts the iterated results as sequence:
<syntaxhighlight lang="xquery">
declare namespace Scanner = 'java:java.util.Scanner';
Scanner:new("A B C")
=> Scanner:useDelimiter(" ")
=> convert:from-java()
</syntaxhighlight>
|-
| '''Errors'''
|{{Error|java|#Errors}} A wrapped Java object cannot be converted to an XQuery value.
|}
|{{Code|integer}}
|The specified digit is not valid for the given range.
|-
|{{Code|java}}
|A wrapped Java object cannot be converted to an XQuery value.
|-
|{{Code|key}}
=Changelog=
 
;Version 9.6
* Added: {{Function||convert:from-java}}
;Version 9.4
 
* Added: [[#convert:encode-key|convert:encode-key]], [[#convert:decode-key|convert:decode-key]].
;Version 9.0
 
* Added: [[#convert:binary-to-integers|convert:binary-to-integers]].
* Updated: [[#convert:integers-to-base64|convert:integers-to-base64]], [[#convert:integers-to-hex|convert:integers-to-hex]]: Renamed from {{Code|convert:bytes-to-base64}}; argument type relaxed from {{Code|xs:byte}} to {{Code|xs:integer}}.
;Version 8.5
 
* Updated: [[#convert:binary-to-string|convert:binary-to-string]]: <code>$fallback</code> argument added.
;Version 7.5
 
* Added: [[#convert:integer-to-dateTime|convert:integer-to-dateTime]], [[#convert:dateTime-to-integer|convert:dateTime-to-integer]], [[#convert:integer-to-dayTime|convert:integer-to-dayTime]], [[#convert:dayTime-to-integer|convert:dayTime-to-integer]].
The module was introduced with Version 7.3. Some of the functions have been adopted from the obsolete Utility Module.
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu