Broker 10.5 | webMethods Broker Documentation | webMethods Broker Client Java API Programmer's Guide | Creating and Initializing Events | Regular Data Fields | Getting Regular Field Values
 
Getting Regular Field Values
Several methods are provided for obtaining the value of a regular event data field, based on its type. These methods are described in BrokerEvent.get<type>Field. The type of the value being retrieved depends on the field's type, as shown in the table below.
BrokerEvent Method
Value Type
getBooleanField
boolean
getByteField
byte
getCharField
char
getDateField
BrokerDate
getDoubleField
double
getFloatField
float
getIntegerField
int
getLongField
long
getShortField
short
getStringField
String
The following example contains an excerpt from a sample application that shows the use of the BrokerEvent.getIntegerField method. This method requires the name of the event field you want to retrieve.
BrokerEvent e;
int pub_count;
. . .
try {
pub_count = e.getIntegerField("count");
} catch (BrokerException ex) {
System.out.println("Error on getting count field\n"+ex);
return;
}
. . .
If you attempt to get a field value with a type that does not match the field's defined type, an exception might be thrown. Type checking will not occur if the event whose field is being obtained was created without a Broker client, as described in Field Type Checking.
You can also use the BrokerEvent.getField method to obtain the value and type of an event field.