Syntax for traversing hierarchical business objects

When you are writing code that requires that you traverse hierarchical business objects, you need to use the syntax that lets you specify attributes in elements in child business object arrays that are elements of child business object arrays, and other such complexities. This chapter specifies the syntax to use.

An attribute specification can be:

[[attributeName[index].]...]attributeName
 

This syntax expands to any of the following formats:

attributeName
 attributeName[index].attributeName
 attributeName[index]... .attributeName
 
Note:
Do not use the period (.) when creating a business object attribute name. If a business object attribute has a period within its name, a IBM WebSphere InterChange Server Express Map interprets the period as Java's dot operator and imparts special meaning to it. For example, "attribute.name"will be interpreted as "name" being a field or method for the "attribute" object.

Specifying an attribute of basic type

The following example uses the busObj.get() method to retrieve a basic type attribute named OrderID from the business object orderObj.

orderObj.get("OrderID"); 
 

Specifying an attribute in a child business object

The following example assumes that orderObj is a hierarchical business object. One of its attributes is CustomerInfo, a single-cardinality child business object. The example retrieves the customer name from the CustomerName attribute of CustomerInfo.

orderObj.get("CustomerInfo.CustomerName"); 
 

Specifying an attribute in a child of a child business object

If there is a chain of child business objects, in which CustomerInfo is a child of orderObj and AddressInfo is a child of CustomerInfo, you can retrieve city information from AddressInfo as follows:

orderObj.get("CustomerInfo.AddressInfo.City");
 

Specifying an attribute in an element of an array of child business objects

You can also refer to a child business object in an array by specifying its index in the array. The first element in the array always begins with zero. For example, the following example retrieves the value of the Quantity attribute from the third child business object in an array.

orderObj.get("LineItem[2].Quantity");
 

Copyright IBM Corp. 2003