Apama API Reference for .NET  10.2.0.3
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events Pages
Apama.Event.Event Class Reference

An Event object representing an event instance in flat event string format and/or structured format (as defined by its associated Apama.Event.Parser.EventType). More...

Public Member Functions

 Event (string eventString)
 Constructor to create an Event instance based on a raw event string. More...
 
 Event (string eventString, string channel)
 Constructor to create an Event instance based on a raw event string, and the channel More...
 
 Event (string eventString, string channel, double time)
 Constructor to create an Event instance based on a raw event string, and the channel and time when the event arrived. More...
 
 Event (EventType eventType)
 Constructor to create an Event based on an EventType. The name of the event will be derived from the eventType. More...
 
Object GetField (string name)
 Get the value of a field in this event instance (without generic type safety). More...
 
GetField< T > (Field< T > fieldDefinition)
 Get the value of a field in this event instance (recommended overload, with generic type safety). More...
 
GetField< T > (string fieldName, FieldType< T > fieldType)
 Get the value of a field in this event instance (with generic type safety). More...
 
virtual void SetEventParser (EventParser eventParser)
 Method to set the user-provided EventParser. If an EventParser is not provided, the EventParser.GetDefaultParser(false) will be used for parsing the event. More...
 
void SetField (string name, object value)
 Set the value of a field in this event instance (without generic type safety). More...
 
Event SetField< T > (Field< T > fieldDefinition, T value)
 Set the value of a field in this event instance (recommended overload, with generic type safety). More...
 
Event SetField< T > (string fieldName, FieldType< T > fieldType, T value)
 Set the value of a field in this event instance (with generic type safety). More...
 
override string ToString ()
 Retrieve the event's type and its contents as a String. This call is equivalent to the Text property. More...
 

Properties

string Channel [get, set]
 The channel name the event was received on. More...
 
virtual EventType EventType [get]
 Get the EventType for this Event. More...
 
virtual
System.Collections.Generic.IDictionary
< string, Object > 
FieldsMap [get]
 Provides access to the fieldName/value dictionary of the event fields. More...
 
string Name [get]
 The Name of the event type. More...
 
string Text [get]
 The Apama string representation of the event. More...
 
double Time [get, set]
 The time when the event was received. More...
 

Detailed Description

An Event object representing an event instance in flat event string format and/or structured format (as defined by its associated Apama.Event.Parser.EventType).

To get a parsed Event object from an event string, call Apama.Event.Parser.EventParser.Parse (or Apama.Event.Parser.EventType.Parse(string); to build up an Event from a set of field values, start by using the Event(EventType) constructor.

See the Apama.Event.Parser.EventType documentation for an example of how event strings may be generated and parsed using this class.

The event field values can be updated or retrieved by calling the SetField() and GetField() methods respectively.

In order to make the Event "known" to the Correlator, the event definition must be injected to the correlator by using the engine_inject command (or equivalent) before it is sent into the Correlator.

See also
Apama.Event.Parser.EventParser, Apama.Event.Parser.EventType, Apama.Event.Parser.StringFieldType, Apama.Event.Parser.IntegerFieldType, Apama.Event.Parser.FloatFieldType, Apama.Event.Parser.DecimalFieldType, Apama.Event.Parser.BooleanFieldType, Apama.Event.Parser.SequenceFieldType, Apama.Event.Parser.DictionaryFieldType, Apama.Event.Parser.OptionalFieldType

Constructor & Destructor Documentation

Apama.Event.Event.Event ( string  eventString)

Constructor to create an Event instance based on a raw event string.

E.g. "SampleEvent(\"field1Value",[1,2,3,4],2.0)" where an Event instance named SampleEvent will be created. In the above example, the event has three fields with values:

1st field = "field1Value", a String type 2nd field = [1,2,3,4], a sequence of integers 3rd field = 2.0, a float type

Parameters
eventStringThe event text (raw event). Can be null or "", in which case null or "" will be returned if user asked for the text with the Text property
Apama.Event.Event.Event ( string  eventString,
string  channel 
)

Constructor to create an Event instance based on a raw event string, and the channel

E.g. "SampleEvent(\"field1Value",[1,2,3,4],2.0)" where an Event instance named SampleEvent will be created. In the above example, the event has three fields with values:

1st field = "field1Value", a String type 2nd field = [1,2,3,4], a sequence of integers 3rd field = 2.0, a float type

