javaIs: Performs class comparisons for Java objects

Description Usage Arguments Details Value Author(s) References See Also Examples

Description

Allows one to test if a Java object (in Omegahat) is an object of a particular class, or implements a particular Java interface.

Usage

1
javaIs(obj, klass, instanceof=TRUE)

Arguments

obj

the Java object whose class is being queried and compared

klass

the name of a Java class or the Class reference object with which the object obj is being compared.

instanceof

a logical value indicating whether the comparison should be done using the equality of classes or the Java instanceof semantics. The former tests whether the class of obj is the same as the class identified by klass. The latter identifies whether obj implements the Java interface class klass. (There is also the assignable from semantics which may or may not be currently present).

Details

This calls the Omegahat evaluator's is method.

Value

A logical value indicating whether the class of obj is related to klass in the specified comparison. This is TRUE or FALSE.

Author(s)

Duncan Temple Lang, John Chambers

References

http://www.omegahat.org/RSJava

See Also

.JNew .Java

Examples

1
2
3
4
5
6
7
8
  x <- .JNew("java.util.Vector")

    # TRUE
  javaIs(x, "java.util.Vector")
  javaIs(x, "java.util.List", TRUE)

   # FALSE
  javaIs(x, "java.util.Hashtable")

SJava documentation built on Oct. 5, 2016, 4:17 a.m.

Related to javaIs in SJava...