SETSTATICtypeFIELD Method

Modifies the value of a static field for a Java object.

Category: Field Reference
Applies to: Java object

Syntax

object.SETSTATICtypeFIELD ("field-name", value);

Arguments

object

specifies the name of a Java object.

type

specifies the type for the Java field. The type can be one of the following values:

BOOLEAN

specifies that the field type is BOOLEAN.

BYTE

specifies that the field type is BYTE.

CHAR

specifies that the field type is CHAR.

DOUBLE

specifies that the field type is DOUBLE.

FLOAT

specifies that the field type is FLOAT.

INT

specifies that the field type is INT.

LONG

specifies that the field type is LONG.

SHORT

specifies that the field type is SHORT.

STRING

specifies that the field type is STRING.

See Type Issues in SAS Language Reference: Concepts

field-name

specifies the Java field name.

Requirement The field name must be enclosed in either single or double quotation marks.

value

specifies the value for the field.

Details

Once you instantiate a Java object, you can access and modify its public fields through method calls on the Java object. The SETSTATICtypeFIELD method enables you to modify static fields.
Note: The type argument 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.

Comparisons

The SETSTATICtypeFIELD method modifies the value of a static field for a Java object. To modify the value of a non-static field, use the SETtypeFIELD method.

Example: Creating a Java Class with Static Fields

The following example creates a simple class that contains three static fields. The Java object j is instantiated, the field values are set using the SETSTATICtypeFIELD method, and then the field values are retrieved.
/* Java code */
import java.util.*;
import java.lang.*;
public class ttestc
{
   public static double d;
   public static double dm()
   {
      return d;
   }
}
/*  DATA step code */
data _null_;
   dcl javaobj j("ttest");
   length val 8;
   length str $20;
   j.setStaticIntField("i", 100);
   j.setStaticDoubleField("d", 3.14159);
   j.setStaticStringField("s", "abc");
   j.getStaticIntField("i", val);
   put val=;
   j.getStaticDoubleField("d", val);
   put val=;
   j.getStaticStringField("s", str);
   put str=;
run;
The following lines are written to the SAS log:
val=100
val=3.14159
str=abc