\r\n

51Degrees API Documentation  4.4

Introduction

Element data key is the key that is used to store and retrieve element data within the flow data. Each flow element has a hard-coded key value.

Structure

Element data key will always have a string name that is used as the key when storing the element data within flow data.

In addition, in strongly-typed languages such as Java and C#, element data key will also contain the specific type of the element data that it corresponds to. This allows the flow data to return the element data instance as the correct type.

Name conflicts

The Pipeline does not require that each flow element has a unique element data key. In fact, it is sometimes desirable for this to be the case. However, care must be taken to ensure that conflicting key names do not cause unexpected behavior or errors.

The Pipeline does not define what happens in the case of element data key conflicts. The handling of such conflicts is left up to individual flow elements. The flow element base functionality also does not specify what should happen. This is because flow elements are not even required to create an element data instance at all.

The aspect engine base class does explicitly allow conflicting key names, although it is still up to specific implementations to operate responsibly.

Name conflict example

Consider a Pipeline with two device detection engines. One determines values relating to the device hardware. (i.e. manufacturer, screen information, CPU/GPU specs, etc.) The other determines values relating to the software platform or operating system running on the device. (i.e. software vendor, name, version, etc.)

Each of these engines uses the same element data key as shown below:

At step 1, the flow data enters the Pipeline with no element data. At step 2, the Hardware device detection engine has created the element data and added it to flow data using the key 'device'. It will be populated with details of the device hardware but other values relating to the software platform will not have been set. The Platform/OS device detection engine will see that an element data instance already exists in the flow data for its element data key. Rather than creating a new one, it will take that instance and update it with values relating to the OS running on the device.

Note that, as long as the flow data has been set up correctly for it, this example will continue to work if the two engines are configured to run in parallel.