Package com.apama.event.parser
Represents the definition of an Apama event type, for which values are specified as
Event
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 Apamaany
type, for which values are specified as asAnyFieldValue
objects.AnyFieldValue Represents the value of an Apamaany field.BooleanFieldType Represents the Apamaboolean
type, for which values are eitherBoolean.TRUE
orBoolean.FALSE
.ChannelFieldType Represents the ApamaChannel
type, for which values are specified asString
objects.DecimalFieldType Represents the Apamadecimal
type, for which values are specified asDecimalFieldValue
objects.DecimalFieldValue Represents the value of an Apamadecimal field.DictionaryFieldType<K,V> Represents the Apamadictionary<key,item>
type, for which values are specified asMap
objects.EventParser EventType Represents the definition of an Apama event type, for which values are specified asEvent
objects.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 Apamafloat
type, for which values are specified asDouble
objects.IntegerFieldType Represents the Apamainteger
type, for which values are specified asLong
objects.LocationFieldType Represents the Apamalocation
type, for which values are specified asLocationType
objects.LocationType Represents the value of an Apamalocation
type, consisting of of two (x,y) co-ordinates.OptionalFieldType<T> Represents the Apamaoptional
type, for which values are specified asFieldType
objects.SequenceFieldType<E> Represents the Apamasequence<type>
type, for which values are specified asList
objects.StringFieldType Represents the Apamastring
type, for which values are specified asString
objects. -
Exception Summary Exception Description ParserRuntimeException ParserRuntimeException will be thrown when an error occurs while parsing an Apama event.