Parameters
eventStringThe event text (raw event). Can be null or "", in which case null or "" will be returned if user asked for the text with the Text property
channelThe channel the event arrived on
Apama.Event.Event.Event ( string  eventString,
string  channel,
double  time 
)

Constructor to create an Event instance based on a raw event string, and the channel and time when the event arrived.

E.g. "SampleEvent(\"field1Value",[1,2,3,4],2.0)" where an Event instance named SampleEvent will be created. In the above example, the event has three fields with values:

1st field = "field1Value", a String type 2nd field = [1,2,3,4], a sequence of integers 3rd field = 2.0, a float type

Parameters
eventStringThe event text (raw event). Can be null or "", in which case null or "" will be returned if user asked for the text with the Text property
channelThe channel the event arrived on
timeThe time the event arrived
Apama.Event.Event.Event ( EventType  eventType)

Constructor to create an Event based on an EventType. The name of the event will be derived from the eventType.

Parameters
eventTypeTo use to create the Event

Member Function Documentation

Object Apama.Event.Event.GetField ( string  name)

Get the value of a field in this event instance (without generic type safety).

Consider using the generic type-safe alternatives GetField<T>(Field<T>) or GetField<T>(string, FieldType<T>) instead of this method.

The type of the value that is returned depends on which Apama Apama.Event.Parser.FieldType is associated with the field in the Apama.Event.Parser.EventType definition. For example, if the field's type is a SequenceFieldType(FloatFieldType.Type) then the returned value will be an object that implements the System.Collections.IList interface, and contains double objects for each float in the sequence. More information about the classes used to represent field values is available in the documentation for each com.apama.event.parser.*FieldType class.

If a value is not explicitly set then default value for the FieldType associated with this field in the EventType definition is returned. See defaultValue() method of the corresponding com.apama.event.parser.*FieldType class for more information about default value for this field.

Parameters
nameThe name of the field to retrieve
Returns
The value, which will never be null
Exceptions
Apama.Event.Parser.ParserRuntimeExceptionIf there was a problem during parsing of the event string, or if the specified field name is not a valid field in this event type.
See also
Apama.Event.Parser.FieldType, Apama.Event.Parser.FieldType<T>, GetField<T>(Field<T>)
T Apama.Event.Event.GetField< T > ( Field< T >  fieldDefinition)

Get the value of a field in this event instance (recommended overload, with generic type safety).

Parameters
fieldDefinitionThe field of interest. This is typically (but not necessarily) the Field object that was used to construct the EventType registered with the parser.
Returns
The value, which will never be null.
Exceptions
Apama.Event.Parser.ParserRuntimeExceptionParserRuntimeException if there was a problem during parsing of a event string or if the specified field is not a valid field in this event type. An exception should never be thrown if the field exists and the event was parsed from an event string.
See also
Apama.Event.Parser.Field<T>
T Apama.Event.Event.GetField< T > ( string  fieldName,
FieldType< T >  fieldType 
)

Get the value of a field in this event instance (with generic type safety).

Parameters
fieldNameThe name of the field whose value should be retrieved.
fieldTypeThe type of the field.
Returns
The value, which will never be null.
Exceptions
Apama.Event.Parser.ParserRuntimeExceptionParserRuntimeException if there was a problem during parsing of a event string or if the specified field is not a valid field in this event type. An exception should never be thrown if the field exists and the event was parsed from an event string.
See also
Apama.Event.Parser.Field<T>
virtual void Apama.Event.Event.SetEventParser ( EventParser  eventParser)
virtual

Method to set the user-provided EventParser. If an EventParser is not provided, the EventParser.GetDefaultParser(false) will be used for parsing the event.

Parameters
eventParserThe EventParser for parsing the event.
void Apama.Event.Event.SetField ( string  name,
object  value 
)

Set the value of a field in this event instance (without generic type safety).

Consider using the generic type-safe alternatives SetField<T>(Field<T>, T) or SetField<T>(string, FieldType<T>, T) instead of this method.

The type of the value that must be provided depends on which Apama Apama.Event.Parser.FieldType is associated with the field in the Apama.Event.Parser.EventType definition. For example, if the field's type is a SequenceFieldType(FloatFieldType.Type) then the value must be an object that implements the System.Collections.IList interface, and contains double objects for each float in the sequence. More information about the classes used to represent field values is available in the documentation for each com.apama.event.parser.*FieldType class.

