getBoolean(), getDouble(), getFloat(), getInt(), getLong(), get(), getBusObj(), getBusObjArray(), getLongText(), getString()

Retrieve the value of a single attribute from a business object.

Syntax


 
 Object get(String attribute)
 Object get(int position)
 

 boolean getBoolean(String attribute)
 
  
 double getDouble(String attribute)
 
  
 float getFloat(String attribute)
 
  
 int getInt(String attribute)
 
  
 long getLong(String attribute)
 
 
  
 Object get(String attribute)
 BusObj getBusObj(String attribute)
 BusObjArray getBusObjArray(String attribute)
 
  
 String getLongText(String attribute)
 
  
 String getString(String attribute)
 

Parameters

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

Return values

The value of the specified attribute.

Exceptions

CollaborationException--These get methods can set the following exception type for this exception:

Notes

The get() method retrieves an attribute value from the current business object. It returns a copy of the attribute value. It does not return an object reference to this attribute in the source business object. Therefore, any change to attribute value in the source business object is not made to the value that get() returns. Each time this method is called, it returns a new copy (clone) of the attribute.

The get() method provides the following forms:

Examples

The following example illustrates how get() returns a copy (clone) of the attribute value instead of an object reference:

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

After this code fragment executes, if you change the Extract business object, mySettingBusObj does not change because the get() call returned a copy of the attr1 attribute.

The following example uses getBusObj() to retrieve a child business object containing a customer address from the customer business object and assign it to the variable address.

BusObj address = customer.getBusObj("Address");
 

The following example uses getString() to retrieve the value of the CustomerName attribute. The business object variable is sourceCustomer.

String customerName = sourceCustomer.getString("CustomerName");
 

The following example uses getInt() to retrieve the Quantity values from two business objects whose variables are item1 and item2. The example then computes the sum of both quantities.

int sumQuantity = item1.getInt("Quantity") + item2.getInt("Quantity");
 

The following example retrieves the attribute Item from the business object variable order. The attribute Item is a business object array.

BusObjArray items = order.getBusObjArray("Item");
 

The following example gets the CustID attribute value from the source business object and sets the Customer value in the destination business object to match.

destination.set("Customer", source.get("CustID"));
 

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

for i=0; i<maxAttrCount; i++)
 {
         String strValue = (String)myBusObj.get(i);
     ...
 

Copyright IBM Corp. 2003