Package com.apama.event.parser
Warning: This API is deprecated and will be removed in a future version.
Represents the definition of an Apama event type, for which values are specified asEvent objects.
Each EventType consists of an event type name, and zero or more Field objects.
An event that contains an 'any' field must be registered to exactly one EventParser object, along with all types that may be contained within the 'any' value.
Example: EVENT_PARSER.registerType(FieldTypes.sequence(FieldTypes.INTEGER));
Example usage:
static final Field<String> FIELD_MY_STRING = FieldTypes.STRING.newField("myString");
static final Field<List<Double>> FIELD_MY_SEQ = FieldTypes.sequence(FieldTypes.FLOAT).newField("mySeq");
static final Field<Map<String,Long>> FIELD_MY_DICT = FieldTypes.dictionary(FieldTypes.STRING, FieldTypes.INTEGER).newField("myDict");
static final Field<AnyFieldValue> FIELD_ANY = new AnyFieldType().newField("anyField");
static final EventType EVENT_NESTED = new EventType("sample.NestedEvent", FIELD_MY_STRING);
static final Field<Event> FIELD_NESTED = EVENT_NESTED.newField("myNested");
static final EventType EVENT_MY_EVENT = new EventType("sample.MyEvent", FIELD_MY_STRING, FIELD_MY_SEQ, FIELD_MY_DICT, FIELD_NESTED, FIELD_ANY);
static final EventParser EVENT_PARSER = new EventParser(EVENT_MY_EVENT);
public void demonstrateParsingAndGettingFieldValues()
{
Event e = EVENT_PARSER.parse("sample.MyEvent(\"Hello\",[1.5,2.3],{\"myDictKey\":123},sample.NestedEvent(\"Nested Hello\"), any(integer,4321))");
String myString = e.getField(FIELD_MY_STRING);
List<Double> mySeq = e.getField(FIELD_MY_SEQ);
Map<String,Long> myDict = e.getField(FIELD_MY_DICT);
String myString2 = e.getField(FIELD_NESTED).getField(FIELD_MY_STRING);
Object anyField = e.getField(FIELD_ANY);
System.out.println("Field values: "+myString+", "+mySeq+", "+myDict+", "+myString2 + ", "+ anyField);
}
public void demonstrateSettingFieldValues()
{
Event e = new Event(EVENT_MY_EVENT)
.setField(FIELD_MY_STRING, "Hello")
.setField(FIELD_MY_SEQ, Arrays.asList(1.5, 2.3D))
.setField(FIELD_MY_DICT, Collections.singletonMap("myDictKey", 123L))
.setField(FIELD_NESTED,
new Event(EVENT_NESTED)
.setField(FIELD_MY_STRING, "Nested Hello"))
.setField(FIELD_ANY,new AnyFieldValue(FieldTypes.STRING, "ANY_AS_STRING"));
String eventString = e.getText();
System.out.println(eventString);
}
-
Class Summary Class Description AnyFieldType Represents the Apamaanytype, for which values are specified as asAnyFieldValueobjects.AnyFieldValue Represents the value of an Apamaany field.BooleanFieldType Represents the Apamabooleantype, for which values are eitherBoolean.TRUEorBoolean.FALSE.ChannelFieldType Represents the ApamaChanneltype, for which values are specified asStringobjects.DecimalFieldType Represents the Apamadecimaltype, for which values are specified asDecimalFieldValueobjects.DecimalFieldValue Represents the value of an Apamadecimal field.DictionaryFieldType<K,V> Represents the Apamadictionary<key,item>type, for which values are specified asMapobjects.EventParser EventType Represents the definition of an Apama event type, for which values are specified asEventobjects.Field<T> Represents the name and type of a field in anEventType.FieldType<T> Represents an Apama type.FieldTypes Provides factory methods and constants for getting all supported Apama event field types.FloatFieldType Represents the Apamafloattype, for which values are specified asDoubleobjects.IntegerFieldType Represents the Apamaintegertype, for which values are specified asLongobjects.LocationFieldType Represents the Apamalocationtype, for which values are specified asLocationTypeobjects.LocationType Represents the value of an Apamalocationtype, consisting of of two (x,y) co-ordinates.OptionalFieldType<T> Represents the Apamaoptionaltype, for which values are specified asFieldTypeobjects.SequenceFieldType<E> Represents the Apamasequence<type>type, for which values are specified asListobjects.StringFieldType Represents the Apamastringtype, for which values are specified asStringobjects. -
Exception Summary Exception Description ParserRuntimeException ParserRuntimeException will be thrown when an error occurs while parsing an Apama event.