Revision [1602]

This is an old revision of CommandJset made by DavidLee on 2010-12-03 06:54:53.

 

Command jset


Name

jcall Sets a variable as a result of creating a java object or calling a java method.

Synopsis

jset [options] [args ...]

Description

Jset creates a new Java Object or calls a static or instance method on that object or a supplied object.
The result is assigned to the named variable.

See FunctionJnew and JavaObjects for a function equivalent.


Options

-v,-variable nameAssigns the result to the named variable in the current scope
-c,-classname classnameCreates a new instance of a class given its fully qualified classname and calls the a constructor
-m,-method methodCalls an instance method on the object specified with -object or a static method if no -object
-o,-object objectUses the specified object for a method call (-method)


-variable is required and the name is the name of an existing or to be created variable in the current scope.
If -classname is passed then the classname is used to either create a new variable or if -m is specified calling a static method on classname.
If -method is supplied then an instance method is called (requires -object)
If -object is supplied then -method is required and the specified method is invoked on the object.


If any additional arguments are specified they are used as the argument list for the constructor or method call,
using the same boxing and conversions in JavaObjects.



In all cases the result value (new object or return from method call) is assigned to the specified variable.



Examples


Create a Data object with default constructor and assign to "date" and print its type and value (using Date.toString())

jset -v date -c java.util.Date
xtype $date
echo $date


Result
java.util.Date
Fri Dec 03 09:46:11 EST 2010


Get the unix time of the date created
jset -v time -o $date -m getTime
xtype $time
echo $time


Result
java.lang.Long
1291387571095


Create an integer by passing in a string value of "12345"
jset -v int -c java.lang.Integer 12345
xtype $int
echo $int


Result
java.lang.Integer
12345



Create a hex representation from an integer by calling a static method java.lang.Integer.toHexString( int )
jset -v hex -c java.lang.Integer -m toHexString $int
xtype $hex
echo $hex


Result
java.lang.String
3039








CategoryCommands
Commands
There are no comments on this page.
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki