Revision [1923]

Last edited on 2014-07-06 22:45:53 by DavidLee
Additions:
All java commands and functions are in the "jnew" commands package. You need to import this package to use the java commands. You can import to the global namespace or choose a namespace.
import commands java


Revision [1584]

Edited on 2010-11-18 17:48:26 by DavidLee
Additions:
Version 1.1 introduced direct support for creating native Java Objects, invoking both static and instance methods, storing Java Objects in [[Variables]] and passing object references through [[CommandExecution Command Execution]] and [[SyntaxFunctionCall Function Calls]].
Deletions:
Version 1.1 introduced direct support for creating native Java Objects, invoking both static and instance methods, storing Java Objects in [[Variables]] and passing object references through [[CommandInvocation Command Invocation]] and [[SyntaxFunctionCall Function Calls]].


Revision [1582]

Edited on 2010-11-18 14:34:11 by DavidLee
Additions:
# Get a substring - use <[ number ]> to force arguments to be xs:integer which is convertable to int
s2=s1.substring( <[3]> <[6]> )
Deletions:
# Get a substring
s2=s1.substring( 3 3)


Revision [1581]

Edited on 2010-11-18 14:31:33 by DavidLee
Additions:
Instance methods of a java object in a variable may be called using the instance method syntax.
variable.methodName( [args ...] )

This is similar to the [[SyntaxFunctionCall Function Call Synatx]] except that it calls java instance methods on any object.
The arguments (if any) are expanded identically to function or command calls and the parameter list is then matched against public methods of the object's class to determine a "best match". If more then one matching method is found a method is chosen 'at random'. Method matching follows these rules
* Get a list of methods with the same number of parameters as arguments
* For each method compare the list of actual arguments against the method signature and determine the 'Best Match' by adding the conversions required for each argument.
* If an arguments' class is an exact match for the expected class, add 0
* If an arguments' class can be cast to the expected class, add 1
* If an arguments' class can be "boxed" to the expected class add 2
* If an argument is an XDM value then attempt matching with the Java primitive class coercion of XDM Value (example, an xs:string's Java primitive class is a String)
* The method(s) with the lowest total from the above conversion rules are candidates for invocation
* If more then one method has the same lowest score then pick one method.
After matching methods, a similar process is performed to convert the actual arguments to the expected type for each expected type and the method is called.
The resulting object is returned (or null if void).
Instance methods can also be called using the [[CommandJset jset Command]].
Example
# Create a String object with "Hi There"
s1=jnew(java.lang.String "Hi There")
# Get a substring
s2=s1.substring( 3 3)
echo $s2
The
----
[[Functions]]
[[Commands]]
[[FunctionJnew jnew Command]]
[[CommandJset jset Command]]


Revision [1580]

The oldest known version of this page was created on 2010-11-18 13:47:27 by DavidLee
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki