Developing Apama Applications > Developing Apama Applications in EPL > Defining Event Listeners > Defining event expressions with one event template > Using name/value syntax to listen for events with particular content
Using name/value syntax to listen for events with particular content
Specification of every field in an event can get unwieldy when you are working with event types with a large number of fields and you are specifying values for only a few of them. In this case, you can use the name/value syntax in which you specify only the fields of interest. In the name/value syntax, it is as if you had specified a wildcard (*) for each field for which you do not specify a value. For example:
on MobileUser(hairColour="red", starsign="Capricorn",
    preferredGender=1) some_action();
The table below shows equivalent event expressions that demonstrate how to specify each syntax. The table uses these event types:
event A {
   integer a;
   string b;
}
 
event B {
   integer a;
}
 
event C {
 integer a;
   integer b;
   integer c;
}
Comparison of positional and name/value syntax in event expressions
Comparison Criterion
Positional Syntax
Equivalent Name/Value Syntax
Equality
on A(3,"string")
on A(=3,="string")
on A(a=3,b="string")
on A(b="string",a=3)
Relational comparisons
on B(>3)
on B(a>3)
Ranges
on B([2:3])
on B(a in [2:3])
Wildcards
on C(*,4,*)
 
on C(*,*,*)
on C(b=4)
on C(a=*,b=4,c=*)
on C()
For details about the operators and expressions that you can specify in event templates, see Expressions in the Apama EPL Reference.
It is possible to mix the two syntax styles as long as you specify all positional fields before named fields. For example:
*Correct event template: on D(3,>4,i in [2:4])
*Incorrect event template: on D(k=9,"error")
Copyright © 2013 Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA, and/or Terracotta Inc., San Francisco, CA, USA, and/or Software AG (Canada) Inc., Cambridge, Ontario, Canada, and/or, Software AG (UK) Ltd., Derby, United Kingdom, and/or Software A.G. (Israel) Ltd., Or-Yehuda, Israel and/or their licensors.