TibrvMsg.update()
Method
Declaration
voidupdate
(
java.lang.String fieldName,
java.lang.Object data)
throws TibrvException
voidupdate
(
java.lang.String fieldName,
java.lang.Object data,
short type)
throws TibrvException
voidupdate
(
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 |
|
Update a field with this name. When absent, locate the field by identifier only. |
|
Update a field using this data value. It is illegal to add or update a field with |
|
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. |
|
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 |
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.