Functions - java

createNull

Returns a handle that refers to Java null.

fromString

Returns a handle that refers to the Java string representation of the Ballerina string.

getArrayElement

Returns a handle that refers to the element at the specified index in the given Java array.

This function panics with a JavaNullReferenceError error if the handle refers to Java null.

getArrayLength

Returns the length of the given Java array.

This function panics with a JavaNullReferenceError error if the handle refers to Java null.

isNull

Returns true if this handle refers to Java null.

setArrayElement

Replaces the element at the specified index in the given Java array with the specified element.

This function panics with a JavaNullReferenceError error if the handle refers to Java null.

toString

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.

createNull

()

returns handle

Returns a handle that refers to Java null.

  • Return Type

    (handle)
  • the handle that refers to Java null

fromString

(string value)

returns handle

Returns a handle that refers to the Java string representation of the Ballerina string.

Parameters

  • value string
  • the Ballerina string with which the handle is created

  • Return Type

    (handle)
  • the handle that refers to the Java String representation of the Ballerina string

getArrayElement

(handle receiver, int index)

returns handle

Returns a handle that refers to the element at the specified index in the given Java array.

This function panics with a JavaNullReferenceError error if the handle refers to Java null.

Parameters

  • receiver handle
  • the handle which referes to the Java array

  • index int
  • the index of the element to be returned

  • Return Type

    (handle)
  • the handle that refers to the element at the specified position in the Java array

getArrayLength

(handle receiver)

returns int

Returns the length of the given Java array.

This function panics with a JavaNullReferenceError error if the handle refers to Java null.

Parameters

  • receiver handle
  • the handle which referes to the Java array

  • Return Type

    (int)
  • the length of the given Java array

isNull

(handle value)

returns boolean

Returns true if this handle refers to Java null.

Parameters

  • value handle
  • the handle whose referred value to be tested with Java null

  • Return Type

    (boolean)
  • true if this handle refers to Java null

setArrayElement

Replaces the element at the specified index in the given Java array with the specified element.

This function panics with a JavaNullReferenceError error if the handle refers to Java null.

Parameters

  • receiver handle
  • the handle which referes to the Java array

  • index int
  • the index of the element to be replaced

  • element handle
  • the element to be stored at the specified index

toString

(handle value)

returns string?

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.

Parameters

  • value handle
  • the handle whose referred value to be converted to Ballerina string

  • Return Type

    (string?)
  • the Ballerina string representation of the Java object referred by the handle or returns nil of the handle refers to Java null