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

Represents the definition of an Apama event type, for which values are specified as Apama.Event.Event objects. Each EventType consists of an event type name, and zero or more Field<T> objects. More...

Inherits Apama.Event.Parser.FieldType< T >.

Public Member Functions

void AddField (Field field)
 Method to append extra field to the EventType. More...
 
void AddField (string name, FieldType fieldType)
 Method to append extra field to the EventType. More...
 
override Event DefaultValue ()
 Get the default value for Event field type. More...
 
override bool Equals (Object obj)
 Determines whether two EventType objects are equal More...
 
 EventType (string name, params Field[] fields)
 Create a new Event Type by specifying the name of the event and the FieldType of each of the event parameter. More...
 
bool FieldExists (string fieldName, FieldType fieldType)
 Method to check if this EventType contains a field with name fieldName AND type fieldType. More...
 
Field GetField (string fieldName)
 Get a named field. More...
 
override int GetHashCode ()
 The hash function for EventType More...
 
override Event Parse (string value)
 Parse a token according to syntax rules of this type. More...
 
override string ToString ()
 Returns a String representation of the event type. Note that this representation is not valid monitorscript. More...
 
- Public Member Functions inherited from Apama.Event.Parser.FieldType< T >
Field< T > NewField (string name)
 Creates a new Field object with the specified name, using this field type. More...
 
abstract T Parse (String value)
 Parse a token according to syntax rules of this type. More...
 
- Public Member Functions inherited from Apama.Event.Parser.FieldType
virtual string Format (Object value)
 Format the given value in MonitorScript representation. More...
 
abstract object GetDefaultValue ()
 Get the default value for this field type. More...
 
abstract object ParseObject (String value)
 Parse a value from this type's Apama event string representation into the .NET object representation of the value. More...
 
override string ToString ()
 For Internal use only More...
 

Properties

ReadOnlyCollection< string > FieldNames [get]
 Method to retrieve the field names as a string array for the event. More...
 
- Properties inherited from Apama.Event.Parser.FieldType
string Name [get]
 Return the name of this type. More...
 
Type TypeClass [get]
 Return the .NET type used to express values of this Apama field type. More...
 

Additional Inherited Members

- Protected Member Functions inherited from Apama.Event.Parser.FieldType
 FieldType (string typeName, Type clazz)
 Create a new FieldType. More...
 

Detailed Description

Represents the definition of an Apama event type, for which values are specified as Apama.Event.Event objects. Each EventType consists of an event type name, and zero or more Field<T> objects.

The EventType class is not fully thread-safe, but once it has been initialized with all the required fields it is safe to concurrently use it to parse and create event strings from any thread, provided fields are not added or removed from the event type (which would never happen in typical usage anyway).

struct MyEvents
{
public static readonly Field<string> myString = FieldTypes.String.NewField("myString");
public static readonly Field<IList<double>> mySeq = FieldTypes.Sequence(FieldTypes.Float).NewField("mySeq");
public static readonly Field<IDictionary<String,long>> myDict = FieldTypes.Dictionary(FieldTypes.String, FieldTypes.Integer).NewField("myDict");
public static readonly EventType nestedEventType = new EventType("sample.NestedEvent", myString);
public static readonly Field<Event> myNested = nestedEventType.NewField("myNested");
public static readonly EventType myEvent = new EventType("sample.MyEvent", myString, mySeq, myDict, myNested);
public static readonly EventType myEvent2 = new EventType("sample.MyEvent2", myString);
}
static readonly EventParser eventParser = new EventParser(MyEvents.myEvent);
public void demonstrateParsingAndGettingFieldValues()
{
Event e = eventParser.Parse("sample.MyEvent(\"Hello\",[1.5,2.3],{\"myDictKey\":123},sample.NestedEvent(\"Nested Hello\"))");
string myString = e.GetField(MyEvents.myString);
IList<double> mySeq = e.GetField(MyEvents.mySeq);
IDictionary<string,long> myDict = e.GetField(MyEvents.myDict);
string myString2 = e.GetField(MyEvents.myNested).GetField(MyEvents.myString);
Console.WriteLine("Field values: myString=" + myString + ", mySeq.Count=" + mySeq.Count +
", myDict[myDictKey]=" + myDict["myDictKey"] + ", myString2=" + myString2);
}
public void demonstrateSettingFieldValues()
{
IDictionary<string, long> dict = new Dictionary<string, long>();
dict["myDictKey"] = 123;
IList<double> seq = new double[]{1.5, 2.3};
Event e = new Event(MyEvents.myEvent)
.SetField(MyEvents.myString, "Hello")
.SetField(MyEvents.mySeq, seq)
.SetField(MyEvents.myDict, dict)
.SetField(MyEvents.myNested,
new Event(MyEvents.nestedEventType)
.SetField(MyEvents.myString, "Nested Hello")
);
String eventString = e.Text;
Console.WriteLine(eventString);
// some compilers may require explicit generic type arguments when used with a
// non-interface container type (e.g. List not IList)
List<double> seqList = new List<double>(new double[] { 1.5, 2.3 });
e.SetField<IList<double>>(MyEvents.mySeq, seqList);
}

Constructor & Destructor Documentation

Apama.Event.Parser.EventType.EventType ( string  name,
params Field[]  fields 
)

Create a new Event Type by specifying the name of the event and the FieldType of each of the event parameter.

Parameters
nameThe name of this type
fieldsField definitions for each event parameter

Member Function Documentation

void Apama.Event.Parser.EventType.AddField ( Field  field)

Method to append extra field to the EventType.

Parameters
fieldA new field to append to the eventType. New applications are recommended to use the generic Field<T> type, although the legacy Field is also supported for backwards compatability reasons.
void Apama.Event.Parser.EventType.AddField ( string  name,
FieldType  fieldType 
)

Method to append extra field to the EventType.

Parameters
nameName of the field
fieldTypeOf the new field to be added New applications are recommended to use the generic FieldType<T> type, although the legacy FieldType is also supported for backwards compatability reasons.
override Event Apama.Event.Parser.EventType.DefaultValue ( )
virtual

Get the default value for Event field type.

Returns
An empty Event

Implements Apama.Event.Parser.FieldType< T >.

override bool Apama.Event.Parser.EventType.Equals ( Object  obj)

Determines whether two EventType objects are equal

Parameters
objThe object to compare for equality
bool Apama.Event.Parser.EventType.FieldExists ( string  fieldName,
FieldType  fieldType 
)

Method to check if this EventType contains a field with name fieldName AND type fieldType.

Parameters
fieldNameThe fieldName to check
fieldTypeThe fieldType to match
Returns
True if the fieldName exists with type fieldType. False otherwise.
Field Apama.Event.Parser.EventType.GetField ( string  fieldName)

Get a named field.

Parameters
fieldNameThe fieldName to check
Returns
The Field object for the named field, or null if the name does not exist.
override int Apama.Event.Parser.EventType.GetHashCode ( )

The hash function for EventType

override Event Apama.Event.Parser.EventType.Parse ( string  value)

Parse a token according to syntax rules of this type.

Parameters
valueThe value to parse
Returns
An Object of Event type
Exceptions
ParserRuntimeExceptionIf some problem occurs
override string Apama.Event.Parser.EventType.ToString ( )

Returns a String representation of the event type. Note that this representation is not valid monitorscript.

Property Documentation

ReadOnlyCollection<string> Apama.Event.Parser.EventType.FieldNames
get

Method to retrieve the field names as a string array for the event.

Returns
fieldName array
Submit a bug or feature
Copyright (c) 2013-2016 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.