Developing Apama Applications > Apama EPL Reference > Variables > Variable declarations > Reference-type variable declarations > Dictionary variable declarations
Dictionary variable declarations
A DictionaryDeclaration specifies a key type, a data type, an identifier, and an optional initializer.
DictionaryDeclaration
Rule component
The dictionary’s KeyType and DataType, separated by a comma, are enclosed in angle brackets. The KeyType defines the type of the dictionary’s key values. The DataType defines the type of the dictionary’s data values.
The Identifier becomes the dictionary variable’s name.
The initial dictionary size is determined by the number of entries in the ditionary’s initializer if one is present and zero otherwise.
Examples
dictionary<string, integer> dayNumbers;
dictionary<integer, string> dayNames;
DictionaryInitializer
Rule component
A DictionaryInitializer is a comma-separated list of expression pairs separated by colons. The entire list is enclosed in curly braces. Each expression value pair becomes an element in the dictionary. In each pair, the first expression value is the element’s key value and the second is the element’s data value.
The first expression result type in each pair must match the dictionary’s key type. The second must match the dictionary’s data type.
Examples
event PhoneticAlphabet
{
   action getPhoneticHexValues() returns dictionary <string, string>
   {
      dictionary <string, string> dict :=
       {"A":"Alfa", "B":"Bravo", "C":"Charlie", "D":"Delta",                 
"E":"Echo", "F":"Foxtrot"};
      return dict;
    }
}
 
dictionary <string, integer> dayNumbers :=
   {"Sunday": 1, "Monday":2, "Tuesday": 3, "Wednesday": 4,
    "Thursday": 5, "Friday": 6, "Saturday": 7};
 
dictionary <integer, string> dayNames :=
   {1: "Sunday", 2: "Monday", 3: "Tuesday",
    4: "Wednesday", 5: "Thursday", 6: "Friday",
    7: "Saturday"};
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.