Functions
-
java
cast |
I
Returns an |
||||||||||||||||||
createNull |
I
Returns a |
||||||||||||||||||
fromString |
I
Returns a |
||||||||||||||||||
getClass |
I
Returns a This function performs a Java
|
||||||||||||||||||
isNull |
I
Returns |
||||||||||||||||||
jObjToString |
Returns the string representation of a Java object stored in a handle reference. |
||||||||||||||||||
toString |
I
Returns a Ballerina |
Returns an JObject|error
, which is obtained after casting the provided JObject
instance
to the given JObject
type depending on assignability.
JObject|error obj = java:cast(inputStream, typedesc<FileInputStream>);
if (obj is JObject) {
FileInputStream fileInputStream = <FileInputStream>obj;
}
Parameters
- value JObject
-
The
JObject
instance which is to be casted
- castType typedesc
-
The
JObject
implementation typetypedesc<JObject>
to which the given object is casted to if assignable
-
Return Type
(JObject | error) The
JObject|error
, which refers to the newJObject
instance or anerror
Returns a handle
, which refers to Java null.
handle nullHandle = java:createNull();
-
Return Type
(handle) The
handle
, which refers to Java null
Returns a handle
, which refers to the Java string representation of the Ballerina string
.
handle header = java:fromString("Content-Type");
Parameters
- value string
-
The Ballerina
string
with which thehandle
is created
-
Return Type
(handle) The
handle
, which refers to the Java String representation of the Ballerinastring
Returns a handle
, which refers to the Java Class object associated with the class or interface with the given
string name.
handle|error intClass = java:getClass("int");
This function performs a Java class.forName(name)
except for the following cases:
Name | Output |
---|---|
boolean | Java Class instance representing the primitive type boolean |
byte | Java Class instance representing the primitive type byte |
char | Java Class instance representing the primitive type char |
short | Java Class instance representing the primitive type short |
int | Java Class instance representing the primitive type int |
long | Java Class instance representing the primitive type long |
float | Java Class instance representing the primitive type float |
double | Java Class instance representing the primitive type double |
Parameters
- name string
-
The name of the Java class
-
Return Type
(handle | error) The Java Class object for the class with the given name
Returns true
if this handle refers to Java null.
boolean status = java:isNull(value);
Parameters
- value handle
-
The
handle
of which the referred value is to be tested with Java null
-
Return Type
(boolean) true
if this handle refers to Java null
Returns the string representation of a Java object stored in a handle reference.
Parameters
- jObj handle
-
The
handle
reference to the corresponding Java object.
-
Return Type
(string) The
string
representation of the Java object.
Returns a Ballerina string
representation of the Java object referred by the handle
.
If the handle
refers to Java null, then this function returns a nil
value.
string? version = java:toString(versionProperty);
Parameters
- value handle
-
The
handle
of which the referred value is to be converted to a Ballerinastring
-
Return Type
(string?) The Ballerina
string
representation of the Java object referred by thehandle
or else returns()
if thehandle
refers to Java null