SJava (version 0.98.0)

javaIs: Performs class comparisons for Java objects

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

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).

Value

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

Details

This calls the Omegahat evaluator's is method.

References

http://www.omegahat.org/RSJava

See Also

.JNew .Java

Examples

Run this code
  x <- .JNew("java.util.Vector")

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

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

Run the code above in your browser using DataLab