Previous UML Classes Table of Contents UML Packages Next


17.5.13 StringExpression

Templates


   An expression that specifies a string value that is derived by concatenating a set of sub string expressions, some of which might be template parameters.

*Generalizations

   

    TemplateableElement (from Templates) on page 649

   

    Expression (from Kernel ) on page 69

   Description

   StringExpression is a specialization of the general Expression metaclass that adds the ability to contain sub expressions and whose operands are exclusively LiteralString s.

   Attributes

   No additional attributes

Associations

subExpression : StringExpression[0..*] The StringExpressions that constitute this StringExpression. Subsets
Element::ownedElement

Issue 8530 -add owningExpression item

   • owningExpression : StringExpression [0..1] The StringExpression of which this expression is a substring. Subsets

   Element::owner

   Constraints

   [1] All the operands of a StringExpression must be LiteralString s.

   operand->forAll (op | op.oclIsKindOf (LiteralString ))

   [2] If a StringExpression has sub expressions, it cannot have operands and vice versa (this avoids the problem of having to define a collating sequence between operands and subexpressions).

   if subExpression->notEmpty() then operand->isEmpty() else operand->notEmpty()

   Additional Operations

   [1] The query stringValue() returns the string that concatenates, in order, all the component string literals of all the subexpressions that are part of the StringExpression.

   StringExpression::stringValue() : String;

   if subExpression->notEmpty()then subExpression->iterate(se; stringValue = ‘’| stringValue.concat(se.stringValue())) else operand->iterate()(op; stringValue = ‘’ | stringValue.concat(op.value))

   Semantics

   A StringExpression is a composite expression whose elements are either nested StringExpressions or LiteralString s. The string value of the expression is obtained by concatenating the respective string values of all the subexpressions in order. If the expression has no subexpressions, the string value is obtained by concatenating the LiteralString s that are the operands of the StringExpression in order.

   Notation

    See the notation section of NamedElement (from Templates) on page 667.

   Examples

   See Figure 17.28 on page 669.

   Operation templates

Issue Editorial change - combine diagram 17.29 into 17.30 and remove 17.29

   The Operation templates diagram (Figure 17.29 on page 671) supports the specification of operation templates.