Concept Property Arrays
To work with concept property arrays you need to follow certain rules.
Accessing a Concept Property Array
This is the syntax for accessing a concept property array:
instanceName.propertyName
where
instanceName
is the identifier of the concept instance, and
propertyName
is the name of the concept property that you want to access.
Accessing a Value in a Concept Property Array
To access a value in a property array, identify the position in the array of the value as shown:
instanceName.propertyName[indexPosition]
For example:
String x = instanceA.lineItem[0];
This gets the current value of the first property atom in the array,
lineItem
, and assigns it to the local variable, x.
Setting the Value for an Existing Concept Property Array Position
You can set the value of an existing position in an array. For example:
int[] ii = {1,2,3}; ii[2] = 1;
Adding a Value to a Concept Property Array
You can append a value to the end of a property array. You cannot, however, add a value to any other position in an array. This is the syntax:
instanceName.propertyName[indexPosition] = value
To use the syntax shown above you must know the index position of the end of the array. You can append a value to the end of an array without knowing the index position of the end of the array using the @length attribute as shown:
instanceName.propertyName[instanceName.propertyName@length] = value
Deleting Values in a Property Array
This is the syntax for deleting an array property:
Instance.PropertyArray.delete(instanceName.propertyName,indexPosition);
Array identifier numbers are positional. When history is not tracked and you delete multiple items in an array (using a for loop), delete higher position numbers before lower position numbers to ensure the correct entries are deleted. For example, if you want to delete items in positions 1, 2, and 4, delete them in this order: 4, 2, and then 1.
The array entry that held a deleted concept is removed, reducing the array size by one, and reducing by one the index of every entry in the array at a higher index than the deleted one. If you delete entries with lower position numbers first, the remaining lower numbers are then occupied by different items.
For example, if you delete the item in position 1, then the item that was in position
2
is now in position
1
.
Checking if Multiple Property of a Concept is Empty
If you have a concept (for example, CustomerConcept) which contains multiple property (for example, address) and you did not pass any value to the address property when creating the concept then the following check always returns false:
customerConcept.address == null
The reason for this is that the multiple check on a concept property (simple property, ContainedConcept, or ConceptReference) makes the property an array. Even if you do not add any property, ContainedConcept, or ConceptReference to the multiple property, the property is an array with the length zero but not null.
Thus, to resolve this, for a multiple property (simple property, ContainedConcept, or ConceptReference), check the length of the property (array). The length zero indicates there is no simple property, ContainedConcept, or ConceptReference.