Bridges > Java Import Bridge > Managing IDL-Java Object Properties

# Managing IDL-Java Object Properties

Property names and arguments are also passed to the IDL Java subsystem and are used in conjunction with the Java Reflection API to construct and access public data members on the underlying object. These public data members (known as properties in IDL) are identified through arguments to the GetProperty and SetProperty methods. See Getting and Setting Properties for more information.

Note: Only public data members may be accessed.

Due to case-sensitivity incompatibilities between IDL and Java and the fact that Java might promote certain data types, the Java bridge uses an algorithm to match the IDL properties name to the corresponding Java object data members.

Before the algorithm starts, IDL provides a case-insensitive <PROPERTYNAME> and a reference to the Java object. For the given object and its parent classes, the Java bridge obtains a list of all the public data members including static members. This algorithm performs the following steps:

1. If the Java class has one data member name matching the IDL <PROPERTYNAME> (except for case insensitivity), this Java data member is used. At this point, data types are not yet taken into account; this algorithm only matches the data member names.
2. If the Java class has several member names that differ only in case, the data member name that exactly matches the IDL <PROPERTYNAME> (i.e. the one that is all caps) is called. Otherwise, the IDL-Java bridge issues an error that the class has no data members named <PROPERTYNAME>.
3. When setting a property with the SetProperty method, a promotion algorithm matches the provided IDL parameter with the Java data parameter as closely as possible. If the IDL value can be promoted to the same type as the data member, this data member is used. Otherwise, an error is issued.

When retrieving a property with the GetProperty method, this step is skipped and the value is returned to IDL.

Note: The allprops.pro and publicmembers.pro files in the resource/bridges/import/java/examples directory of the IDL distribution provide information about data members associated with given Java classes. Run the example procedures by entering allprops and publicmembers at the IDL command prompt or view the files in an IDL Editor window by entering .EDIT allprops.pro or .EDIT publicmembers.pro.

## Getting and Setting Properties

The IDL-Java bridge follows the standard IDL property interface to support data member access on Java objects and classes.

To retrieve a property value from a Java object, use the following syntax:

ObjRef->GetProperty, PROPERTY=variable

where ObjRef is an instance of IDLjavaObject that encapsulates the Java object, PROPERTY is the name of the Java object’s data member (property), and variable is the name of an IDL variable that will contain the retrieved property value.

Note: Use the function syntax if there is a return value (i.e. "result = ObjRef->GetProperty([PROPERTY])").

To retrieve multiple property values in a single statement supply multiple PROPERTY=variable pairs separated by commas.

To set a property value on a Java object, use the following syntax:

ObjRef->SetProperty, Property=value

where ObjRef is an instance of IDLjavaObject that encapsulates the Java object, PROPERTY is the name of the Java object’s data member, and value is value of the property to be set.

Note: Use the function syntax if there is a return value (i.e. "result = ObjRef->SetProperty([Property, value])").

To set multiple property values in a single statement supply multiple PROPERTY=value pairs separated by commas.

Note: The provided PROPERTY must map directly to a data member name. Any name passed into either of the property routines is assumed to be a fully qualified Java property name. As such, the partial property name functionality provided by IDL is not valid with IDL Java based objects.

The variable or value part may be an IDL primitive type, an instance of IDLJavaObject, or an array of an IDL primitive type. See IDL-Java Bridge Data Type Mapping for more information.

Note: Besides other Java-based objects, no complex types (structures, pointers, etc.) are supported as parameters to property calls.