set()

Set a business object's attribute to a specified value of a particular data type.

Syntax

void set(String attribute
 
 Object value)
 void set(int position, Object value)
 
void set(String attribute
 boolean value)
 void set(String attribute
 double value)
 void set(String attribute
 float value)
 void set(String attribute
 int value)
 void set(String attribute
 long value)
 void set(String attribute
 
 Object value)
 void set(String attribute
 String value)
 

Parameters

attribute
The name of the attribute to set.

position
An integer that specifies the ordinal position of an attribute in the business object's attribute list.

value
An attribute value.

Exceptions

CollaborationException--The set() method can set the following exception type for this exception:

Notes

The set() method sets an attribute value in the current business object. This method sets an object reference to the value parameter when it assigns the value to the attribute. It does not clone the attribute value from the source business object. Therefore, any changes to value in the source business object are also made to the attribute in the business object that calls set().

The set() method provides the following forms:

Examples

The following example sets the LName attribute in toCustomer to the value Smith.

toCustomer.set("LName", "Smith");
 

The following example illustrates how set() assigns an object reference instead of cloning the value:

BusObj BusObj myBusObj = new BusObj();
 BusObj mySettingBusObj = new BusObj();
  
 myBusObj.set("attr1", mySettingBusObj);
 

After this code fragment executes, the attr1 attribute of myBusObj is set to the mySettingBusObj business object. If mySettingBusObj is changed in any way, myBusObj.attr1 is changed in the exact manner because set() makes an object reference to mySettingBusObj when it sets the attr1 attribute; it does not create a static copy of mySettingBusObj.

The following example sets an attribute value using the attribute's ordinal position within the attribute list:

for i=0; i<maxAttrCount; i++)
 {
         myBusObj.set(i, strValue);
     ...
 

Copyright IBM Corp. 1997, 2003