Parameters
nameThe name of the field.
valueThe value of the field. The specified value must be assignable to the .NET type associated with the Apama FieldType for this field in the event definition. The null value is converted to default value for the FieldType associated with this field in the EventType definition. See defaultValue() method of the corresponding com.apama.event.parser.*FieldType class for more information about default value for this field.
Exceptions
Apama.Event.Parser.ParserRuntimeExceptionIf there was a problem during initial parsing of the original event string, or if the specified name is not a valid field for this event type.
See also
Apama.Event.Parser.FieldType, Apama.Event.Parser.FieldType<T>, SetField<T>(Field<T>, T)
Event Apama.Event.Event.SetField< T > ( Field< T >  fieldDefinition,
value 
)

Set the value of a field in this event instance (recommended overload, with generic type safety).

Note that on some early .NET compilers it may be necessary to explicitly specify the generic type parameter for container types when using a passing a value whose type is a concrete class rather than an interface, e.g. e.SetField<IList<double>>(f, new List<double>()).

Parameters
fieldDefinitionA field object representing the field's name and type.
valueThe value of the field. The null value is converted to default value for the FieldType associated with this field in the EventType definition. See defaultValue() method of the corresponding com.apama.event.parser.*FieldType class for more information about default value for this field.
Returns
Returns the same Event instance that the method was called on, to make it easy to set several field values in a single statement.
Exceptions
Apama.Event.Parser.ParserRuntimeExceptionIf there was a problem during initial parsing of original event string, or if the specified field name is not a valid field in this event type.
See also
Apama.Event.Parser.Field<T>
Event Apama.Event.Event.SetField< T > ( string  fieldName,
FieldType< T >  fieldType,
value 
)

Set the value of a field in this event instance (with generic type safety).

Parameters
fieldNameThe name of the field.
fieldTypeThe type of the field.
valueThe value of the field. The null value is converted to default value for the FieldType associated with this field in the EventType definition. See defaultValue() method of the corresponding com.apama.event.parser.*FieldType class for more information about default value for this field.
Returns
Returns the same Event instance that the method was called on, to make it easy to set several field values in a single statement.
Exceptions
Apama.Event.Parser.ParserRuntimeExceptionIf there was a problem during initial parsing of the original event string, or if the specified field name is not a valid field in this event type.
See also
Apama.Event.Parser.FieldType<T>
override string Apama.Event.Event.ToString ( )

Retrieve the event's type and its contents as a String. This call is equivalent to the Text property.

Returns
String containing the event's textual representation.

Property Documentation

string Apama.Event.Event.Channel
getset

The channel name the event was received on.

This currently only has meaning for events which have been sourced from the correlator, in which case it is set to the name of the channel the event was emitted from, or "" (the empty string) for the wildcard channel.

The event's channel name.

virtual EventType Apama.Event.Event.EventType
get

Get the EventType for this Event.

Returns
The EventType for this event. null if failure while parsing the event
virtual System.Collections.Generic.IDictionary<string, Object> Apama.Event.Event.FieldsMap
get

Provides access to the fieldName/value dictionary of the event fields.

Returns

The dictionary containing the event fields. Keys are the field names and values are the corresponding field values.

Note that the dictionary is NOT ordered, so callers should not expect a consistent or deterministic order (wrap the result in a SortedDictionary if that is required).

The resulting map should not be changed by the caller.

Exceptions
Apama.Event.Parser.ParserRuntimeExceptionIf there was a problem during initial parsing of a textual event.
See also
Apama.Event.Event.GetField<T>(Field<T>)
string Apama.Event.Event.Name
get

The Name of the event type.

The name of the event type, or null if the event string is null, invalid or empty

string Apama.Event.Event.Text
get

The Apama string representation of the event.

Returns
The string representation of the event; null if eventString is null or empty
double Apama.Event.Event.Time
getset

The time when the event was received.

This currently only has meaning for events which have been sourced from the correlator, in which case it is set to the correlator time at which it was created, or the value it was set to explicitly by code running within the correlator.

The event's timestamp

Submit a bug or feature
Copyright (c) 2013-2018 Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors. Use, reproduction, transfer, publication or disclosure is prohibited except as specifically provided for in your License Agreement with Software AG.