3.6.1 Using the Result.getValue() Method

The data is retrieved from a ServletResult by providing a key that corresponds to the parameter names of the Tuxedo service, as defined in the Metadata Repository. You supply the key to the appropriate getValue() method, which returns the corresponding value object.

The Result.getValue() method also expects a default value object; this is returned if the key lookup fails. It is your responsibility to cast the returned object to the appropriate type, as defined by the Tuxedo service. For example, this line of code:

Integer answer = (Integer) resultSet.getValue("Age",null);

sets the integer answer to the returned value in the ServletResult identified by the key "Age", or returns null if this key does not exist in the ServletResult. Refer to the table in “Converting Java Data Types to Tuxedo Data Types” for the Java equivalents of the Tuxedo types.

It is possible to have an array of values associated with a key. In this case, the simple getValue() method returns the first element of an array in this instance. Use this method signature in that case:

public Object getValue(String name, int index, Object defVal)

to reference a particular indexed element in an array value.