Java Object Language Elements |
Category: | Field reference |
Syntax | |
Arguments | |
Details | |
Comparisons | |
Example | |
See Also |
Syntax |
object.GETtypeFIELD("field-name", value); |
specifies the name of a java object.
specifies the type for the Java field. The type can be one of the following values:
specifies that the field type is BOOLEAN.
specifies that the field type is BYTE.
specifies that the field type is CHAR.
specifies that the field type is DOUBLE.
specifies that the field type is FLOAT.
specifies that the field type is INT.
specifies that the field type is LONG.
specifies that the field type is SHORT.
specifies that the field type is STRING.
See Also: | Type Issues in SAS Language Reference: Concepts |
specifies the Java field name.
Requirement: | The field name must be enclosed in either single or double quotation marks. |
specifies the name of variable that receives the returned field value.
Details |
Once you instantiate a java object, you can access and modify its public fields through method calls on the java object. The GETtypeFIELD method enables you to access non-static fields.
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.
Comparisons |
The GETtypeFIELD method returns the value of a non-static field for a java object. To return the value of a static field, use the GETSTATICtypeFIELD 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 modified and then retrieved by using the GETtypeFIELD method.
/* Java code */ import java.util.*; import java.lang.*; public class ttest { public int i; public double d; public string s; } }
/* 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.getIntField("i", val); put val=; j.getDoubleField("d", val); put val=; j.getStringField("s", str); put str=; run;
The following lines are written to the SAS log:
val=100 val=3.14159 str=abc
See Also |
Method: |
Copyright © 2011 by SAS Institute Inc., Cary, NC, USA. All rights reserved.