GetFieldValue
Use this function to get the value of static or non-static public fields in a Java class. For non-static fields, use the variable FieldName for a Java class or TargetObject for a Java object. For a static Java class field, use the variable ClassName.
Adding Java archive (JAR) files to the shared library directory
- Copy the Java classes to the $IMPACT_HOME/dsalib directory.
- Restart the Impact Server to load the JAR files.
Syntax
GetFieldValue( ClassName,
TargetObject, FieldName );Parameters
Parameter |
Description |
|---|---|
|
Name of the Java class. For a non-static method call, this parameter would be set to null. |
|
Name of the instantiated Java object. For a static method, this parameter would be set to null. |
|
Name of the public field variable in the Java class to retrieve the value for. |
Returns
Value of the field.
Example
Get the value of the static field named out of the Java class, java.lang.System:
fieldvalue = GetFieldValue("java.lang.System", null, "out");Get the value of the non-static field firstname from a hypothetical Java class, com.ibm.DeveloperAccount. Since it is a non-static field, we are retrieving the field data off an instantiated object of the class. We assume that the constructor needs only a simple ID number to retrieve the account instance:
Example using IPL.
dev_acct = NewJavaObject("com.ibm.DeveloperAccount", {765224});
first_name = GetFieldValue(null, dev_acct, "firstname");Example using JavaScript.
dev_acct = NewJavaObject("com.ibm.DeveloperAccount", [765224]);
first_name = GetFieldValue(null, dev_acct, "firstname");