Broker 10.5 | webMethods Broker Documentation | webMethods Broker Client Java API Programmer's Guide | Creating and Initializing Events | Regular Data Fields | Setting Regular Data Fields
 
Setting Regular Data Fields
Several methods are provided for setting a regular data field, based on it's type. These methods are described in BrokerEvent.set<type>Field. The source value for the field being set depends on the field's type, as shown in the table below.
BrokerEvent Method
Value Type
setBooleanField
boolean
setByteField
byte
setCharField
char
setDateField
BrokerDate
setDoubleField
double
setFloatField
float
setIntegerField
int
setLongField
long
setShortField
short
setStringField
String
The following example contains an excerpt from a sample application that shows the use of the BrokerEvent.setIntegerField method. This method takes the following parameters:
*The name of the event field to be set.
*The value for the field.
BrokerEvent e;
int count;
. . .
count = 1;
/* Publish */
while (count < num_to_publish) {
try {
e.setIntegerField("count",count);
} catch (BrokerException ex) {
System.out.println("Error on setting event field\n"+ex);
return;
}
. . .
If you attempt to set a field with a value that does not match its defined type, an exception might be thrown. Type checking will not occur if the event whose field is being set was created without a Broker client context, as described in Field Type Checking.
You can also use the BrokerEvent.setField method to set an event field.