getAttrValue()

Retrieves the value of an attribute of a business object, given the attribute's name or its position in the business object's attribute list.

Syntax

void * getAttrValue(char * attrName);
 void * getAttrValue(int position);
 

Parameters

name [in]
Is the name of an attribute whose value is retrieved.
position [in]
Is 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, in the format defined for the attribute's data type. The method will return NULL if an invalid position is specified.

Notes

When you use getAttrValue(), make sure that you check the type of the attribute with getAttrType() before you assign the returned value to a variable. Based on the attribute type, cast the void pointer to a character pointer, a business object pointer, or a business object container before assigning the returned value to a variable.

WebSphere InterChange Server

Attribute values that are not business objects or business object containers are stored as strings in C++ to handle the special "Blank"or "Ignore" values. The Blank value means "Clear this field; there is no data in it." The Ignore value means "The collaboration doesn't know or care what is in this field."

To handle attribute values that are not business objects or business object containers, cast the void pointer to a character pointer, and then determine whether the attribute is a special value. If the attribute value is not a special value and is a data type other than a string, you will need to convert the value to the correct type.

If you pass an empty string (" ") or NULL as a parameter for the attribute name or position, the getAttrValue() method displays Error Message 73:

Failed to set the attribute value because the attribute position "{1}" or attribute type "{2}" is invalid.

If a business object has a specific attribute whose value has not been set, the getAttrValue() method returns NULL.

Examples

BusinessObject *pObj;
 void *attr;
 ...
 attr = pObj->getAttrValue(0):
 if (pObj->getAttrType(0) == BOAttrType::STRING)
 {
    char *attrStr = (char *) attr;
    if (pObj->isIgnoreValue(attrStr))
    {
       // ignore this value
    }
    else
       if (pObj->isBlankValue(attrStr))
       {
          // value should be blank
       }
 ...
 }
 

See also

getAttrName() getDefaultAttrValue() setAttrValue()

Copyright IBM Corp. 1997, 2003