Open topic with navigation

TIBCO Rendezvous® 8.7.0

# TibrvMsg.update()

Method

## Declaration

    void update(
        java.lang.String fieldName,
        java.lang.Object data)
      throws TibrvException
    void update(
        java.lang.String fieldName,
        java.lang.Object data,
        short            type)
      throws TibrvException
    void update(
        java.lang.String fieldName,
        java.lang.Object data,
        short            type,
        int              fieldId)
      throws TibrvException

## Purpose

Update a field within a message.

## Remarks

This method copies the new data into the message field. All related convenience methods behave similarly.

This method locates a field within the message by matching the `fieldName` and `fieldId` arguments. Then it updates the message field using the `data` argument. (Notice that only the value and count of the message field can change.)

If no existing field matches the specifications in the `fieldName` and `fieldId` arguments, then this method adds a new field to the message. Update convenience methods also add a field if it is not present.

The type of the existing message field and the type of the updating `field` argument must be identical; otherwise, the method throws an exception with the error status code TibrvStatus.INVALID_TYPE. However, when updating array or vector fields, the count (number of elements) can change.

Parameter | Description
`fieldName` | Update a field with this name. When absent, locate the field by identifier only.
`data` | Update a field using this data value. It is illegal to add or update a field with `null` data. To remove a field, use TibrvMsg.removeField().
`type` | Update a field with this type. When absent, determine the field’s type from the type of the data. Default encodings and possible conversions are identical to methods that add fields; see Java to Wire Format Datatype Conversion Matrix.
`fieldId` | Update a field with this identifier. All field identifiers must be unique within each message. Zero is a special value, indicating no identifier. It is illegal to add a field that has both a `null` field name, and a non-zero field identifier.

## Field Search Algorithm

This method, and related methods that update message fields, all use this algorithm to find and update a field within a message, as specified by a field identifier and a field name.

Procedure

| 1. | If the program supplied zero as the identifier, or omitted any identifier, then begin at step 3.

If the program supplied a non-zero field identifier, then search for the field with that identifier.

If the search succeeds, then update that field.

On failure, continue to step 2.

| 2. | If the identifier search (in step 1) fails, and the program supplied a non-`null` field name, then search for a field with that name.

If the search succeeds, then update that field.

If the name search succeeds, but the actual identifier in the field is non-`null` (so it does not match the identifier supplied) then throw an exception with the status code `TibrvStatus.ID_CONFLICT.`

If the search fails, add the field as specified (with name and identifier).

However, if the program supplied `null` as the field name, then do not search for the field name; instead, throw an exception with the status code `TibrvStatus.NOT_FOUND.`

| 3. | When the program supplied zero as the identifier, or omitted any identifier, then begin here.

Search for a field with the specified name—even if that name is `null`.

If the search fails, add the field as specified (with name and identifier).

If a message contains several fields with the same name, searching by name finds the first instance of the field with that name.

## Nested Message

When the new value is a message object, this method uses only the data portion of the nested message (`data`); it does not include any address information or certified delivery information.

Did you find this helpful?

Yes No
Great!
Thanks for taking the time to give us some feedback.
Sorry about that

Why wasn't this helpful? (check all that apply)

Could not find what I was looking for
Instructions confusing or unclear
Instructions did not work

Want to tell us more?

Please select at least one option or provide details about the issue!!

Error occurred while submitting feedback.

Error2 occurred while submitting feedback.

TIBCO Rendezvous®

Copyright © 1997-2023. Cloud Software Group, Inc. All Rights Reserved.