<Default Package>
Type event


Methods available on all event types.

Events are data objects which represent notifications of user-defined business events happening. There is no distinct "event" type, however these methods are available on all defined event types.

Here is an example of creating a simple event
event MySimpleEvent{}
Event types also contain data elements (called event "fields") and executable code known as actions, which can be in addition to those specified below. A field in an event can be any Apama type. If an event contains a field type which is not routable, then you cannot specify that type in an event template or send, emit, route or enqueue that event.

Here is an example of how to create an event with two event fields:
event MyEvent {
integer number;
string myString;
}
This event can then be instantiated using the following syntax:
MyEvent evt := MyEvent(1, "Test");
Alternatively, one can instantiate a blank event and populate the event fields later:
MyEvent evt := new MyEvent;
evt.number := 1;
evt.myString := "Test";
Events support an equality operator as long as all their fields are comparable and not cyclic. Events are equal if all of their fields are equal.

Events support the comparison operators (>, <, >=, <=) if all of their fields are comparable and not cyclic. Events are ordered according to the first field in order of definition which differs.

Event types are potentially cyclic (a type which directly or indirectly refers to itself), depending on the type of its fields.

Event types are parseable if all of their fields are parseable.

The default value of an event type is to have all of its members initialized to their default types.

Note that event types do not have a built-in hash() method, but if all of the members of the event are hashable it can be hashed via casting to an any:

(<any> ev).hash()

Action summary
 booleanstatic canParse(string s)

Check whether it is possible to parse the string argument as this event type.
 sequence<string>static getFieldNames()

Get the names of all the fields of this event type.
 sequence<string>static getFieldTypes()

Get the names of the types of each field of this event type.
 stringstatic getName()

Get the name of the event type.
 eventstatic parse(string s)

Parse the string argument as this event type.
 eventclone()

Create a new event which is a deep copy of this event.
 sequence<string>getFieldValues()

Get the values of each field.
 floatgetTime()

Get the timestamp of this event.
 booleanisExternal()

Check whether the event was externally generated.
 stringtoString()

Get the string form of this event.
 
Action detail

canParse

boolean static canParse(string s)
Check whether it is possible to parse the string argument as this event type.

This action only exists if the event type is parseable.
Parameters:
s - The string to check for parseability.
Returns:
True if it would be possible to parse this string as this event type. False otherwise.
See Also:
 - See the toString documentation for the string form.

getFieldNames

sequence<string> static getFieldNames()
Get the names of all the fields of this event type.
Returns:
A sequence of strings containing the name of each field of this event type, in definition order.

getFieldTypes

sequence<string> static getFieldTypes()
Get the names of the types of each field of this event type.
Returns:
A sequence of strings containing the name of the type of each field of this event type, in field definition order.

getName

string static getName()
Get the name of the event type.
Returns:
The name of the event type.

parse

event static parse(string s)
Parse the string argument as this event type.

This action only exists if the event type is parseable.
Parameters:
s - The string to parse, which must be the string form of an event of this type.
Returns:
The parsed event.
Throws:
Throws ParseException if the string cannot be parsed as this event type.
See Also:
 - See the toString documentation for the string form.

clone

event clone()
Create a new event which is a deep copy of this event.

If the event type is potentially cyclic, then any aliases (multiple references to a single object) will be preserved. If the event type is definitely acyclic, then multiple aliases to a single object will be copied to multiple separate objects.
Returns:
A deep copy of the event.

getFieldValues

sequence<stringgetFieldValues()
Get the values of each field.

Each event field is converted into its string form (with no escaping for strings).
Returns:
A sequence of strings containing the string form of each field, in field definition order.

getTime

float getTime()
Get the timestamp of this event.

The event time is calculated as follows: Event expressions involving multiple event templates may receive an event and set its timestamp before the listener code executes.

The accuracy of this timestamp is the accuracy of the correlator clock, typically 100ms.
Returns:
A float corresponding to the time in seconds since the epoch (Jan 1st 1970).

isExternal

boolean isExternal()
Check whether the event was externally generated.

Events are considered external if they were received from a non-EPL source. Events are considered internal if they were created or cloned within EPL. Routing, sending or enqueuing to a destination does not change the value of the external flag. Enqueuing with no destination from EPL will be treated as an external event. Spawning a monitor instance containing an event also does not change the value of the external flag.
Returns:
True if the event is external. False otherwise.

toString

string toString()
Get the string form of this event.

For non-cyclic types, the string form of the event is as follows:

FullyQualifiedName "(" ( FieldValue "," )* ")"

The FullyQualifiedName is either PackageName.EventName or, for monitor-internal events, PackageName.MonitorName.EventName. FieldValue is the string form of each field of this event. The field values are separated by commas. For example:

StockPrice("IBM", 70.5)

Potentially cyclic types may not be directly converted to strings. Instead, it labels objects as they are encountered during the creation of the string and adds a reference when a second instance of an already stringified object is encountered. References are of the form "@" followed by an object index, where the object index starts at 0 for the event being converted to a string and increments each time a new, unreferenced, object is encountered. For example:

Test([@0, Test([@0])])
Returns:
A string corresponding to the string form of this event.