On this page

Getting a structural feature value

You can use the following API in the fUML object syntax to retrieve a structural feature value:

object.get(featureName)


 

Information

Alternatively, you can use ALH API through the fUML object syntax, with object.get(featureName). For example:

  • value = object.get("speed");
object getValue(StructuredValue object, String featureName)


The following example shows how to get the value of the structural feature indicated above in ALH API.

value = ALH.getValue(object, "speed");

If the value of an object or a featureName is null, an IllegalArgumentException will be thrown.

Information

While using Rhino JavaScript, the return value of ALH.getValue() is not automatically UnBoxed to a primitive type. Users needs to handle such UnBoxing by themselves, by using ALH.getValue(object, "speed").intValue() to get the value of primitive integer type.



Specifying a structural feature value

You can use the following API to specify a structural feature value:

void setValue(StructuredValue object, String featureName, Object value)

The following example shows how to specify the value of the structural feature in ALH API:

value = ALH.setValue(object, "speed", "10");

If the value of an object or a featureName is null, an IllegalArgumentException will be thrown. However, null is acceptable for an assigned value.


In addition, the RuntimeObject can be omitted. The following example shows how to set a structural feature value without specifying a RuntimeObject in ALH API:

void setValue(String featureName, Object value)

Information

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

  • value = object.set("speed", "10");


Removing a value of an object

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

You can remove an object's value by executing the following code fragment

boolean removeValue(StructuredValue object, String featureName, Value value)


If you want to remove more than one value from an object, e.g., the value of the upper bound of the multiplicity is more than one, you can remove them by using the parameter removeAt.

boolean removeValueAt(StructuredValue object, String featureName, Integer removeAt)



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

print(System);							// System.p1 = [10, 20, 30]
ALH.removeValueAt(System,”p1”,3);       // System.p1 = [10, 20]
ALH.removeValue(System,”p1”,20);        // System.p1 = [10]


Adding a value to an object

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]


Removing a value of an object

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

You can remove an object's value by executing the following code fragment

boolean removeValue(StructuredValue object, String featureName, Value value)


If you want to remove more than one value from an object, e.g., the value of the upper bound of the multiplicity is more than one, you can remove them by using the parameter removeAt.

boolean removeValueAt(StructuredValue object, String featureName, Integer removeAt)



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

print(System);							// System.p1 = [10, 20, 30]
ALH.removeValueAt(System,”p1”,3);       // System.p1 = [10, 20]
ALH.removeValue(System,”p1”,20);        // System.p1 = [10]

Information

Alternatively, you can use ALH API through the fUML object syntax, with object.remove(featureName) and object.removeAt(featureName, removeAt). For example:

  • print(System);                             // System.p1 = [10, 20, 30]
  • System.removeAt(”p1”,3);  // System.p1 = [10, 20]
  • System.remove(”p1”,20);   // System.p1 =


Getting a tag value

You can use the following API to get a tag value:

object getTagValue(Object_ object, String tagName) throws Exception


If the RuntimeObject is omitted, $context$ or self will be used as an object. The context object in the parametric is the constraint block object that owns the constraint, not the actual context of the diagram. The following example shows how to get a tag value without specifying a RuntimeObject in ALH API:

object getTagValue(String tagName) throws Exception



The following code fragment shows how to get tag values, e.g., max, through ALH API. See also Value access and references by tags.

ALH.getTagValue(d, “uniform.max”);	// 10

Information

Alternatively, you can use ALH API through the fUML object syntax, with object.getTagValue(tagName). For example:

  • d.getTagValue(“uniform.max”);  // 10