Previous Page | Next Page

Java Object Language Elements

CALLtypeMETHOD Method



Invokes an instance method on a java object from a non-static Java method.
Category: Method reference

Syntax
Arguments
Details
Comparisons
Example
See Also

Syntax

object.CALLtypeMETHOD ("method-name", <method-argument-1 ..., method-argument-n>, <return value>);


Arguments

object

specifies the name of the java object.

type

specifies the result type for the non-static Java method. The type can be one of the following values:

BOOLEAN

specifies that the result type is BOOLEAN.

BYTE

specifies that the result type is BYTE.

CHAR

specifies that the result type is CHAR.

DOUBLE

specifies that the result type is DOUBLE.

FLOAT

specifies that the result type is FLOAT.

INT

specifies that the result type is INT.

LONG

specifies that the result type is LONG.

SHORT

specifies that the result type is SHORT.

STRING

specifies that the result type is STRING.

VOID

specifies that the result type is VOID.

See Also: Type Issues in SAS Language Reference: Concepts
method-name

specifies the name of the non-static Java method.

Requirement: The method name must be enclosed in either single or double quotation marks.
method-argument

specifies the parameters to pass to the method.

return-value

specifies the return value if the method returns one.


Details

Once you instantiate a java object, you can access any non-static Java method through method calls on the java object by using the CALLtypeMETHOD method.

Note:   type represents a Java data type. For more information about how Java data types relate to SAS data types, see Type Issues in SAS Language Reference: Concepts.  [cautionend]


Comparisons

Use the CALLtypeMETHOD method for non-static Java methods. If the Java method is static, use the CALLSTATICtypeMETHOD method.


Example

The following example creates a simple class that contains three non-static fields. The java object j is instantiated, the field values are set and then retrieved by using the CALLtypeFIELD method .

/* Java code */
import java.util.*;
import java.lang.*;
public class ttest
{
   public int i;
   public double d;
   public string s;

   public int im()
   {
      return i;
   }

   public String sm()
   {
       return s;
   }

   public double dm()
   {
      return d;
   }
}

/*  DATA step code */
data _null_;
   dcl javaobj j("ttest");
   length val 8;
   length str $20;
    j.setIntField("i", 100);
   j.setDoubleField("d", 3.14159);
   j.setStringField("s", "abc");

   j.callIntMethod("im", val);
   put val=;
   j.callDoubleMethod("dm", val);
   put val=;
   j.callStringMethod("sm", str);
   put str=;
run;

The following lines are written to the SAS log:

val=100
val=3.14159
str=abc


See Also

Method:

CALLSTATICtypeMETHOD Method

Previous Page | Next Page | Top of Page