Type casting

Type casting is used to refine the results of a query. A type is not assigned to schema elements that can have more than one valid type. You define the types for these elements with the cast to type feature in the schema view bar.

About this task

Type casting works essentially as an alternate filter for data source elements. A cast query filters the results of the regular query to return only the elements that can be cast to the selected type. After the type is selected, it becomes available in the Schema view under the anyType element. Queries built using cast allow access to all the child elements and attributes of the type cast. The result set returned by a cast query is identical to the result set returned by a query that is filtered with an equivalent IsKindOf predicate. The difference between the cast query and filtered query is that a cast query gives access to the cast type attributes and child elements while the filtered query does not.
Note: At present, the data sources that support type casting are, IBM® Rational® Tau and IBM Rational Rhapsody®.

Procedure

  1. Add a Container element in the editor area.
  2. Add the ownedMember class from the Data Source Schema view to this container. Name the container Class Container for easier reference.
  3. Add the Class type cast for the ownedMember by clicking the Cast to Type icon icon.
  4. Add a Paragraph element below the Container element, and add the name of the package inside the Class Container by dragging the Name(string) attribute.
  5. Add a new text element, and set its content to the static text (Active) by dragging the attribute from the Data Source Schema view.
  6. Right-click the Text element, and then click Data > Edit Condition.
  7. In the Set Condition for Current Element window, expand Attributes, and then select the check box for IsActive attribute. The selected attribute is added to the Left operand field in the right pane.
  8. In the right pane, select the Operator as Equals from the list.
  9. Select the Right operand as true from the list.
  10. Click OK.

Results

Adding a Class cast to the ownedMember element of a package allows defining the following query, which returns only the definitions that are classes from the same context:

Type Casting


Feedback