Required attributes in a model class

A model element can contain attributes of different types, both primitive and complex.

A model element typically consists of one or more of the following types:
Attribute type Description
Primitive, except byte or byte arrays
  • Call the appropriate setProperty() method to set the property of the element. Various overrides exist for all primitive types except byte.
Byte array or large strings
  • To store binary data, the attribute must be of LTAnnotation type or one that extends it. This class has setBytes() and getBytes() methods to store and retrieve binary information. After the getBytes() or setBytes() is called, the data is maintained in memory until the test is saved.
    Note: If this action is not wanted–and it is not in cases where the data set can be large, you can flush the data to a file by individually calling the flush() method on the LTAnnotation. Make sure that you call this method immediately after a set or get is called.
Complex
  • Call setProperty(CBActionElement,CBActionElement) to which you can pass the old and the new value of the attribute. All model elements extend from the CBActionElement class. The old value is passed so that it can be removed from the model and the new value is passed, so it can be set. If you do not have a value, then pass null. For example, if the value is changing from val1 to val2, then call the setProperty(val1,val2) method. If you are setting the value for the first time, call the setProperty(null,val1) method. If you want to clear the value, call setProperty(val1,null).
  • This is similar to the other setProperty() methods for the primitive type, with the added restriction that this needs the old value too.
  • When the model gets loaded, the addReference() method will be called and this method needs to be overwritten to interpret and properly assign the attribute to the object. Call the appropriate setXXX() method to set that attribute with the value passed in.
List
  • The attribute should be of type EList. To access the list, if the element is a container, then it can implement the LTElementHost interface and will need to implement the getElements() method. This method must return the EList. To load the list when the children of this model element are being loaded, the addReference() method is called for each child and the element must put the child in the right list.
Reference to another model element
  • Define an attribute of the type of the element you reference. This will provide the simple getters and setters to this attribute. These getters or setters will not call getProperty or setProperty, but they will simply get or set the attribute value.
  • Define another attribute that will act as a proxy for this element. This element is your own class that extends ProxyElement from the LTBM.
  • When creating the reference, call the setHref() method of the ProxyElement with the ID (getId()) of the element that is being referenced.
  • To get the element that is being referenced, use the href from the ProxyElement (getHref()) to locate the element in the test. You can also use the BehaviorUtil.findElement() method (the test containing this element, the ID of the element being searched) to get the element.