Skip navigation links

Package com.apama.event.parser

See: Description

Package com.apama.event.parser Description

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.

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 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);

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\"))");
	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);

	System.out.println("Field values: "+myString+", "+mySeq+", "+myDict+", "+myString2);
}

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")
		);
	String eventString = e.getText();
	System.out.println(eventString);
}	

Skip navigation links

Submit a bug or feature
Copyright (c) 2013-2017 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.