You can use ALH API to add a value to an object. For example, you can set a designated object, a feature of the designated object to which a value will be added, a value via object, a featureName, and a value parameter respectively.

You can add a value to an object using the code as follows

boolean addValue(StructuredValue object, String featureName, Object value)


If you have more than one value to add to an object, e.g., the value of the upper bound of the multiplicity is more than one, you can still add the values by using the parameter insertAt.

boolean addValueAt(StructuredValue object, String featureName, Object value, Integer insertAt)


The following code fragment shows how to add values to an object, e.g., System.p1, through ALH API.

ALH.addValue(System,”p1”,10);            // System.p1 = [10]
ALH.addValue(System,”p1”,30);            // System.p1 = [10, 30]
ALH.addValueAt(System,”p1”,20,2);        // System.p1 = [10, 20, 30]

Information

Alternatively, you can use ALH API through the fUML object syntax, with object.addValue(featureName, value) and object.addValueAt(featureName, value, insertAt). For example:

  • System.addValue(”p1”,10);          // System.p1 = [10]
  • System.addValue(”p1”,30);          // System.p1 = [10, 30]
  • System.addValueAt(”p1”,20,2);    // System.p1 = [10, 20, 30]