Reference data types
In addition to the primitive types, EPL provides for a number of object types. These types are manipulated by reference as opposed to by value (in the same way as complex types are handled in Java). They are:
When a variable of reference type is assigned to another one of the same type, the latter will reference the same object as the former, and should one be changed, the other one would reflect the change as well.
If you require a variable of reference type to contain a copy of another one of the same type, that is a completely distinct but identical copy, then you should use the clone() method as described below. This returns a deep copy of the variable, that is, it copies it and all its contents (and their contents in turn) recursively.
The string type is technically a reference type, but unlike all other reference types, the string type is immutable; its value cannot change. The clone() method has no effect on strings, as they cannot be changed.
Note that you cannot use an object type for matching in an event template. For example, suppose you have the following event types:
InnerEvent
{
float f;
}
WrapperEvent
{
string s;
InnerEvent anInnerEvent;
}
The following statement is correct:
on all WrapperEvent(s = "some_string")
However, the following statement is not allowed:
on all WrapperEvent(anInnerEvent.f = 5.5)
More than one variable can have a reference to the same underlying data value. For example, consider the following code:
sequence <integer> s1;
sequence <integer> s2;
s1 := [12, 55, 42];
s2 := s1;
print s1[1].toString; // print second element of s1
s2[1] := 99; // change the second element
print s1[1].toString; // print second element of s1 again
Both s1 and s2 refer to the same array, so whichever variable you use, there is only one copy of the data values. So the program’s output is
55
99
ReferenceDataTypeName
Copyright © 2013
Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA, and/or Terracotta Inc., San Francisco, CA, USA, and/or Software AG (Canada) Inc., Cambridge, Ontario, Canada, and/or, Software AG (UK) Ltd., Derby, United Kingdom, and/or Software A.G. (Israel) Ltd., Or-Yehuda, Israel and/or their licensors.