Broker 10.15 | webMethods Broker Documentation | webMethods Broker Client Java API Programmer's Guide | Creating and Initializing Events | Sequence Data Fields | Setting Sequence Fields
 
Setting Sequence Fields
Several methods are provided for setting the values of the entire sequence, or a subset of the sequence. These methods are described in BrokerEvent.set<type>SeqField.
You can also use the BrokerEvent.set<type>Field to set a single value within a sequence field by specifying the field name with an index.
The following example shows the use of the BrokerEvent.setIntegerSeqField method. This method takes the following parameters:
*The name of the event sequence field to be set.
*The number of elements to skip from the beginning of the source array parameter.
*The number of elements to skip from the beginning of the target sequence in the event.
*The number of elements to be set.
*The source array of values of the appropriate type.
Setting the values of an event sequence field
int count[5] = { 0, 1, 2, 3, 4};
. . .
try {
e.setIntegerSeqField("count", 0, 0, 5, count);
} catch (BrokerException ex) {
System.out.println("Error on setting sequence field\n"+ex);
return;
}
. . .
The manner in which the source array is specified depends on the array's type.
BrokerEvent Method Name
Sequence Value Type
setBooleanSeqField
boolean[]
setByteSeqField
byte[]
setCharSeqField
char[]
setDateSeqField
BrokerDate[]
setDoubleSeqField
double []
setFloatSeqField
float[]
setIntegerSeqField
int[]
setLongSeqField
long[]
setShortSeqField
short[]
setStringSeqField
string[]
Each of the BrokerEvent.set<type>SeqField methods can overwrite all or part of the destination sequence field. After the code shown in the example in Setting Sequence Fields is executed, the sequence will contain:
[0 1 2 3 4]
If you then set three elements (3, 2, 1) into this same sequence at location 1, the sequence would then appear as:
[0 3 2 1 4]
An error will be returned if you attempt to set a field with a value that does not match its defined type.
These methods can also cause the destination sequence to grow in size, if a larger number of elements are stored into the sequence.
These methods never reduce the number of elements in the destination sequence. Use the BrokerEvent.setSequenceFieldSize method to reduce the size of a sequence field.
You can also use the BrokerEvent.setSequenceField method to set a sequence field.