Difference between revisions of "Acceleo/OCL Operations Reference"

From Eclipsepedia

Jump to: navigation, search
m (Formatting)
(Formatting)
 
(10 intermediate revisions by one user not shown)
Line 7: Line 7:
 
Returns a Set containing all of the existing instances of the current classifier (along with instances of all its inherited classifiers).
 
Returns a Set containing all of the existing instances of the current classifier (along with instances of all its inherited classifiers).
  
  +----------------------------------------------------------------------------------+----------------+
+
{| border="1" cellpadding="5" cellspacing="0"
  | Expression                                                                      | Result        |
+
|-
  +==================================================================================+================+
+
! style="background: #BCBCBC;" align="center"| Expression
  | let a : String = 'a', b : String = 'b', c : Integer = 2 in String.allInstances() | Set{'a','b'}   |
+
! style="background: #BCBCBC;" align="center"| Result
  +----------------------------------------------------------------------------------+----------------+
+
|-
 +
| let a : String = 'a', b : String = 'b', c : Integer = 2 in String.allInstances()
 +
| Set{'a','b'}
 +
|}
  
  
Line 17: Line 20:
  
 
=== oclAsType ( typespec : Classifier ) : T ===
 
=== oclAsType ( typespec : Classifier ) : T ===
  Returns *self* statically typed as typespec if it is an instance of this type. *Note* that this does not alter the
+
Returns *self* statically typed as typespec if it is an instance of this type. *Note* that this does not alter the runtime value of *self*, it only enables access to subtype operations. This operation allows users to cast '''self''' to another type.
  runtime value of *self*, it only enables access to subtype operations. This operation allows users to cast *self*
+
 
  to another type.
+
{| border="1" cellpadding="5" cellspacing="0"
 +
|-
 +
! style="background: #BCBCBC;" align="center"| Expression
 +
! style="background: #BCBCBC;" align="center"| Result
 +
|-
 +
| aPerson.oclAsType(Employee)
 +
| an object of Employee type
 +
|}
  
  +-------------------------------------------------------------+-----------------------------+
 
  | Expression                                                  | Result                      |
 
  +=============================================================+=============================+
 
  | aPerson.oclAsType(Employee)                                | an object of Employee type  |
 
  +-------------------------------------------------------------+-----------------------------+
 
  
 
=== oclIsInvalid () : Boolean ===
 
=== oclIsInvalid () : Boolean ===
  Returns **true** if *self* is equal to *invalid*.
+
Returns '''true''' if '''self''' is equal to *invalid*.
  
  +--------------------------------------------------------------+--------+
+
{| border="1" cellpadding="5" cellspacing="0"
  | Expression                                                  | Result |
+
|-
  +==============================================================+========+
+
! style="background: #BCBCBC;" align="center"| Expression
  | let anObject : String = null in anObject.oclIsUndefined()   | false |
+
! style="background: #BCBCBC;" align="center"| Result
  +--------------------------------------------------------------+--------+
+
|-
  | let anObject : String = invalid in anObject.oclIsUndefined() | true   |
+
| let anObject : String = null in anObject.oclIsUndefined()
  +--------------------------------------------------------------+--------+
+
| false
  | let anObject : String = 'null' in anObject.oclIsUndefined() | false |
+
|-
  +--------------------------------------------------------------+--------+
+
| let anObject : String = invalid in anObject.oclIsUndefined()
 +
| true
 +
|-
 +
| let anObject : String = 'null' in anObject.oclIsUndefined()
 +
| false
 +
|}
  
  
 
=== oclIsKindOf( Classifier typespec ) : Boolean ===
 
=== oclIsKindOf( Classifier typespec ) : Boolean ===
  Returns **true** if the type of *self* corresponds to the type or supertype of typespec, **false** otherwise. This
+
Returns **true** if the type of '''self''' corresponds to the type or supertype of typespec, '''false''' otherwise. This operation allows users to check the class hierarchy of '''self''' much like would an '''instanceof''' Java.
  operation allows users to check the class hierarchy of *self* much like would an *instanceof* Java.
+
  
  +----------------------------------+--------+
+
{| border="1" cellpadding="5" cellspacing="0"
  | Expression                      | Result |
+
|-
  +==================================+========+
+
! style="background: #BCBCBC;" align="center"| Expression
  | anEmployee.oclIsKindOf(Employee) | true   |
+
! style="background: #BCBCBC;" align="center"| Result
  +----------------------------------+--------+
+
|-
  | anEmployee.oclIsKindOf(Person)   | true   |
+
| anEmployee.oclIsKindOf(Employee)
  +----------------------------------+--------+
+
| true
  | aCat.oclIsKindOf(Person)         | false |
+
|-
  +----------------------------------+--------+
+
| anEmployee.oclIsKindOf(Person)
 +
| true
 +
|-
 +
| aCat.oclIsKindOf(Person)
 +
| false
 +
|}
  
  
 
=== oclIsTypeOf( typespec : Classifier ) : Boolean ===
 
=== oclIsTypeOf( typespec : Classifier ) : Boolean ===
  Returns **true** if the type of *self* is the same as typespec, or **false** otherwise. This operation allows users
+
Returns '''true''' if the type of '''self''' is the same as typespec, or **false** otherwise. This operation allows users to check the exact class type of '''self'''.
  to check the exact class type of *self*.
+
 
 
+
{| border="1" cellpadding="5" cellspacing="0"
  +----------------------------------+--------+
+
|-
  | Expression                      | Result |
+
! style="background: #BCBCBC;" align="center"| Expression
  +==================================+========+
+
! style="background: #BCBCBC;" align="center"| Result
  | anEmployee.oclIsTypeOf(Employee) | true   |
+
|-
  +----------------------------------+--------+
+
| anEmployee.oclIsTypeOf(Employee)
  | anEmployee.oclIsTypeOf(Person)   | false |
+
| true
  +----------------------------------+--------+
+
|-
  | aCat.oclIsTypeOf(Person)         | false |
+
| anEmployee.oclIsTypeOf(Person)
  +----------------------------------+--------+
+
| false
 +
|-
 +
| aCat.oclIsTypeOf(Person)
 +
| false
 +
|}
  
  
 
=== oclIsUndefined () : Boolean ===
 
=== oclIsUndefined () : Boolean ===
  Returns **true** if *self* is equal to *invalid* or *null*.
+
Returns **true** if *self* is equal to *invalid* or *null*.
 
+
  +--------------------------------------------------------------+--------+
+
  | Expression                                                  | Result |
+
  +==============================================================+========+
+
  | let anObject : String = null in anObject.oclIsUndefined()    | true  |
+
  +--------------------------------------------------------------+--------+
+
  | let anObject : String = invalid in anObject.oclIsUndefined() | true  |
+
  +--------------------------------------------------------------+--------+
+
  | let anObject : String = 'null' in anObject.oclIsUndefined()  | false  |
+
  +--------------------------------------------------------------+--------+
+
  
 +
{| border="1" cellpadding="5" cellspacing="0"
 +
|-
 +
! style="background: #BCBCBC;" align="center"| Expression
 +
! style="background: #BCBCBC;" align="center"| Result
 +
|-
 +
| let anObject : String = null in anObject.oclIsUndefined()
 +
| true
 +
|-
 +
| let anObject : String = invalid in anObject.oclIsUndefined()
 +
| true
 +
|-
 +
| let anObject : String = 'null' in anObject.oclIsUndefined()
 +
| false
 +
|}
  
  
 
=== <> ( object : OclAny ) : Boolean ===
 
=== <> ( object : OclAny ) : Boolean ===
  Returns **true** if *self* is a different object from *object*.
+
Returns **true** if *self* is a different object from *object*.
  
  +--------------------------------------------------+--------+
+
{| border="1" cellpadding="5" cellspacing="0"
  | Expression                                      | Result |
+
|-
  +==================================================+========+
+
! style="background: #BCBCBC;" align="center"| Expression
  | let a : String = 'a', b : String = 'a' in a <> b | false |
+
! style="background: #BCBCBC;" align="center"| Result
  +--------------------------------------------------+--------+
+
|-
  | let a : Integer = 2, b : Real = 2.0 in a <> b   | false |
+
| let a : String = 'a', b : String = 'a' in a <> b
  +--------------------------------------------------+--------+
+
| false
  | let a : Integer = -2, b : Integer = 2 in a <> b | true   |
+
|-
  +--------------------------------------------------+--------+
+
| let a : Integer = 2, b : Real = 2.0 in a <> b
 +
| false
 +
|-
 +
| let a : Integer = -2, b : Integer = 2 in a <> b
 +
| true
 +
|}
  
  
 
=== = ( object : OclAny) : Boolean ===
 
=== = ( object : OclAny) : Boolean ===
  Returns **true** if *self* is equal to *object*.
+
Returns **true** if *self* is equal to *object*.
  
 +
{| border="1" cellpadding="5" cellspacing="0"
 +
|-
 +
! style="background: #BCBCBC;" align="center"| Expression
 +
! style="background: #BCBCBC;" align="center"| Result
 +
|-
 +
| let a : String = 'a', b : String = 'a' in a = b
 +
| true
 +
|-
 +
| let a : Integer = 2, b : Real = 2.0 in a = b
 +
| true
 +
|-
 +
| let a : Integer = -2, b : Integer = 2 in a = b
 +
| false
 +
|}
  
  +--------------------------------------------------+--------+
 
  | Expression                                      | Result |
 
  +==================================================+========+
 
  | let a : String = 'a', b : String = 'a' in a = b  | true  |
 
  +--------------------------------------------------+--------+
 
  | let a : Integer = 2, b : Real = 2.0 in a = b    | true  |
 
  +--------------------------------------------------+--------+
 
  | let a : Integer = -2, b : Integer = 2 in a = b  | false  |
 
  +--------------------------------------------------+--------+
 
  
 +
=== < ( object : T ) : Boolean ===
 +
Returns **true** if *self* is comparable to *object* and less than *object*.
  
< ( object : T ) : Boolean
+
{| border="1" cellpadding="5" cellspacing="0"
-----------------------------------------------------------------
+
|-
  Returns **true** if *self* is comparable to *object* and less than *object*.
+
! style="background: #BCBCBC;" align="center"| Expression
 +
! style="background: #BCBCBC;" align="center"| Result
 +
|-
 +
| let a : Integer = 1, b : Integer = 2 in a < b
 +
| true
 +
|-
 +
| let a : Real = 1.5, b : Integer = 2 in a < b
 +
| true
 +
|-
 +
| let a : String = 'Anteater', b : String = 'Aardvark' in a < b
 +
| false
 +
|}
  
  examples:
 
  
  .. class:: exampletable
+
=== > ( object : T ) : Boolean ===
 +
Returns **true** if *self* is comparable to *object* and greater than *object*.
  
  +--------------------------------------------------------------+--------+
+
{| border="1" cellpadding="5" cellspacing="0"
  | Expression                                                  | Result |
+
|-
  +==============================================================+========+
+
! style="background: #BCBCBC;" align="center"| Expression
  | let a : Integer = 1, b : Integer = 2 in a < b               | true  |
+
! style="background: #BCBCBC;" align="center"| Result
  +--------------------------------------------------------------+--------+
+
|-
  | let a : Real = 1.5, b : Integer = 2 in a < b                 | true  |
+
| let a : Integer = 1, b : Integer = 2 in a > b
  +--------------------------------------------------------------+--------+
+
| false
  |let a : String = 'Anteater', b : String = 'Aardvark' in a < b | false  |
+
|-
  +--------------------------------------------------------------+--------+
+
| let a : Real = 1.5, b : Integer = 2 in a > b
 +
| false
 +
|-
 +
| let a : String = 'Anteater', b : String = 'Aardvark' in a > b
 +
| true
 +
|}
  
Back to Contents_
 
  
> > ( object : T ) : Boolean
+
=== <= ( object : T ) : Boolean ===
-----------------------------------------------------------------
+
Returns **true** if *self* is comparable to *object* and less than or equal to *object*.
  Returns **true** if *self* is comparable to *object* and greater than *object*.
+
  
  examples:
+
{| border="1" cellpadding="5" cellspacing="0"
 +
|-
 +
! style="background: #BCBCBC;" align="center"| Expression
 +
! style="background: #BCBCBC;" align="center"| Result
 +
|-
 +
| let a : Integer = 1, b : Integer = 2 in a <= b
 +
| true
 +
|-
 +
| let a : Real = 1.5, b : Integer = 2 in a <= b
 +
| true
 +
|-
 +
| let a : String = 'Anteater', b : String = 'Aardvark' in a <= b
 +
| false
 +
|}
  
  .. class:: exampletable
 
  
  +--------------------------------------------------------------+--------+
+
=== >= ( object : T ) : Boolean ===
  | Expression                                                  | Result |
+
Returns **true** if *self* is comparable to *object* and greater than or equal to *object*.
  +==============================================================+========+
+
  | let a : Integer = 1, b : Integer = 2 in a > b                | false  |
+
  +--------------------------------------------------------------+--------+
+
  | let a : Real = 1.5, b : Integer = 2 in a > b                | false  |
+
  +--------------------------------------------------------------+--------+
+
  |let a : String = 'Anteater', b : String = 'Aardvark' in a > b | true   |
+
  +--------------------------------------------------------------+--------+
+
  
Back to Contents_
+
{| border="1" cellpadding="5" cellspacing="0"
 +
|-
 +
! style="background: #BCBCBC;" align="center"| Expression
 +
! style="background: #BCBCBC;" align="center"| Result
 +
|-
 +
| let a : Integer = 1, b : Integer = 2 in a >= b
 +
| false
 +
|-
 +
| let a : Real = 1.5, b : Integer = 2 in a >= b
 +
| false
 +
|-
 +
| let a : String = 'Anteater', b : String = 'Aardvark' in a >= b
 +
| true
 +
|}
  
<= ( object : T ) : Boolean
 
-----------------------------------------------------------------
 
  Returns **true** if *self* is comparable to *object* and less than or equal to *object*.
 
  
  examples:
+
== Ocl operations for type *String* ==
  
  .. class:: exampletable
+
**A note on Strings** : OCL Strings begin at index *1*, not *0* as in most languages. Thus *'test'.at(0)* fails in
 +
*invalid* whereas *'test'.at(1)* yields *'t'*. Likewise, *'test'.substring(2, 2)* returns *'e'*.
  
  +---------------------------------------------------------------+--------+
+
=== concat ( s : String ) : String ===
  | Expression                                                    | Result |
+
Returns a string containing *self* followed by *s*.
  +===============================================================+========+
+
  | let a : Integer = 1, b : Integer = 2 in a <= b                | true  |
+
  +---------------------------------------------------------------+--------+
+
  | let a : Real = 1.5, b : Integer = 2 in a <= b                | true  |
+
  +---------------------------------------------------------------+--------+
+
  |let a : String = 'Anteater', b : String = 'Aardvark' in a <= b | false  |
+
  +---------------------------------------------------------------+--------+
+
  
Back to Contents_
+
{| border="1" cellpadding="5" cellspacing="0"
 +
|-
 +
! style="background: #BCBCBC;" align="center"| Expression
 +
! style="background: #BCBCBC;" align="center"| Result
 +
|-
 +
| 'concat'.concat(' ').concat('operation')
 +
| 'concat operation'
 +
|}
  
> >= ( object : T ) : Boolean
 
-----------------------------------------------------------------
 
  Returns **true** if *self* is comparable to *object* and greater than or equal to *object*.
 
  
  examples:
+
=== size () : Integer ===
 +
Returns the number of characters composing *self*.
  
  .. class:: exampletable
+
{| border="1" cellpadding="5" cellspacing="0"
 +
|-
 +
! style="background: #BCBCBC;" align="center"| Expression
 +
! style="background: #BCBCBC;" align="center"| Result
 +
|-
 +
| 'size operation'.size()
 +
| 14
 +
|}
  
  +---------------------------------------------------------------+--------+
 
  | Expression                                                    | Result |
 
  +===============================================================+========+
 
  | let a : Integer = 1, b : Integer = 2 in a >= b                | false  |
 
  +---------------------------------------------------------------+--------+
 
  | let a : Real = 1.5, b : Integer = 2 in a >= b                | false  |
 
  +---------------------------------------------------------------+--------+
 
  |let a : String = 'Anteater', b : String = 'Aardvark' in a >= b | true  |
 
  +---------------------------------------------------------------+--------+
 
  
Back to Contents_
+
=== substring ( lower : Integer, upper : Integer ) : String ===
 +
Returns a string containing all characters from *self* starting from index *lower* up to index *upper* included. Both *lower* and *upper* parameters should be contained between *1* and *self.size()* included. *lower* cannot be greater than *upper*.
  
Ocl operations for type *String*
+
{| border="1" cellpadding="5" cellspacing="0"
====================================
+
|-
 +
! style="background: #BCBCBC;" align="center"| Expression
 +
! style="background: #BCBCBC;" align="center"| Result
 +
|-
 +
| 'substring operation'.substring(11, 19)
 +
| 'operation'
 +
|-
 +
| 'substring operation'.substring(1, 1)
 +
| 's'
 +
|-
 +
| 'substring operation'.substring(0, 1)
 +
| '''''invalid'''''
 +
|}
  
**A note on Strings** : OCL Strings begin at index *1*, not *0* as in most languages. Thus *'test'.at(0)* fails in
 
*invalid* whereas *'test'.at(1)* yields *'t'*. Likewise, *'test'.substring(2, 2)* returns *'e'*.
 
  
concat ( s : String ) : String
+
=== toInteger () : Integer ===
-----------------------------------------------------------------
+
Returns an Integer of value equal to *self*, or |invalid| if *self* does not represent an integer.
  Returns a string containing *self* followed by *s*.
+
  
  examples:
+
{| border="1" cellpadding="5" cellspacing="0"
 +
|-
 +
! style="background: #BCBCBC;" align="center"| Expression
 +
! style="background: #BCBCBC;" align="center"| Result
 +
|-
 +
| '3.0'.toInteger()
 +
| '''''invalid'''''
 +
|-
 +
| '4'.toInteger()
 +
| 4
 +
|-
 +
| 'toInteger'.toInteger()
 +
| '''''invalid'''''
 +
|}
  
  .. class:: exampletable
 
  
  +-------------------------------------------------------------------+--------------------+
+
=== toLower () : String ===
  | Expression                                                        | Result            |
+
Returns *self* with all characters converted to lowercase.
  +===================================================================+====================+
+
  | 'concat'.concat(' ').concat('operation')                          | 'concat operation' |
+
  +-------------------------------------------------------------------+--------------------+
+
  
Back to Contents_
+
{| border="1" cellpadding="5" cellspacing="0"
 +
|-
 +
! style="background: #BCBCBC;" align="center"| Expression
 +
! style="background: #BCBCBC;" align="center"| Result
 +
|-
 +
| 'LoWeR OpErAtIoN'.toLower()
 +
| 'lower operation'
 +
|}
  
size () : Integer
 
-----------------------------------------------------------------
 
  Returns the number of characters composing *self*.
 
  
  examples:
+
=== toReal () : Real ===
 +
Returns a Real of value equal to *self*, or |invalid| if *self* does not represent a real.
  
  .. class:: exampletable
+
{| border="1" cellpadding="5" cellspacing="0"
 +
|-
 +
! style="background: #BCBCBC;" align="center"| Expression
 +
! style="background: #BCBCBC;" align="center"| Result
 +
|-
 +
| '3.0'.toReal()
 +
| 3.0
 +
|-
 +
| '4'.toReal()
 +
| 4.0
 +
|-
 +
| 'toReal'.toReal()
 +
| '''''invalid'''''
 +
|}
  
  +-------------------------------------------------------------+--------+
 
  | Expression                                                  | Result |
 
  +=============================================================+========+
 
  | 'size operation'.size()                                    | 14    |
 
  +-------------------------------------------------------------+--------+
 
  
Back to Contents_
+
=== toUpper () : String ===
 +
Returns *self* with all characters converted to uppercase.
  
substring ( lower : Integer, upper : Integer ) : String
+
{| border="1" cellpadding="5" cellspacing="0"
-----------------------------------------------------------------
+
|-
  Returns a string containing all characters from *self* starting from index *lower* up to index *upper* included.
+
! style="background: #BCBCBC;" align="center"| Expression
  Both *lower* and *upper* parameters should be contained between *1* and *self.size()* included. *lower* cannot be
+
! style="background: #BCBCBC;" align="center"| Result
  greater than *upper*.
+
|-
 +
| 'UpPeR OpErAtIoN'.toUpper()
 +
| 'UPPER OPERATION'
 +
|}
  
  examples:
 
  
  .. class:: exampletable
+
== Ocl operations for type *Number* ==
 +
In addition to the basic math functions (+, -, /, \*) are a number of advanced functions. Take note that *Number* denotes both *Integer* and *Real*, and they're substitutive unless otherwise specified.
  
  +---------------------------------------------------------------+----------------+
+
=== Number::abs () : Number ===
  | Expression                                                    | Result        |
+
Returns the absolute value of *self*, *self* if it is already a positive number.
  +===============================================================+================+
+
  | 'substring operation'.substring(11, 19)                      | 'operation'    |
+
  +---------------------------------------------------------------+----------------+
+
  | 'substring operation'.substring(1, 1)                        | 's'            |
+
  +---------------------------------------------------------------+----------------+
+
  | 'substring operation'.substring(0, 1)                        | |invalid|      |
+
  +---------------------------------------------------------------+----------------+
+
  
Back to Contents_
+
{| border="1" cellpadding="5" cellspacing="0"
 +
|-
 +
! style="background: #BCBCBC;" align="center"| Expression
 +
! style="background: #BCBCBC;" align="center"| Result
 +
|-
 +
| (-2.3).abs()
 +
| 2.3
 +
|-
 +
| -5.abs()
 +
| 5
 +
|}
  
toInteger () : Integer
 
-----------------------------------------------------------------
 
  Returns an Integer of value equal to *self*, or |invalid| if *self* does not represent an integer.
 
  
  examples:
+
=== Number::floor () : Integer ===
 +
Returns the integer part of *self* if it is a Real, *self* if it is an Integer.
  
  .. class:: exampletable
+
{| border="1" cellpadding="5" cellspacing="0"
 +
|-
 +
! style="background: #BCBCBC;" align="center"| Expression
 +
! style="background: #BCBCBC;" align="center"| Result
 +
|-
 +
| (2.3).floor()
 +
| 2
 +
|-
 +
| (2.8).floor()
 +
| 2
 +
|-
 +
| 2.floor()
 +
| 2
 +
|}
  
  +---------------------------------------------------------------+----------------+
 
  | Expression                                                    | Result        |
 
  +===============================================================+================+
 
  | '3.0'.toInteger()                                            | |invalid|      |
 
  +---------------------------------------------------------------+----------------+
 
  | '4'.toInteger()                                              | 4              |
 
  +---------------------------------------------------------------+----------------+
 
  | 'toInteger'.toInteger()                                      | |invalid|      |
 
  +---------------------------------------------------------------+----------------+
 
  
Back to Contents_
+
=== Number::max ( r : Number ) : Number ===
 +
Returns the greatest number between *self* and *r*.
  
toLower () : String
+
{| border="1" cellpadding="5" cellspacing="0"
-----------------------------------------------------------------
+
|-
  Returns *self* with all characters converted to lowercase.
+
! style="background: #BCBCBC;" align="center"| Expression
 +
! style="background: #BCBCBC;" align="center"| Result
 +
|-
 +
| 6.max(3)
 +
| 6
 +
|-
 +
| 6.max(5.2)
 +
| 6.0
 +
|-
 +
| (2.3).max(3)
 +
| 3.0
 +
|-
 +
| (2.3).max(5.2)
 +
| 5.2
 +
|}
  
  examples:
 
  
  .. class:: exampletable
+
=== Number::min ( r : Number ) : Number ===
 +
Returns the lowest number between *self* and *r*.
  
  +------------------------------------------------------------+-------------------+
+
{| border="1" cellpadding="5" cellspacing="0"
  | Expression                                                | Result            |
+
|-
  +============================================================+===================+
+
! style="background: #BCBCBC;" align="center"| Expression
  | 'LoWeR OpErAtIoN'.toLower()                               | 'lower operation' |
+
! style="background: #BCBCBC;" align="center"| Result
  +------------------------------------------------------------+-------------------+
+
|-
 +
| 6.min(3)
 +
| 3
 +
|-
 +
| 6.min(5.2)
 +
| 5.2
 +
|-
 +
| (2.3).min(3)
 +
| 2.3
 +
|-
 +
| (2.3).min(5.2)
 +
| 2.3
 +
|}
  
Back to Contents_
 
  
toReal () : Real
+
=== Number::round () : Integer ===
-----------------------------------------------------------------
+
Returns the nearest integer to *self* if it is a Real, *self* if it is an Integer.
  Returns a Real of value equal to *self*, or |invalid| if *self* does not represent a real.
+
  
  examples:
+
{| border="1" cellpadding="5" cellspacing="0"
 +
|-
 +
! style="background: #BCBCBC;" align="center"| Expression
 +
! style="background: #BCBCBC;" align="center"| Result
 +
|-
 +
| (2.3).round()
 +
| 2
 +
|-
 +
| (2.5).round()
 +
| 3
 +
|-
 +
| (2.8).round()
 +
| 3
 +
|-
 +
| 2.round()
 +
| 2
 +
|}
  
  .. class:: exampletable
 
  
  +---------------------------------------------------------------+----------------+
+
=== Integer::div ( i : Integer ) : Integer ===
  | Expression                                                    | Result        |
+
Returns the integer quotient of the division of *self* by *i*.
  +===============================================================+================+
+
  | '3.0'.toReal()                                                | 3.0            |
+
  +---------------------------------------------------------------+----------------+
+
  | '4'.toReal()                                                  | 4.0            |
+
  +---------------------------------------------------------------+----------------+
+
  | 'toReal'.toReal()                                            | |invalid|      |
+
  +---------------------------------------------------------------+----------------+
+
  
Back to Contents_
+
{| border="1" cellpadding="5" cellspacing="0"
 +
|-
 +
! style="background: #BCBCBC;" align="center"| Expression
 +
! style="background: #BCBCBC;" align="center"| Result
 +
|-
 +
| 3.div(2)
 +
| 1
 +
|-
 +
| 11.div(3)
 +
| 3
 +
|}
 +
 
  
toUpper () : String
+
=== Integer::mod ( i : Integer ) : Integer ===
-----------------------------------------------------------------
+
Returns the integer remainder of the division of *self* by *i*.
  Returns *self* with all characters converted to uppercase.
+
  
  examples:
+
{| border="1" cellpadding="5" cellspacing="0"
 +
|-
 +
! style="background: #BCBCBC;" align="center"| Expression
 +
! style="background: #BCBCBC;" align="center"| Result
 +
|-
 +
| 3.mod(2)
 +
| 1
 +
|-
 +
| 11.mod(3)
 +
| 2
 +
|}
  
  .. class:: exampletable
 
  
  +------------------------------------------------------------+-------------------+
+
== Ocl operations for type *Collection* ==
  | Expression                                                | Result            |
+
  +============================================================+===================+
+
  | 'UpPeR OpErAtIoN'.toUpper()                                | 'UPPER OPERATION' |
+
  +------------------------------------------------------------+-------------------+
+
  
Back to Contents_
+
Please note that OCL collections can contain the *null* value (null) but not the *invalid* value (|invalid|). Trying to add |invalid| within a new or existing collection will yield |invalid| as a result. OCL proposes four distinct kinds of collections offering all possibilities of ordering/unicity.
  
Ocl operations for type *Number*
 
====================================
 
  
In addition to the basic math functions (+, -, /, \*) are a number of advanced functions. Take note that *Number*
+
{| border="1" cellpadding="5" cellspacing="0" align="center"
denotes both *Integer* and *Real*, and they're substitutive unless otherwise specified.
+
|-
 +
! style="background: #BCBCBC;" align="center"| Collection type
 +
! style="background: #BCBCBC;" align="center"| Ordered
 +
! style="background: #BCBCBC;" align="center"| Unique
 +
|-
 +
| Sequence
 +
| true
 +
| false
 +
|-
 +
| OrderedSet
 +
| true
 +
| true
 +
|-
 +
| Bag
 +
| false
 +
| false
 +
|-
 +
| Set
 +
| false
 +
| true
 +
|-
 +
|}
  
Number::abs () : Number
 
-----------------------------------------------------------------
 
  Returns the absolute value of *self*, *self* if it is already a positive number.
 
  
  examples:
+
=== any ( expr : OclExpression ) : T ===
 +
Returns any element contained in *self* that validates the condition *expr*, null otherwise. Evaluation is shortcut as soon as an element validating *expr* is found. Note that the result of this on unordered collections will be random if more than one element validates *expr*.
  
  .. class:: exampletable
+
{| border="1" cellpadding="5" cellspacing="0"
 +
|-
 +
! style="background: #BCBCBC;" align="center"| Expression
 +
! style="background: #BCBCBC;" align="center"| Result
 +
|-
 +
| Sequence{1.2, 2.3, 5.2, 0.9}->any(self < 1)
 +
| 0.9
 +
|-
 +
| Sequence{1.2, 2.3, 5.2, 0.9}->any(self < 2)
 +
| 1.2
 +
|}
  
  +---------------------------------------------------------------+----------------+
 
  | Expression                                                    | Result        |
 
  +===============================================================+================+
 
  | (-2.3).abs()                                                  | 2.3            |
 
  +---------------------------------------------------------------+----------------+
 
  | -5.abs()                                                      | 5              |
 
  +---------------------------------------------------------------+----------------+
 
  
Back to Contents_
+
=== asBag () : Bag(T) ===
 +
Returns a Bag containing all elements of *self*.
  
Number::floor () : Integer
+
{| border="1" cellpadding="5" cellspacing="0"
-----------------------------------------------------------------
+
|-
  Returns the integer part of *self* if it is a Real, *self* if it is an Integer.
+
! style="background: #BCBCBC;" align="center"| Expression
 +
! style="background: #BCBCBC;" align="center"| Result
 +
|-
 +
| Sequence{'3', 1, 2.0, '3'}->asBag()
 +
| Bag{2.0, '3', 1, '3'}
 +
|-
 +
| Bag{1, 2.0, '3'}->asBag()
 +
| Bag{2.0, 1, '3'}
 +
|-
 +
| OrderedSet{1, 2.0, '3'}->asBag()
 +
| Bag{2.0, 1, '3'}
 +
|-
 +
| OrderedSet{1, 1, 2.0, '3'}->asBag()
 +
| Bag{'3', 1, 2.0}
 +
|-
 +
| Set{1, 2.0, '3'}->asBag()
 +
| Bag{2.0, 1, '3'}
 +
|-
 +
| Set{1, 1, 2.0, '3'}->asBag()
 +
| Bag{2.0, '3', 1}
 +
|}
  
  examples:
 
  
  .. class:: exampletable
+
=== asOrderedSet () : OrderedSet(T) ===
 +
Returns an OrderedSet containing all elements of *self*. Element ordering is preserved when possible.
  
  +---------------------------------------------------------------+----------------+
+
{| border="1" cellpadding="5" cellspacing="0"
  | Expression                                                    | Result        |
+
|-
  +===============================================================+================+
+
! style="background: #BCBCBC;" align="center"| Expression
  | (2.3).floor()                                                 | 2             |
+
! style="background: #BCBCBC;" align="center"| Result
  +---------------------------------------------------------------+----------------+
+
|-
  | (2.8).floor()                                                 | 2             |
+
| Sequence{1, 2.0, '3'}->asOrderedSet()
  +---------------------------------------------------------------+----------------+
+
| OrderedSet{1, '3', 2.0}
  | 2.floor()                                                     | 2             |
+
|-
  +---------------------------------------------------------------+----------------+
+
| Sequence{1, 1, 2.0, '3'}->asOrderedSet()
 +
| OrderedSet{'3', 1, 2.0}
 +
|-
 +
| Bag{1, 2.0, '3'}->asOrderedSet()
 +
| OrderedSet{2.0, 1, '3'}
 +
|-
 +
| Bag{1, 1, 2.0, '3'}->asOrderedSet()
 +
| OrderedSet{1, '3', 2.0}
 +
|-
 +
| OrderedSet{1, 2.0, '3'}->asOrderedSet()
 +
| OrderedSet{1, 2.0, '3'}
 +
|-
 +
| Set{1, 2.0, '3'}->asOrderedSet()
 +
| OrderedSet{'3', 1, 2.0}
 +
|}
  
Back to Contents_
 
  
Number::max ( r : Number ) : Number
+
=== asSequence () : Boolean ===
-----------------------------------------------------------------
+
Returns a Sequence containing all elements of *self*. Element ordering is preserved when possible.
  Returns the greatest number between *self* and *r*.
+
  
  examples:
+
{| border="1" cellpadding="5" cellspacing="0"
 +
|-
 +
! style="background: #BCBCBC;" align="center"| Expression
 +
! style="background: #BCBCBC;" align="center"| Result
 +
|-
 +
| Sequence{1, 2.0, '3'}->asSequence()
 +
| Sequence{1, 2.0, '3'}
 +
|-
 +
| Bag{1, 2.0, '3'}->asSequence()
 +
| Sequence{2.0, 1, '3'}
 +
|-
 +
| OrderedSet{1, 2.0, '3'}->asSequence()
 +
| Sequence{1, 2.0, '3'}
 +
|-
 +
| Set{1, 2.0, '3'}->asSequence()
 +
| Sequence{'3', 1, 2.0}
 +
|}
  
  .. class:: exampletable
 
  
  +---------------------------------------------------------------+----------------+
+
=== asSet () : Set(T) ===
  | Expression                                                    | Result        |
+
Returns a Set containing all elements of *self*.
  +===============================================================+================+
+
  | 6.max(3)                                                     | 6              |
+
  +---------------------------------------------------------------+----------------+
+
  | 6.max(5.2)                                                   | 6.0            |
+
  +---------------------------------------------------------------+----------------+
+
  | (2.3).max(3)                                                  | 3.0            |
+
  +---------------------------------------------------------------+----------------+
+
  | (2.3).max(5.2)                                                | 5.2            |
+
  +---------------------------------------------------------------+----------------+
+
  
Back to Contents_
+
{| border="1" cellpadding="5" cellspacing="0"
 +
|-
 +
! style="background: #BCBCBC;" align="center"| Expression
 +
! style="background: #BCBCBC;" align="center"| Result
 +
|-
 +
| Sequence{1, 2.0, '3'}->asSet()
 +
| Set{1, '3', 2.0}
 +
|-
 +
| Sequence{1, 1, 2.0, '3'}->asSet()
 +
| Set{'3', 1, 2.0}
 +
|-
 +
| Bag{1, 2.0, '3'}->asSet()
 +
| Set{2.0, 1, '3'}
 +
|-
 +
| Bag{1, 1, 2.0, '3'}->asSet()
 +
| Set{1, '3', 2.0}
 +
|-
 +
| OrderedSet{1, 2.0, '3'}->asSet()
 +
| Set{1, '3', 2.0}
 +
|-
 +
| OrderedSet{1, 1, 2.0, '3'}->asSet()
 +
| Set{'3', 1, 2.0}
 +
|-
 +
| Set{1, 2.0, '3'}->asSet()
 +
| Set{2.0, 1, '3'}
 +
|-
 +
| Set{1, 1, 2.0, '3'}->asSet()
 +
| Set{'3', 1, 2.0}
 +
|}
  
Number::min ( r : Number ) : Number
 
-----------------------------------------------------------------
 
  Returns the lowest number between *self* and *r*.
 
  
  examples:
+
=== collect ( expr : OclExpression ) : Collection(T2) ===
 +
Returns a collection containing the result of applying *expr* on all elements contained in *self*.
  
  .. class:: exampletable
+
{| border="1" cellpadding="5" cellspacing="0"
 +
|-
 +
! style="background: #BCBCBC;" align="center"| Expression
 +
! style="background: #BCBCBC;" align="center"| Result
 +
|-
 +
| Sequence{'first', 'second'}->collect(toUpper())
 +
| Sequence{'FIRST', 'SECOND'}
 +
|}
  
  +---------------------------------------------------------------+----------------+
 
  | Expression                                                    | Result        |
 
  +===============================================================+================+
 
  | 6.min(3)                                                      | 6              |
 
  +---------------------------------------------------------------+----------------+
 
  | 6.min(5.2)                                                    | 5.2            |
 
  +---------------------------------------------------------------+----------------+
 
  | (2.3).min(3)                                                  | 2.3            |
 
  +---------------------------------------------------------------+----------------+
 
  | (2.3).min(5.2)                                                | 2.3            |
 
  +---------------------------------------------------------------+----------------+
 
  
Back to Contents_
+
=== collectNested ( expr : OclExpression ) : Collection(T2) ===
 +
Returns a collection containing all the elements contained in *self* on which we applied the OclExpression *expr*. The results won't be flattened. The type of the resulting collection depends on the type of *self*.
  
Number::round () : Integer
+
For the purpose of these examples we'll assume here that we have a Class *Person* with a reference *children*. Our model contains two persons such as *person1.children = {James, Jane}* and *person2.children = {John}*.
-----------------------------------------------------------------
+
  Returns the nearest integer to *self* if it is a Real, *self* if it is an Integer.
+
  
  examples:
+
{| border="1" cellpadding="5" cellspacing="0"
 +
|-
 +
! style="background: #BCBCBC;" align="center"| Expression
 +
! style="background: #BCBCBC;" align="center"| Result
 +
|-
 +
| self.persons->collectNested(children.firstname)
 +
| Sequence{Sequence{James, Jane}, Sequence{John}}
 +
|}
  
  .. class:: exampletable
 
  
  +---------------------------------------------------------------+----------------+
+
=== count ( object : T ) : Integer ===
  | Expression                                                    | Result        |
+
Returns how many times *object* is in the collection *self*.
  +===============================================================+================+
+
  | (2.3).round()                                                | 2              |
+
  +---------------------------------------------------------------+----------------+
+
  | (2.5).round()                                                | 3              |
+
  +---------------------------------------------------------------+----------------+
+
  | (2.8).round()                                                | 3              |
+
  +---------------------------------------------------------------+----------------+
+
  | 2.round()                                                    | 2              |
+
  +---------------------------------------------------------------+----------------+
+
  
Back to Contents_
+
{| border="1" cellpadding="5" cellspacing="0"
 +
|-
 +
! style="background: #BCBCBC;" align="center"| Expression
 +
! style="background: #BCBCBC;" align="center"| Result
 +
|-
 +
| Sequence{2.3, 5.2}->count(5.2)
 +
| 1
 +
|-
 +
| Set{3, 'test', 4.0, 4, 4.0, 'test'}->count(null)
 +
| 0
 +
|-
 +
| Set{3, null, 4.0, null, 'test'}->count(null)
 +
| 1
 +
|-
 +
| Bag{3, null, 4.0, null, 'test'}->count(null)
 +
| 2
 +
|}
  
Integer::div ( i : Integer ) : Integer
 
-----------------------------------------------------------------
 
  Returns the integer quotient of the division of *self* by *i*.
 
 
 
  examples:
 
  
  .. class:: exampletable
+
=== excludes ( object : T ) : Boolean ===
 +
Returns **true** if *object* is not contained in *self*, **false** otherwise.
  
  +---------------------------------------------------------------+----------------+
+
{| border="1" cellpadding="5" cellspacing="0"
  | Expression                                                    | Result        |
+
|-
  +===============================================================+================+
+
! style="background: #BCBCBC;" align="center"| Expression
  | 3.div(2)                                                     | 1              |
+
! style="background: #BCBCBC;" align="center"| Result
  +---------------------------------------------------------------+----------------+
+
|-
  | 11.div(3)                                                     | 3              |
+
| Sequence{2.3}->excludes(2.1)
  +---------------------------------------------------------------+----------------+
+
| true
 
+
|-
Back to Contents_
+
| Sequence{2.0}->excludes(2)
 +
| false
 +
|}
  
Integer::mod ( i : Integer ) : Integer
 
-----------------------------------------------------------------
 
  Returns the integer remainder of the division of *self* by *i*.
 
 
 
  examples:
 
  
  .. class:: exampletable
+
=== excludesAll ( c2 : Collection(T) ) : Boolean ===
 +
Returns **true** if no element of *c2* is contained in *self*, **false** otherwise.
  
  +---------------------------------------------------------------+----------------+
+
{| border="1" cellpadding="5" cellspacing="0"
  | Expression                                                    | Result        |
+
|-
  +===============================================================+================+
+
! style="background: #BCBCBC;" align="center"| Expression
  | 3.mod(2)                                                     | 1              |
+
! style="background: #BCBCBC;" align="center"| Result
  +---------------------------------------------------------------+----------------+
+
|-
  | 11.mod(3)                                                     | 2              |
+
| Sequence{2.3, 5.2, 'a', 3, null}->excludesAll(Set{4, null})
  +---------------------------------------------------------------+----------------+
+
| false
 +
|-
 +
| Sequence{2.3, 5.2, 'a', 3}->excludesAll(Set{4, null})
 +
| true
 +
|}
  
Back to Contents_
 
  
Ocl operations for type *Collection*
+
=== excluding ( object : T ) : Collection(T) ===
====================================
+
Returns a collection containing all elements of *self* minus all occurences of *object*. **Note** : at the time of writing, the OCL standard library sports a bug which changes *OrderedSets* in *Sets* when excluding elements.
  
Please note that OCL collections can contain the *null* value (null) but not the *invalid* value (|invalid|). Trying to add |invalid| within a new or existing collection will yield |invalid| as a result. OCL proposes four distinct kinds of collections offering all possibilities of ordering/unicity.
+
{| border="1" cellpadding="5" cellspacing="0"
 +
|-
 +
! style="background: #BCBCBC;" align="center"| Expression
 +
! style="background: #BCBCBC;" align="center"| Result
 +
|-
 +
| Sequence{'b', 'a', 'b', 'c'}->excluding('b')
 +
| Sequence{'a', 'c'}
 +
|-
 +
| Bag{'b', 'a', 'b', 'c'}->excluding('b')
 +
| Bag{'c', 'a'}
 +
|-
 +
| OrderedSet{'b', 'a', 'b', 'c'}->excluding('b')
 +
| Set{'c', 'a'}
 +
|-
 +
| Set{'b', 'a', 'b', 'c'}->excluding('b')
 +
| Set{'c', 'a'}
 +
|}
  
.. list-table::
 
:header-rows: 1
 
:stub-columns: 1
 
         
 
* - Collection type
 
  - Ordered
 
  - Unique
 
* - Sequence
 
  - true
 
  - false
 
* - OrderedSet
 
  - true
 
  - true
 
* - Bag
 
  - false
 
  - false
 
* - Set
 
  - false
 
  - true
 
  
Back to Contents_
+
=== exists ( expr : OclExpression ) : Boolean ===
 +
Returns **true** if at least one element in *self* validates the condition *expr*, **false** otherwise. The evaluation stops as soon as one element validating *expr* is found.
  
any ( expr : OclExpression ) : T
+
{| border="1" cellpadding="5" cellspacing="0"
-----------------------------------------------------------------
+
|-
Returns any element contained in *self* that validates the condition *expr*, null otherwise. Evaluation is shortcut as soon
+
! style="background: #BCBCBC;" align="center"| Expression
as an element validating *expr* is found. Note that the result of this on unordered collections will be random if more than
+
! style="background: #BCBCBC;" align="center"| Result
one element validates *expr*.
+
|-
+
| Sequence{2.3, 5.2}->exists(self > 3)
examples:
+
| true
 +
|}
  
.. class:: exampletable
 
 
+---------------------------------------------------------------+----------------+
 
| Expression                                                    | Result        |
 
+===============================================================+================+
 
| Sequence{1.2, 2.3, 5.2, 0.9}->any(self < 1)                  | 0.9            |
 
+---------------------------------------------------------------+----------------+
 
| Sequence{1.2, 2.3, 5.2, 0.9}->any(self < 2)                  | 1.2            |
 
+---------------------------------------------------------------+----------------+
 
  
Back to Contents_
+
=== flatten () : Collection(T2) ===
 +
Returns a collection containing all elements of *self* recursively flattened. **Note** : at the time of writing, the OCL standard library sports a bug which changes *OrderedSets* in *Sets* when flattening.
  
asBag () : Bag(T)
+
{| border="1" cellpadding="5" cellspacing="0"
-----------------------------------------------------------------
+
|-
Returns a Bag containing all elements of *self*.
+
! style="background: #BCBCBC;" align="center"| Expression
+
! style="background: #BCBCBC;" align="center"| Result
examples:
+
|-
+
| Sequence{Set{1, 2, 3}, Sequence{2.0, 3.0}, Bag{'test'}}->flatten()
.. class:: exampletable
+
| Sequence{1, 2, 3, 2.0, 3.0, 'test'}
+
|-
+-------------------------------------------------------+-----------------------+
+
| Bag{Set{Bag{'test', 2, 3.0}}, Sequence{OrderedSet{2.0, 3, 1}}}->flatten()
| Expression                                           | Result                |
+
| Bag{1, 2, 3, 2.0, 3.0, 'test'}
+=======================================================+=======================+
+
|-
| Sequence{'3', 1, 2.0, '3'}->asBag()                  | Bag{2.0, '3', 1, '3'} |
+
| OrderedSet{Set{Bag{'test', 2, 3.0}}, Sequence{Set{2.0, 3, 1}}}->flatten()
+-------------------------------------------------------+-----------------------+
+
| Set{3.0, 2, 1, 3, 'test', 2.0}
| Bag{1, 2.0, '3'}->asBag()                            | Bag{2.0, 1, '3'}     |
+
|-
+-------------------------------------------------------+-----------------------+
+
| Set{Set{Bag{'test', 2, 3.0}}, Sequence{OrderedSet{2.0, 3, 1}}}->flatten()
| OrderedSet{1, 2.0, '3'}->asBag()                     | Bag{2.0, 1, '3'}     |
+
| Set{3.0, 2, 1, 3, 'test', 2.0}
+-------------------------------------------------------+-----------------------+
+
|}
| OrderedSet{1, 1, 2.0, '3'}->asBag()                  | Bag{'3', 1, 2.0}     |
+
+-------------------------------------------------------+-----------------------+
+
| Set{1, 2.0, '3'}->asBag()                             | Bag{2.0, 1, '3'}     |
+
+-------------------------------------------------------+-----------------------+
+
| Set{1, 1, 2.0, '3'}->asBag()                         | Bag{2.0, '3', 1}     |
+
+-------------------------------------------------------+-----------------------+
+
  
Back to Contents_
 
  
asOrderedSet () : OrderedSet(T)
+
=== forAll ( expr : OclExpression ) : Boolean ===
-----------------------------------------------------------------
+
Returns **true** if the all the elements contained in *self* validate the condition *expr*, **false** otherwise.
Returns an OrderedSet containing all elements of *self*. Element ordering is preserved when possible.
+
+
examples:
+
+
.. class:: exampletable
+
+
+-------------------------------------------------------+-------------------------+
+
| Expression                                            | Result                  |
+
+=======================================================+=========================+
+
| Sequence{1, 2.0, '3'}->asOrderedSet()                | OrderedSet{1, '3', 2.0} |
+
+-------------------------------------------------------+-------------------------+
+
| Sequence{1, 1, 2.0, '3'}->asOrderedSet()              | OrderedSet{'3', 1, 2.0} |
+
+-------------------------------------------------------+-------------------------+
+
| Bag{1, 2.0, '3'}->asOrderedSet()                      | OrderedSet{2.0, 1, '3'} |
+
+-------------------------------------------------------+-------------------------+
+
| Bag{1, 1, 2.0, '3'}->asOrderedSet()                  | OrderedSet{1, '3', 2.0} |
+
+-------------------------------------------------------+-------------------------+
+
| OrderedSet{1, 2.0, '3'}->asOrderedSet()              | OrderedSet{1, 2.0, '3'} |
+
+-------------------------------------------------------+-------------------------+
+
| Set{1, 2.0, '3'}->asOrderedSet()                      | OrderedSet{'3', 1, 2.0} |
+
+-------------------------------------------------------+-------------------------+
+
  
Back to Contents_
+
{| border="1" cellpadding="5" cellspacing="0"
 +
|-
 +
! style="background: #BCBCBC;" align="center"| Expression
 +
! style="background: #BCBCBC;" align="center"| Result
 +
|-
 +
| Sequence{2.3, 5.2}->forAll(self > 3)
 +
| false
 +
|-
 +
| Sequence{2.3, 5.2}->forAll(self > 1.2)
 +
| true
 +
|}
  
asSequence () : Boolean
 
-----------------------------------------------------------------
 
Returns a Sequence containing all elements of *self*. Element ordering is preserved when possible.
 
 
examples:
 
 
.. class:: exampletable
 
 
+-------------------------------------------------------+-----------------------+
 
| Expression                                            | Result                |
 
+=======================================================+=======================+
 
| Sequence{1, 2.0, '3'}->asSequence()                  | Sequence{1, 2.0, '3'} |
 
+-------------------------------------------------------+-----------------------+
 
| Bag{1, 2.0, '3'}->asSequence()                        | Sequence{2.0, 1, '3'} |
 
+-------------------------------------------------------+-----------------------+
 
| OrderedSet{1, 2.0, '3'}->asSequence()                | Sequence{1, 2.0, '3'} |
 
+-------------------------------------------------------+-----------------------+
 
| Set{1, 2.0, '3'}->asSequence()                        | Sequence{'3', 1, 2.0} |
 
+-------------------------------------------------------+-----------------------+
 
  
Back to Contents_
+
=== includes ( object : T ) : Boolean ===
 +
Returns **true** if *object* is contained in *self*, **false** otherwise.
  
asSet () : Set(T)
+
{| border="1" cellpadding="5" cellspacing="0"
-----------------------------------------------------------------
+
|-
Returns a Set containing all elements of *self*.
+
! style="background: #BCBCBC;" align="center"| Expression
+
! style="background: #BCBCBC;" align="center"| Result
examples:
+
|-
+
| Sequence{2.3}->includes(2.1)
.. class:: exampletable
+
| false
+
|-
+-------------------------------------------------------+-----------------------+
+
| Sequence{2.0}->includes(2)
| Expression                                           | Result                |
+
| true
+=======================================================+=======================+
+
|}
| Sequence{1, 2.0, '3'}->asSet()                        | Set{1, '3', 2.0}      |
+
+-------------------------------------------------------+-----------------------+
+
| Sequence{1, 1, 2.0, '3'}->asSet()                    | Set{'3', 1, 2.0}      |
+
+-------------------------------------------------------+-----------------------+
+
| Bag{1, 2.0, '3'}->asSet()                             | Set{2.0, 1, '3'}      |
+
+-------------------------------------------------------+-----------------------+
+
| Bag{1, 1, 2.0, '3'}->asSet()                          | Set{1, '3', 2.0}      |
+
+-------------------------------------------------------+-----------------------+
+
| OrderedSet{1, 2.0, '3'}->asSet()                      | Set{1, '3', 2.0}      |
+
+-------------------------------------------------------+-----------------------+
+
| OrderedSet{1, 1, 2.0, '3'}->asSet()                   | Set{'3', 1, 2.0}      |
+
+-------------------------------------------------------+-----------------------+
+
| Set{1, 2.0, '3'}->asSet()                            | Set{2.0, 1, '3'}      |
+
+-------------------------------------------------------+-----------------------+
+
| Set{1, 1, 2.0, '3'}->asSet()                          | Set{'3', 1, 2.0}      |
+
+-------------------------------------------------------+-----------------------+
+
  
Back to Contents_
 
  
collect ( expr : OclExpression ) : Collection(T2)
+
=== includesAll ( c2 : Collection(T) ) : Boolean ===
-----------------------------------------------------------------
+
Returns **true** if all element of *c2* are contained in *self*, **false** otherwise.
Returns a collection containing the result of applying *expr* on all elements contained in *self*.
+
+
examples:
+
  
.. class:: exampletable
+
{| border="1" cellpadding="5" cellspacing="0"
+
|-
+---------------------------------------------------------------+-----------------------------+
+
! style="background: #BCBCBC;" align="center"| Expression
| Expression                                                   | Result                      |
+
! style="background: #BCBCBC;" align="center"| Result
+===============================================================+=============================+
+
|-
| Sequence{'first', 'second'}->collect(toUpper())              | Sequence{'FIRST', 'SECOND'} |
+
| Sequence{2.3, 5.2, 'a', 3, null}->includesAll(Set{3, null})
+---------------------------------------------------------------+-----------------------------+
+
| true
 +
|-
 +
| Sequence{2.3, 5.2, 'a', 3}->includesAll(Set{3, null})
 +
| false
 +
|}
  
Back to Contents_
 
  
collectNested ( expr : OclExpression ) : Collection(T2)
+
=== including ( object : T ) : Collection(T) ===
-----------------------------------------------------------------
+
Returns a collection containing all elements of *self* followed by *object*. **Note** : at the time of writing, the OCL standard library sports a bug which changes *OrderedSets* in *Sets* when including elements.
Returns a collection containing all the elements contained in *self* on which we applied the OclExpression *expr*.
+
The results won't be flattened. The type of the resulting collection depends on the type of *self*.
+
+
examples:
+
+
For the purpose of these examples we'll assume here that we have a Class *Person* with a reference *children*. Our
+
model contains two persons such as *person1.children = {James, Jane}* and *person2.children = {John}*.
+
+
.. class:: exampletable
+
+
+-------------------------------------------------------+-------------------------------------------------+
+
| Expression                                            | Result                                          |
+
+=======================================================+=================================================+
+
| self.persons->collectNested(children.firstname)      | Sequence{Sequence{James, Jane}, Sequence{John}} |
+
+-------------------------------------------------------+-------------------------------------------------+
+
  
Back to Contents_
+
{| border="1" cellpadding="5" cellspacing="0"
 +
|-
 +
! style="background: #BCBCBC;" align="center"| Expression
 +
! style="background: #BCBCBC;" align="center"| Result
 +
|-
 +
| Sequence{'a', 'b'}->including('c')
 +
| Sequence{'a', 'b', 'c'}
 +
|-
 +
| Bag{'a', 'b'}->including('c')
 +
| Bag{'a', 'c', 'b'}
 +
|-
 +
| OrderedSet{'a', 'b'}->including('c')
 +
| Set{'a', 'c', 'b'}
 +
|-
 +
| Set{'a', 'b'}->including('c')
 +
| Set{'a', 'c', 'b'}
 +
|}
  
count ( object : T ) : Integer
 
-----------------------------------------------------------------
 
  Returns how many times *object* is in the collection *self*.
 
  
  examples:
+
=== isEmpty () : Boolean ===
 +
Returns **true** if *self* is empty, **false** otherwise.
  
  .. class:: exampletable
+
{| border="1" cellpadding="5" cellspacing="0"
 +
|-
 +
! style="background: #BCBCBC;" align="center"| Expression
 +
! style="background: #BCBCBC;" align="center"| Result
 +
|-
 +
| Sequence{2, 'a'}->isEmpty()
 +
| false
 +
|-
 +
| Sequence{null}->isEmpty()
 +
| false
 +
|-
 +
| Sequence{}->isEmpty()
 +
| true
 +
|}
  
  +---------------------------------------------------------------+----------------+
 
  | Expression                                                    | Result        |
 
  +===============================================================+================+
 
  | Sequence{2.3, 5.2}->count(5.2)                                | 1              |
 
  +---------------------------------------------------------------+----------------+
 
  | Set{3, 'test', 4.0, 4, 4.0, 'test'}->count(null)              | 0              |
 
  +---------------------------------------------------------------+----------------+
 
  | Set{3, null, 4.0, null, 'test'}->count(null)                  | 1              |
 
  +---------------------------------------------------------------+----------------+
 
  | Bag{3, null, 4.0, null, 'test'}->count(null)                  | 2              |
 
  +---------------------------------------------------------------+----------------+
 
  
Back to Contents_
+
=== isUnique ( expr : OclExpression ) : Boolean ===
 +
Returns **true** if all elements contained in *self* evaluate to a distinct value for *expr*.
  
excludes ( object : T ) : Boolean
+
{| border="1" cellpadding="5" cellspacing="0"
-----------------------------------------------------------------
+
|-
Returns **true** if *object* is not contained in *self*, **false** otherwise.
+
! style="background: #BCBCBC;" align="center"| Expression
+
! style="background: #BCBCBC;" align="center"| Result
examples:
+
|-
 +
| Sequence{2.3, 5.2}->isUnique(self > 3)
 +
| true
 +
|-
 +
| Sequence{2.3, 5.2}->isUnique(self > 1)
 +
| false
 +
|}
  
.. class:: exampletable
 
 
+---------------------------------------------------------------+----------------+
 
| Expression                                                    | Result        |
 
+===============================================================+================+
 
| Sequence{2.3}->excludes(2.1)                                  | true          |
 
+---------------------------------------------------------------+----------------+
 
| Sequence{2.0}->excludes(2)                                    | false          |
 
+---------------------------------------------------------------+----------------+
 
  
Back to Contents_
+
=== notEmpty () : Boolean ===
 +
Returns **true** if *self* contains at least one element, **false** otherwise.
  
excludesAll ( c2 : Collection(T) ) : Boolean
+
{| border="1" cellpadding="5" cellspacing="0"
-----------------------------------------------------------------
+
|-
Returns **true** if no element of *c2* is contained in *self*, **false** otherwise.
+
! style="background: #BCBCBC;" align="center"| Expression
+
! style="background: #BCBCBC;" align="center"| Result
examples:
+
|-
 +
| Sequence{2, 'a'}->notEmpty()
 +
| true
 +
|-
 +
| Sequence{null}->notEmpty()
 +
| true
 +
|-
 +
| Sequence{}->notEmpty()
 +
| false
 +
|}
  
.. class:: exampletable
 
 
+---------------------------------------------------------------+----------------+
 
| Expression                                                    | Result        |
 
+===============================================================+================+
 
| Sequence{2.3, 5.2, 'a', 3, null}->excludesAll(Set{4, null})  | false          |
 
+---------------------------------------------------------------+----------------+
 
| Sequence{2.3, 5.2, 'a', 3}->excludesAll(Set{4, null})        | true          |
 
+---------------------------------------------------------------+----------------+
 
  
Back to Contents_
+
=== one ( expr : OclExpression ) : Boolean ===
 +
Returns **true** if there is only one element contained in *self* that validates the condition *expr*, **false** otherwise.
  
excluding ( object : T ) : Collection(T)
+
{| border="1" cellpadding="5" cellspacing="0"
-----------------------------------------------------------------
+
|-
Returns a collection containing all elements of *self* minus all occurences of *object*.
+
! style="background: #BCBCBC;" align="center"| Expression
**Note** : at the time of writing, the OCL standard library sports a bug which changes *OrderedSets* in *Sets* when
+
! style="background: #BCBCBC;" align="center"| Result
excluding elements.
+
|-
+
| Sequence{1.2, 2.3, 5.2, 0.9}->one(self < 1)
examples:
+
| true
+
|-
.. class:: exampletable
+
| Sequence{1.2, 2.3, 5.2, 0.9}->one(self < 2)
+
| false
+-----------------------------------------------------+-------------------------+
+
|}
| Expression                                         | Result                  |
+
+=====================================================+=========================+
+
| Sequence{'b', 'a', 'b', 'c'}->excluding('b')        | Sequence{'a', 'c'}      |
+
+-----------------------------------------------------+-------------------------+
+
| Bag{'b', 'a', 'b', 'c'}->excluding('b')             | Bag{'c', 'a'}          |
+
+-----------------------------------------------------+-------------------------+
+
| OrderedSet{'b', 'a', 'b', 'c'}->excluding('b')     | Set{'c', 'a'}          |
+
+-----------------------------------------------------+-------------------------+
+
| Set{'b', 'a', 'b', 'c'}->excluding('b')            | Set{'c', 'a'}          |
+
+-----------------------------------------------------+-------------------------+
+
  
Back to Contents_
 
  
exists ( expr : OclExpression ) : Boolean
+
=== product ( c2 : Collection(T2) ) : Set(Tuple(first : T, second : T2)) ===
-----------------------------------------------------------------
+
Returns a Set of Tuples which represents the cartesian product of *self* with *c2*.
Returns **true** if at least one element in *self* validates the condition *expr*, **false** otherwise. The evaluation
+
stops as soon as one element validating *expr* is found.
+
+
examples:
+
  
.. class:: exampletable
+
{| border="1" cellpadding="5" cellspacing="0"
+
|-
+---------------------------------------------------------------+----------------+
+
! style="background: #BCBCBC;" align="center"| Expression
| Expression                                                   | Result        |
+
! style="background: #BCBCBC;" align="center"| Result
+===============================================================+================+
+
|-
| Sequence{2.3, 5.2}->exists(self > 3)                         | true          |
+
| Sequence{3, 4}->product(Bag{3.0, 4.0})
+---------------------------------------------------------------+----------------+
+
| Set{Tuple{3, 3.0}, Tuple{3, 4.0}, Tuple{4, 3.0}, Tuple{4, 4.0}}
 +
|-
 +
| Set{3, 4}->product(OrderedSet{3.0, 4.0})
 +
| Set{Tuple{3, 3.0}, Tuple{3, 4.0}, Tuple{4, 3.0}, Tuple{4, 4.0}}
 +
|}
  
Back to Contents_
 
  
flatten () : Collection(T2)
+
=== reject ( expr : OclExpression ) : Collection(T) ===
-----------------------------------------------------------------
+
Returns a collection with all elements of *self* except for those who validate the OclExpression *expr*.  
Returns a collection containing all elements of *self* recursively flattened.
+
**Note** : at the time of writing, the OCL standard library sports a bug which changes *OrderedSets* in *Sets* when
+
flattening.  
+
+
examples:
+
+
.. class:: exampletable
+
+
+---------------------------------------------------------------------------+-------------------------------------+
+
| Expression                                                                | Result                              |
+
+===========================================================================+=====================================+
+
| Sequence{Set{1, 2, 3}, Sequence{2.0, 3.0}, Bag{'test'}}->flatten()        | Sequence{1, 2, 3, 2.0, 3.0, 'test'} |
+
+---------------------------------------------------------------------------+-------------------------------------+
+
| Bag{Set{Bag{'test', 2, 3.0}}, Sequence{OrderedSet{2.0, 3, 1}}}->flatten() | Bag{1, 2, 3, 2.0, 3.0, 'test'}      |
+
+---------------------------------------------------------------------------+-------------------------------------+
+
| OrderedSet{Set{Bag{'test', 2, 3.0}}, Sequence{Set{2.0, 3, 1}}}->flatten() | Set{3.0, 2, 1, 3, 'test', 2.0}      |
+
+---------------------------------------------------------------------------+-------------------------------------+
+
| Set{Set{Bag{'test', 2, 3.0}}, Sequence{OrderedSet{2.0, 3, 1}}}->flatten() | Set{3.0, 2, 1, 3, 'test', 2.0}      |
+
+---------------------------------------------------------------------------+-------------------------------------+
+
  
Back to Contents_
+
{| border="1" cellpadding="5" cellspacing="0"
 +
|-
 +
! style="background: #BCBCBC;" align="center"| Expression
 +
! style="background: #BCBCBC;" align="center"| Result
 +
|-
 +
| Sequence{1, 2, 3}->reject(i : Integer | i > 1 )
 +
| Sequence{1}
 +
|-
 +
| Bag{1, 2, 3}->reject(i : Integer | i > 1 )
 +
| Bag{1}
 +
|-
 +
| OrderedSet{1, 2, 3}->reject(i : Integer | i > 1 )
 +
| OrderedSet{1}
 +
|-
 +
| Set{1, 2, 3}->reject(i : Integer | i > 1 )
 +
| Set{1}
 +
|}
  
forAll ( expr : OclExpression ) : Boolean
 
-----------------------------------------------------------------
 
Returns **true** if the all the elements contained in *self* validate the condition *expr*, **false** otherwise.
 
 
examples:
 
  
.. class:: exampletable
+
=== select ( expr : OclExpression ) : Collection(T) ===
+
Returns a collection with all elements of *self* that validate the OclExpression *expr*.
+---------------------------------------------------------------+----------------+
+
| Expression                                                    | Result        |
+
+===============================================================+================+
+
| Sequence{2.3, 5.2}->forAll(self > 3)                          | false          |
+
+---------------------------------------------------------------+----------------+
+
| Sequence{2.3, 5.2}->forAll(self > 1.2)                        | true          |
+
+---------------------------------------------------------------+----------------+
+
  
Back to Contents_
+
{| border="1" cellpadding="5" cellspacing="0"
 +
|-
 +
! style="background: #BCBCBC;" align="center"| Expression
 +
! style="background: #BCBCBC;" align="center"| Result
 +
|-
 +
| Sequence{1, 2, 3}->select(i : Integer | i > 1)
 +
| Sequence{2, 3}
 +
|-
 +
| Bag{1, 2, 3}->select(i : Integer | i > 1 )
 +
| Bag{3, 2}
 +
|-
 +
| OrderedSet{1, 2, 3}->select(i : Integer | i > 1 )
 +
| OrderedSet{2, 3}
 +
|-
 +
| Set{1, 2, 3}->select(i : Integer | i > 1 )
 +
| Set{3, 2}
 +
|}
  
includes ( object : T ) : Boolean
 
-----------------------------------------------------------------
 
Returns **true** if *object* is contained in *self*, **false** otherwise.
 
 
examples:
 
  
.. class:: exampletable
+
=== size () : Integer ===
+
Returns the number of elements contained in *self*.
+---------------------------------------------------------------+----------------+
+
| Expression                                                    | Result        |
+
+===============================================================+================+
+
| Sequence{2.3}->includes(2.1)                                  | false          |
+
+---------------------------------------------------------------+----------------+
+
| Sequence{2.0}->includes(2)                                    | true          |
+
+---------------------------------------------------------------+----------------+
+
  
Back to Contents_
+
{| border="1" cellpadding="5" cellspacing="0"
 +
|-
 +
! style="background: #BCBCBC;" align="center"| Expression
 +
! style="background: #BCBCBC;" align="center"| Result
 +
|-
 +
| Sequence{2.3, 5}->size()
 +
| 2
 +
|-
 +
| Sequence{}->size()
 +
| 0
 +
|}
  
includesAll ( c2 : Collection(T) ) : Boolean
 
-----------------------------------------------------------------
 
Returns **true** if all element of *c2* are contained in *self*, **false** otherwise.
 
 
examples:
 
  
.. class:: exampletable
+
=== sortedBy ( expr : OclExpression ) : Sequence(T) ===
+
Returns a sorted collection containing all elements from *self* sorted in accordance with the OclExpression *expr*.
+---------------------------------------------------------------+----------------+
+
This can be used on all kind of collections yet will always yield a Sequence-typed result except for OrderedSet which returns an OrderedSet.
| Expression                                                    | Result        |
+
+===============================================================+================+
+
| Sequence{2.3, 5.2, 'a', 3, null}->includesAll(Set{3, null})  | true          |
+
+---------------------------------------------------------------+----------------+
+
| Sequence{2.3, 5.2, 'a', 3}->includesAll(Set{3, null})        | false          |
+
+---------------------------------------------------------------+----------------+
+
  
Back to Contents_
+
For the purpose of these examples we'll assume here that we have a Class *Employee* with an attribute *age*. Our model contains two employees such as *employee1.age = 24* and *employee2.age = 27*.
  
including ( object : T ) : Collection(T)
+
{| border="1" cellpadding="5" cellspacing="0"
-----------------------------------------------------------------
+
|-
Returns a collection containing all elements of *self* followed by *object*.
+
! style="background: #BCBCBC;" align="center"| Expression
**Note** : at the time of writing, the OCL standard library sports a bug which changes *OrderedSets* in *Sets* when
+
! style="background: #BCBCBC;" align="center"| Result
including elements.
+
|-
+
| self.employees->sortedBy(age)
examples:
+
| Sequence{employee1, employee2}
+
|}
.. class:: exampletable
+
+
+-----------------------------------------------------+-------------------------+
+
| Expression                                         | Result                  |
+
+=====================================================+=========================+
+
| Sequence{'a', 'b'}->including('c')                  | Sequence{'a', 'b', 'c'} |
+
+-----------------------------------------------------+-------------------------+
+
| Bag{'a', 'b'}->including('c')                       | Bag{'a', 'c', 'b'}      |
+
+-----------------------------------------------------+-------------------------+
+
| OrderedSet{'a', 'b'}->including('c')                | Set{'a', 'c', 'b'}      |
+
+-----------------------------------------------------+-------------------------+
+
| Set{'a', 'b'}->including('c')                      | Set{'a', 'c', 'b'}      |
+
+-----------------------------------------------------+-------------------------+
+
  
Back to Contents_
 
  
isEmpty () : Boolean
+
=== sum () : Real ===
-----------------------------------------------------------------
+
Returns the sum of all elements contained in *self* if they support the '+' operation.
Returns **true** if *self* is empty, **false** otherwise.
+
+
examples:
+
  
.. class:: exampletable
+
{| border="1" cellpadding="5" cellspacing="0"
+
|-
+---------------------------------------------------------------+----------------+
+
! style="background: #BCBCBC;" align="center"| Expression
| Expression                                                   | Result        |
+
! style="background: #BCBCBC;" align="center"| Result
+===============================================================+================+
+
|-
| Sequence{2, 'a'}->isEmpty()                                   | false          |
+
| Sequence{2.3, 5.2} in c->sum()
+---------------------------------------------------------------+----------------+
+
| 7.5
| Sequence{null}->isEmpty()                                     | false          |
+
|-
+---------------------------------------------------------------+----------------+
+
| Sequence{2, 4} in c->sum()
| Sequence{}->isEmpty()                                         | true          |
+
| 6
+---------------------------------------------------------------+----------------+
+
|-
 +
| Sequence{2, '4'} in c->sum()
 +
| '''''invalid'''''
 +
|}
  
Back to Contents_
 
  
isUnique ( expr : OclExpression ) : Boolean
+
== Ocl operations for type *Sequence* ==
-----------------------------------------------------------------
+
Returns **true** if all elements contained in *self* evaluate to a distinct value for *expr*.
+
+
examples:
+
  
.. class:: exampletable
+
=== = ( seq : Sequence(T) ) : Boolean ===
+
Returns **true** if *self* contains the very same objects as *seq* in the very same order as they are in *seq*.
+---------------------------------------------------------------+----------------+
+
| Expression                                                    | Result        |
+
+===============================================================+================+
+
| Sequence{2.3, 5.2}->isUnique(self > 3)                        | true          |
+
+---------------------------------------------------------------+----------------+
+
| Sequence{2.3, 5.2}->isUnique(self > 1)                        | false          |
+
+---------------------------------------------------------------+----------------+
+
  
Back to Contents_
+
{| border="1" cellpadding="5" cellspacing="0"
 +
|-
 +
! style="background: #BCBCBC;" align="center"| Expression
 +
! style="background: #BCBCBC;" align="center"| Result
 +
|-
 +
| Sequence{4, 5, 'test'} = Sequence{4, 5, 'test'}
 +
| true
 +
|-
 +
| Sequence{4, 5, 'test'} = Sequence{4, 'test', 5}
 +
| false
 +
|-
 +
| Sequence{4, 5, 'test', 5} = Sequence{4, 5, 'test'}
 +
| false
 +
|}
  
notEmpty () : Boolean
 
-----------------------------------------------------------------
 
Returns **true** if *self* contains at least one element, **false** otherwise.
 
 
 
examples:
+
=== <> ( seq : Sequence(T) ) : Boolean ===
 +
Returns **true** if *self* does not contain the same objects as *seq*, or if these objects are not in the same order as they are in *seq*.
  
.. class:: exampletable
+
{| border="1" cellpadding="5" cellspacing="0"
+
|-
+---------------------------------------------------------------+----------------+
+
! style="background: #BCBCBC;" align="center"| Expression
| Expression                                                   | Result        |
+
! style="background: #BCBCBC;" align="center"| Result
+===============================================================+================+
+
|-
| Sequence{2, 'a'}->notEmpty()                                  | true          |
+
| Sequence{4, 5, 'test'} = Sequence{4, 5, 'test'}
+---------------------------------------------------------------+----------------+
+
| false
| Sequence{null}->notEmpty()                                    | true           |
+
|-
+---------------------------------------------------------------+----------------+
+
| Sequence{4, 5, 'test'} = Sequence{4, 'test', 5}
| Sequence{}->notEmpty()                                        | false          |
+
| true
+---------------------------------------------------------------+----------------+
+
|-
 +
| Sequence{4, 5, 'test', 5} = Sequence{4, 5, 'test'}
 +
| true
 +
|}
  
Back to Contents_
 
  
one ( expr : OclExpression ) : Boolean
+
=== append ( object : T ) : Sequence(T) ===
-----------------------------------------------------------------
+
Returns a Sequence containing all elements of *self* followed by *object*.
Returns **true** if there is only one element contained in *self* that validates the condition *expr*, **false** otherwise.
+
+
examples:
+
  
.. class:: exampletable
+
{| border="1" cellpadding="5" cellspacing="0"
+
|-
+---------------------------------------------------------------+----------------+
+
! style="background: #BCBCBC;" align="center"| Expression
| Expression                                                   | Result        |
+
! style="background: #BCBCBC;" align="center"| Result
+===============================================================+================+
+
|-
| Sequence{1.2, 2.3, 5.2, 0.9}->one(self < 1)                   | true          |
+
| Sequence{'a', 'b'}->append('c')
+---------------------------------------------------------------+----------------+
+
| Sequence{'a', 'b', 'c'}
| Sequence{1.2, 2.3, 5.2, 0.9}->one(self < 2)                  | false          |
+
|}
+---------------------------------------------------------------+----------------+
+
  
Back to Contents_
 
  
product ( c2 : Collection(T2) ) : Set(Tuple(first : T, second : T2))
+
=== at ( index : Integer ) : T ===
--------------------------------------------------------------------
+
Returns the element of *self* at the *index* position.
Returns a Set of Tuples which represents the cartesian product of *self* with *c2*.
+
+
examples (notation of the tuples has been simplified):
+
  
.. class:: exampletable
+
{| border="1" cellpadding="5" cellspacing="0"
+
|-
+------------------------------------------+-----------------------------------------------------------------+
+
! style="background: #BCBCBC;" align="center"| Expression
| Expression                               | Result                                                          |
+
! style="background: #BCBCBC;" align="center"| Result
+==========================================+=================================================================+
+
|-
| Sequence{3, 4}->product(Bag{3.0, 4.0})   | Set{Tuple{3, 3.0}, Tuple{3, 4.0}, Tuple{4, 3.0}, Tuple{4, 4.0}} |
+
| Sequence{'a', 'b'}->at(1)
+------------------------------------------+-----------------------------------------------------------------+
+
| a
| Set{3, 4}->product(OrderedSet{3.0, 4.0}) | Set{Tuple{3, 3.0}, Tuple{3, 4.0}, Tuple{4, 3.0}, Tuple{4, 4.0}} |
+
|}
+------------------------------------------+-----------------------------------------------------------------+
+
  
Back to Contents_
 
  
reject ( expr : OclExpression ) : Collection(T)
+
=== first () : T ===
-----------------------------------------------------------------
+
Returns the first element of *self*.
Returns a collection with all elements of *self* except for those who validate the OclExpression *expr*.  
+
+
examples:
+
+
.. class:: exampletable
+
+
+-------------------------------------------------------+-------------------------+
+
| Expression                                            | Result                  |
+
+=======================================================+=========================+
+
| Sequence{1, 2, 3}->reject(i : Integer | i > 1 )      | Sequence{1}            |
+
+-------------------------------------------------------+-------------------------+
+
| Bag{1, 2, 3}->reject(i : Integer | i > 1 )            | Bag{1}                  |
+
+-------------------------------------------------------+-------------------------+
+
| OrderedSet{1, 2, 3}->reject(i : Integer | i > 1 )    | OrderedSet{1}          |
+
+-------------------------------------------------------+-------------------------+
+
| Set{1, 2, 3}->reject(i : Integer | i > 1 )            | Set{1}                  |
+
+-------------------------------------------------------+-------------------------+
+
  
Back to Contents_
+
{| border="1" cellpadding="5" cellspacing="0"
 +
|-
 +
! style="background: #BCBCBC;" align="center"| Expression
 +
! style="background: #BCBCBC;" align="center"| Result
 +
|-
 +
| Sequence{1, 2.0, '3'}->first()
 +
| 1
 +
|}
  
select ( expr : OclExpression ) : Collection(T)
 
-----------------------------------------------------------------
 
Returns a collection with all elements of *self* that validate the OclExpression *expr*.
 
 
examples:
 
 
.. class:: exampletable
 
 
+-------------------------------------------------------+-------------------------+
 
| Expression                                            | Result                  |
 
+=======================================================+=========================+
 
| Sequence{1, 2, 3}->select(i : Integer | i > 1)        | Sequence{2, 3}          |
 
+-------------------------------------------------------+-------------------------+
 
| Bag{1, 2, 3}->select(i : Integer | i > 1 )            | Bag{3, 2}              |
 
+-------------------------------------------------------+-------------------------+
 
| OrderedSet{1, 2, 3}->select(i : Integer | i > 1 )    | OrderedSet{2, 3}        |
 
+-------------------------------------------------------+-------------------------+
 
| Set{1, 2, 3}->select(i : Integer | i > 1 )            | Set{3, 2}              |
 
+-------------------------------------------------------+-------------------------+
 
  
Back to Contents_
+
=== indexOf ( object : T ) : Integer ===
 +
Returns the position of *object* in sequence *self*.
  
size () : Boolean
+
{| border="1" cellpadding="5" cellspacing="0"
-----------------------------------------------------------------
+
|-
Returns the number of elements contained in *self*.
+
! style="background: #BCBCBC;" align="center"| Expression
+
! style="background: #BCBCBC;" align="center"| Result
examples:
+
|-
 +
| Sequence{'a', 'b'}->indexOf('a')
 +
| 1
 +
|}
  
.. class:: exampletable
 
 
+---------------------------------------------------------------+----------------+
 
| Expression                                                    | Result        |
 
+===============================================================+================+
 
| Sequence{2.3, 5}->size()                                      | 2              |
 
+---------------------------------------------------------------+----------------+
 
| Sequence{}->size()                                            | 0              |
 
+---------------------------------------------------------------+----------------+
 
  
Back to Contents_
+
=== insertAt ( index : Integer, object : T) : Sequence(T) ===
 +
Returns a Sequence containing *self* with *object* inserted at the *index* position.
  
sortedBy ( expr : OclExpression ) : Sequence(T)
+
{| border="1" cellpadding="5" cellspacing="0"
-----------------------------------------------------------------
+
|-
Returns a sorted collection containing all elements from *self* sorted in accordance with the OclExpression *expr*.
+
! style="background: #BCBCBC;" align="center"| Expression
This can be used on all kind of collections yet will always yield a Sequence-typed result except for OrderedSet which
+
! style="background: #BCBCBC;" align="center"| Result
returns an OrderedSet.
+
|-
+
| Sequence{'a', 'b'}->insertAt(0, 'c')
examples:
+
| '''''invalid'''''
+
|-
For the purpose of these examples we'll assume here that we have a Class *Employee* with an attribute *age*. Our
+
| Sequence{'a', 'b'}->insertAt(1, 'c')
model contains two employees such as *employee1.age = 24* and *employee2.age = 27*.
+
| Sequence{'c', 'a', 'b'}
+
|-
.. class:: exampletable
+
| Sequence{'a', 'b'}->insertAt(3, 'c')
+
| Sequence{'a', 'b', 'c'}
+-------------------------------------------------------+--------------------------------+
+
|-
| Expression                                            | Result                        |
+
| Sequence{'a', 'b'}->insertAt(4, 'c')
+=======================================================+================================+
+
| '''''invalid'''''
| self.employees->sortedBy(age)                         | Sequence{employee1, employee2} |
+
|}
+-------------------------------------------------------+--------------------------------+
+
  
Back to Contents_
 
  
sum () : Real
+
=== last () : T ===
-----------------------------------------------------------------
+
Returns the last element of *self*.
Returns the sum of all elements contained in *self* if they support the '+' operation.
+
+
examples:
+
  
.. class:: exampletable
+
{| border="1" cellpadding="5" cellspacing="0"
+
|-
+---------------------------------------------------------------+----------------+
+
! style="background: #BCBCBC;" align="center"| Expression
| Expression                                                   | Result        |
+
! style="background: #BCBCBC;" align="center"| Result
+===============================================================+================+
+
|-
| Sequence{2.3, 5.2} in c->sum()                                | 7.5            |
+
| Sequence{1, 2.0, '3'}->last()
+---------------------------------------------------------------+----------------+
+
| '3'
| Sequence{2, 4} in c->sum()                                   | 6              |
+
|}
+---------------------------------------------------------------+----------------+
+
| Sequence{2, '4'} in c->sum()                                  | |invalid|      |
+
+---------------------------------------------------------------+----------------+
+
  
Back to Contents_
 
  
Ocl operations for type *Sequence*
+
=== prepend ( object : T ) : Sequence(T) ===
-----------------------------------------------------------------
+
Returns a Sequence containing *object* followed by all elements of *self* .
  
= ( seq : Sequence(T) ) : Boolean ___________________________________________________________________________
+
{| border="1" cellpadding="5" cellspacing="0"
Returns **true** if *self* contains the very same objects as *seq* in the very same order as they are in *seq*.
+
|-
+
! style="background: #BCBCBC;" align="center"| Expression
examples:
+
! style="background: #BCBCBC;" align="center"| Result
+
|-
.. class:: exampletable
+
| Sequence{'a', 'b'}->prepend('c')
+
| Sequence{'c', 'a', 'b'}
+---------------------------------------------------------------+----------------+
+
|}
| Expression                                                   | Result        |
+
+===============================================================+================+
+
| Sequence{4, 5, 'test'} = Sequence{4, 5, 'test'}              | true          |
+
+---------------------------------------------------------------+----------------+
+
| Sequence{4, 5, 'test'} = Sequence{4, 'test', 5}               | false          |
+
+---------------------------------------------------------------+----------------+
+
| Sequence{4, 5, 'test', 5} = Sequence{4, 5, 'test'}           | false          |
+
+---------------------------------------------------------------+----------------+
+
  
Back to Contents_
 
 
<> ( seq : Sequence(T) ) : Boolean ___________________________________________________________________________
 
Returns **true** if *self* does not contain the same objects as *seq*, or if these objects are not in the same order
 
as they are in *seq*.
 
 
examples:
 
 
.. class:: exampletable
 
 
+---------------------------------------------------------------+----------------+
 
| Expression                                                    | Result        |
 
+===============================================================+================+
 
| Sequence{4, 5, 'test'} = Sequence{4, 5, 'test'}              | false          |
 
+---------------------------------------------------------------+----------------+
 
| Sequence{4, 5, 'test'} = Sequence{4, 'test', 5}              | true          |
 
+---------------------------------------------------------------+----------------+
 
| Sequence{4, 5, 'test', 5} = Sequence{4, 5, 'test'}            | true          |
 
+---------------------------------------------------------------+----------------+
 
  
Back to Contents_
+
=== subSequence ( startIndex : Integer, endIndex : Integer ) : Sequence(T) ===
 +
Returns a Sequence containing all elements of *self* between the positions 'startIndex' and 'endIndex'.
  
append ( object : T ) : Sequence(T)
+
{| border="1" cellpadding="5" cellspacing="0"
___________________________________________________________________________
+
|-
Returns a Sequence containing all elements of *self* followed by *object*.
+
! style="background: #BCBCBC;" align="center"| Expression
+
! style="background: #BCBCBC;" align="center"| Result
examples:
+
|-
+
| Sequence{'a', 'b', 'c', 'd'}->subSequence(2, 3)
.. class:: exampletable
+
| Sequence{'b', 'c'}
+
|-
+-----------------------------------------------------+-------------------------+
+
| Sequence{'a', 'b', 'c', 'd'}->subSequence(4, 4)
| Expression                                         | Result                  |
+
| Sequence{'d'}
+=====================================================+=========================+
+
|}
| Sequence{'a', 'b'}->append('c')                    | Sequence{'a', 'b', 'c'} |
+
+-----------------------------------------------------+-------------------------+
+
  
Back to Contents_
 
  
at ( index : Integer ) : T ___________________________________________________________________________
+
=== union ( seq : Sequence(T) ) : Sequence(T) ===
Returns the element of *self* at the *index* position.
+
Returns a Sequence containing all elements of *self* followed by all elements of *seq*.
+
examples:
+
+
.. class:: exampletable
+
+
+-----------------------------------------------------+-------------------------+
+
| Expression                                          | Result                  |
+
+=====================================================+=========================+
+
| Sequence{'a', 'b'}->at(1)                          | a                      |
+
+-----------------------------------------------------+-------------------------+
+
  
Back to Contents_
+
{| border="1" cellpadding="5" cellspacing="0"
 +
|-
 +
! style="background: #BCBCBC;" align="center"| Expression
 +
! style="background: #BCBCBC;" align="center"| Result
 +
|-
 +
| Sequence{'a', 'b', 'a'}->union(Sequence{'b', 'c'})
 +
| Sequence{'a', 'b', 'a', 'b', 'c'}
 +
|}
  
first () : T ___________________________________________________________________________
 
Returns the first element of *self*.
 
 
examples:
 
 
.. class:: exampletable
 
 
+-----------------------------------------------------+-------------------------+
 
| Expression                                          | Result                  |
 
+=====================================================+=========================+
 
| Sequence{1, 2.0, '3'}->first()                      | 1                      |
 
+-----------------------------------------------------+-------------------------+
 
  
Back to Contents_
+
== Ocl operations for type *Bag* ==
  
indexOf ( object : T ) : Integer ___________________________________________________________________________
+
=== = ( bag : Bag(T) ) : Boolean ===
Returns the position of *object* in sequence *self*.
+
Returns **true** if *self* contains the same objects as *bag* in the same quantities.
+
examples:
+
+
.. class:: exampletable
+
+
+-----------------------------------------------------+-------------------------+
+
| Expression                                          | Result                  |
+
+=====================================================+=========================+
+
| Sequence{'a', 'b'}->indexOf('a')                    | 1                      |
+
+-----------------------------------------------------+-------------------------+
+
  
Back to Contents_
+
{| border="1" cellpadding="5" cellspacing="0"
 +
|-
 +
! style="background: #BCBCBC;" align="center"| Expression
 +
! style="background: #BCBCBC;" align="center"| Result
 +
|-
 +
| Bag{4, 5, 'test', 4} = Bag{4, 'test', 5, 4}
 +
| true
 +
|-
 +
| Bag{4, 5, 'test'} = Bag{4, 'test', 5}
 +
| true
 +
|-
 +
| Bag{4, 5, 'test', 5} = Bag{4, 5, 'test'}
 +
| false
 +
|}
  
insertAt ( index : Integer, object : T) : Sequence(T)
 
___________________________________________________________________________
 
Returns a Sequence containing *self* with *object* inserted at the *index* position.
 
 
examples:
 
 
.. class:: exampletable
 
 
+-----------------------------------------------------+-------------------------+
 
| Expression                                          | Result                  |
 
+=====================================================+=========================+
 
|Sequence{'a', 'b'}->insertAt(0, 'c')                | |invalid|              |
 
+-----------------------------------------------------+-------------------------+
 
|Sequence{'a', 'b'}->insertAt(1, 'c')                | Sequence{'c', 'a', 'b'} |
 
+-----------------------------------------------------+-------------------------+
 
|Sequence{'a', 'b'}->insertAt(3, 'c')                | Sequence{'a', 'b', 'c'} |
 
+-----------------------------------------------------+-------------------------+
 
|Sequence{'a', 'b'}->insertAt(4, 'c')                | |invalid|              |
 
+-----------------------------------------------------+-------------------------+
 
  
Back to Contents_
+
=== <> ( bag : Bag(T) ) : Boolean ===
 +
Returns **true** if *self* does not contain the same objects as *bag* in the same quantities.
  
last () : T ___________________________________________________________________________
+
{| border="1" cellpadding="5" cellspacing="0"
Returns the last element of *self*.
+
|-
+
! style="background: #BCBCBC;" align="center"| Expression
examples:
+
! style="background: #BCBCBC;" align="center"| Result
+
|-
.. class:: exampletable
+
| Bag{4, 5, 'test'} = Bag{4, 5, 'test'}
+
| false
+-----------------------------------------------------+-------------------------+
+
|-
| Expression                                          | Result                  |
+
| Bag{4, 5, 'test'} = Bag{4, 'test', 5}
+=====================================================+=========================+
+
| false
| Sequence{1, 2.0, '3'}->last()                      | '3'                     |
+
|-
+-----------------------------------------------------+-------------------------+
+
| Bag{4, 5, 'test', 5} = Bag{4, 5, 'test'}
 +
| true
 +
|}
  
Back to Contents_
 
  
prepend ( object : T ) : Sequence(T)
+
=== intersection ( bag : Bag(T) ) : Bag(T) ===
___________________________________________________________________________
+
Returns a Bag containing all elements of *self* that are also contained by *bag*.
Returns a Sequence containing *object* followed by all elements of *self* .
+
+
examples:
+
+
.. class:: exampletable
+
+
+-----------------------------------------------------+-------------------------+
+
| Expression                                          | Result                  |
+
+=====================================================+=========================+
+
| Sequence{'a', 'b'}->prepend('c')                    | Sequence{'c', 'a', 'b'} |
+
+-----------------------------------------------------+-------------------------+
+
  
Back to Contents_
+
{| border="1" cellpadding="5" cellspacing="0"
 +
|-
 +
! style="background: #BCBCBC;" align="center"| Expression
 +
! style="background: #BCBCBC;" align="center"| Result
 +
|-
 +
| Bag{'a', 'b', 'a'}->intersection(Bag{'a', 'b'})
 +
| Bag{'a', 'b'}
 +
|-
 +
| Bag{'a', 'b', 'a', 'b'}->intersection(Bag{'a', 'b', 'b'})
 +
| Bag{'b', 'a', 'b'}
 +
|}
  
subSequence ( startIndex : Integer, endIndex : Integer ) : Sequence(T)
 
___________________________________________________________________________
 
Returns a Sequence containing all elements of *self* between the positions 'startIndex' and 'endIndex'.
 
 
 
examples:
+
=== intersection ( set : Set(T) ) : Set(T) ===
+
Returns a Set containing all elements of *self* that are also contained by *set*.
.. class:: exampletable
+
+
+-----------------------------------------------------+-------------------------+
+
| Expression                                          | Result                  |
+
+=====================================================+=========================+
+
| Sequence{'a', 'b', 'c', 'd'}->subSequence(2, 3)    | Sequence{'b', 'c'}      |
+
+-----------------------------------------------------+-------------------------+
+
| Sequence{'a', 'b', 'c', 'd'}->subSequence(4, 4)    | Sequence{'d'}          |
+
+-----------------------------------------------------+-------------------------+
+
  
Back to Contents_
+
{| border="1" cellpadding="5" cellspacing="0"
 +
|-
 +
! style="background: #BCBCBC;" align="center"| Expression
 +
! style="background: #BCBCBC;" align="center"| Result
 +
|-
 +
| Bag{'a', 'b', 'a'}->intersection(Set{'a', 'b', 'c'})
 +
| Set{'a', 'b'}
 +
|}
  
union ( seq : Sequence(T) ) : Sequence(T)
 
___________________________________________________________________________
 
Returns a Sequence containing all elements of *self* followed by all elements of *seq*.
 
 
examples:
 
 
.. class:: exampletable
 
 
+-----------------------------------------------------+-----------------------------------+
 
| Expression                                          | Result                            |
 
+=====================================================+===================================+
 
| Sequence{'a', 'b', 'a'}->union(Sequence{'b', 'c'})  | Sequence{'a', 'b', 'a', 'b', 'c'} |
 
+-----------------------------------------------------+-----------------------------------+
 
  
Back to Contents_
+
=== union ( bag : Bag(T) ) : Bag(T) ===
 +
Returns a Bag containing all elements of *self* and all elements of *bag*.
  
Ocl operations for type *Bag*
+
{| border="1" cellpadding="5" cellspacing="0"
-----------------------------------------------------------------
+
|-
 +
! style="background: #BCBCBC;" align="center"| Expression
 +
! style="background: #BCBCBC;" align="center"| Result
 +
|-
 +
| Bag{'a', 'b', 'a'}->union(Bag{'b', 'c'})
 +
| Bag{'b', 'a', 'b', 'a', 'c'}
 +
|}
  
= ( bag : Bag(T) ) : Boolean ___________________________________________________________________________
 
Returns **true** if *self* contains the same objects as *bag* in the same quantities.
 
 
examples:
 
 
.. class:: exampletable
 
 
+---------------------------------------------------------------+----------------+
 
| Expression                                                    | Result        |
 
+===============================================================+================+
 
| Bag{4, 5, 'test', 4} = Bag{4, 'test', 5, 4}                  | true          |
 
+---------------------------------------------------------------+----------------+
 
| Bag{4, 5, 'test'} = Bag{4, 'test', 5}                        | true          |
 
+---------------------------------------------------------------+----------------+
 
| Bag{4, 5, 'test', 5} = Bag{4, 5, 'test'}                      | false          |
 
+---------------------------------------------------------------+----------------+
 
  
Back to Contents_
+
=== union ( set : Set(T) ) : Bag(T) ===
 +
Returns a Bag containing all elements of *self* and all elements of *set*.
  
<> ( bag : Bag(T) ) : Boolean ___________________________________________________________________________
+
{| border="1" cellpadding="5" cellspacing="0"
Returns **true** if *self* does not contain the same objects as *bag* in the same quantities.
+
|-
+
! style="background: #BCBCBC;" align="center"| Expression
examples:
+
! style="background: #BCBCBC;" align="center"| Result
+
|-
.. class:: exampletable
+
| Bag{'a', 'b', 'a'}->union(Set{'b', 'c'})
+
| Bag{'b', 'c', 'a', 'b', 'a'}
+---------------------------------------------------------------+----------------+
+
|}
| Expression                                                   | Result        |
+
+===============================================================+================+
+
| Bag{4, 5, 'test'} = Bag{4, 5, 'test'}                         | false          |
+
+---------------------------------------------------------------+----------------+
+
| Bag{4, 5, 'test'} = Bag{4, 'test', 5}                         | false          |
+
+---------------------------------------------------------------+----------------+
+
| Bag{4, 5, 'test', 5} = Bag{4, 5, 'test'}                     | true          |
+
+---------------------------------------------------------------+----------------+
+
  
Back to Contents_
 
  
intersection ( bag : Bag(T) ) : Bag(T)
+
== Ocl operations for type *OrderedSet* ==
___________________________________________________________________________
+
=== = ( set : Set(T) ) : Boolean ===
Returns a Bag containing all elements of *self* that are also contained by *bag*.
+
Returns **true** if *self* contains the same objects as *set*.
+
 
examples:
+
{| border="1" cellpadding="5" cellspacing="0"
+
|-
.. class:: exampletable
+
! style="background: #BCBCBC;" align="center"| Expression
+
! style="background: #BCBCBC;" align="center"| Result
+-----------------------------------------------------------+-----------------------------------+
+
|-
| Expression                                               | Result                            |
+
| OrderedSet{3, 5, 4} = Set{3, 5, 4}
+===========================================================+===================================+
+
| true
| Bag{'a', 'b', 'a'}->intersection(Bag{'a', 'b'})          | Bag{'a', 'b'}                     |
+
|-
+-----------------------------------------------------------+-----------------------------------+
+
| OrderedSet{3, 5, 4} = Set{4, 3, 5, 4, 4}
| Bag{'a', 'b', 'a', 'b'}->intersection(Bag{'a', 'b', 'b'}) | Bag{'b', 'a', 'b'}               |
+
| true
+-----------------------------------------------------------+-----------------------------------+
+
|-
 +
| OrderedSet{3, 5, 4} = Set{2, 5 ,4, 4}
 +
| false
 +
|}
  
Back to Contents_
 
 
intersection ( set : Set(T) ) : Set(T)
 
___________________________________________________________________________
 
Returns a Set containing all elements of *self* that are also contained by *set*.
 
 
examples:
 
 
.. class:: exampletable
 
 
 
+----------------------------------------------------------+-----------------------------------+
+
=== = ( orderedset : OrderedSet(T) ) : Boolean ===
| Expression                                              | Result                            |
+
Returns **true** if *self* contains the same objects as *orderedset* regardless of element ordering.
+==========================================================+===================================+
+
| Bag{'a', 'b', 'a'}->intersection(Set{'a', 'b', 'c'})    | Set{'a', 'b'}                    |
+
+----------------------------------------------------------+-----------------------------------+
+
  
Back to Contents_
+
{| border="1" cellpadding="5" cellspacing="0"
 +
|-
 +
! style="background: #BCBCBC;" align="center"| Expression
 +
! style="background: #BCBCBC;" align="center"| Result
 +
|-
 +
| OrderedSet{3, 5, 4} = OrderedSet{3, 5, 4}
 +
| true
 +
|-
 +
| OrderedSet{4, 5, 'test', 5} = OrderedSet{4, 5, 'test'}
 +
| true
 +
|-
 +
| OrderedSet{4, 5, 'test'} = OrderedSet{4, 'test', 5}
 +
| true
 +
|-
 +
| OrderedSet{4, 5, 'test'} = OrderedSet{4, 'test'}
 +
| false
 +
|}
  
union ( bag : Bag(T) ) : Bag(T)
 
___________________________________________________________________________
 
Returns a Bag containing all elements of *self* and all elements of *bag*.
 
 
examples:
 
 
.. class:: exampletable
 
 
+-----------------------------------------------------+-----------------------------------+
 
| Expression                                          | Result                            |
 
+=====================================================+===================================+
 
| Bag{'a', 'b', 'a'}->union(Bag{'b', 'c'})            | Bag{'b', 'a', 'b', 'a', 'c'}      |
 
+-----------------------------------------------------+-----------------------------------+
 
  
Back to Contents_
+
=== <> ( set : Set(T) ) : Boolean ===
 +
Returns **true** if *self* does not contain the same objects as *set*.
  
union ( set : Set(T) ) : Bag(T)
+
{| border="1" cellpadding="5" cellspacing="0"
___________________________________________________________________________
+
|-
Returns a Bag containing all elements of *self* and all elements of *set*.
+
! style="background: #BCBCBC;" align="center"| Expression
+
! style="background: #BCBCBC;" align="center"| Result
examples:
+
|-
+
| OrderedSet{4, 5, 'test', 4} <> Set{4, 5, 'test'}
.. class:: exampletable
+
| false
+
|-
+-----------------------------------------------------+-----------------------------------+
+
| OrderedSet{4, 5, 'test', 4} <> Set{4, 'test', 5, 4}
| Expression                                         | Result                            |
+
| false
+=====================================================+===================================+
+
|-
| Bag{'a', 'b', 'a'}->union(Set{'b', 'c'})            | Bag{'b', 'c', 'a', 'b', 'a'}     |
+
| OrderedSet{4, 5, 'test', 4} <> Set{4, 5, 'test', 2}
+-----------------------------------------------------+-----------------------------------+
+
| true
 +
|}
  
Back to Contents_
 
  
Ocl operations for type *OrderedSet*
+
=== <> ( orderedset : OrderedSet(T) ) : Boolean ===
-----------------------------------------------------------------
+
Returns **true** if *self* does not contain the same objects as *orderedset*.
  
= ( set : Set(T) ) : Boolean ___________________________________________________________________________
+
{| border="1" cellpadding="5" cellspacing="0"
Returns **true** if *self* contains the same objects as *set*.
+
|-
+
! style="background: #BCBCBC;" align="center"| Expression
examples:
+
! style="background: #BCBCBC;" align="center"| Result
+
|-
.. class:: exampletable
+
| OrderedSet{4, 5, 'test', 4} <> OrderedSet{4, 5, 'test')
+
| false
+---------------------------------------------------------------+----------------+
+
|-
| Expression                                                   | Result        |
+
| OrderedSet{4, 5, 'test', 4} <> OrderedSet{4, 'test', 5, 4}
+===============================================================+================+
+
| false
| OrderedSet{3, 5, 4} = Set{3, 5, 4}                            | true          |
+
|-
+---------------------------------------------------------------+----------------+
+
| OrderedSet{4, 5, 'test', 4} <> OrderedSet{4, 5, 'test', 2}
| OrderedSet{3, 5, 4} = Set{4, 3, 5, 4, 4}                     | true          |
+
| true
+---------------------------------------------------------------+----------------+
+
|}
| OrderedSet{3, 5, 4} = Set{2, 5 ,4, 4}                         | false          |
+
+---------------------------------------------------------------+----------------+
+
  
Back to Contents_
 
 
= ( orderedset : OrderedSet(T) ) : Boolean ___________________________________________________________________________
 
Returns **true** if *self* contains the same objects as *orderedset* regardless of element ordering.
 
 
examples:
 
 
.. class:: exampletable
 
 
+---------------------------------------------------------------+----------------+
 
| Expression                                                    | Result        |
 
+===============================================================+================+
 
| OrderedSet{3, 5, 4} = OrderedSet{3, 5, 4}                    | true          |
 
+---------------------------------------------------------------+----------------+
 
| OrderedSet{4, 5, 'test', 5} = OrderedSet{4, 5, 'test'}        | true          |
 
+---------------------------------------------------------------+----------------+
 
| OrderedSet{4, 5, 'test'} = OrderedSet{4, 'test', 5}          | true          |
 
+---------------------------------------------------------------+----------------+
 
| OrderedSet{4, 5, 'test'} = OrderedSet{4, 'test'}              | false          |
 
+---------------------------------------------------------------+----------------+
 
  
Back to Contents_
+
=== `-` ( set : Set(T) ) : Set(T) ===
 +
Returns a Set containing all elements of *self* minus all elements of *set*.
  
<> ( set : Set(T) ) : Boolean ___________________________________________________________________________
+
{| border="1" cellpadding="5" cellspacing="0"
Returns **true** if *self* does not contain the same objects as *set*.
+
|-
+
! style="background: #BCBCBC;" align="center"| Expression
examples:
+
! style="background: #BCBCBC;" align="center"| Result
+
|-
.. class:: exampletable
+
| OrderedSet{'a', 'b', 'c'} - Set{'c', 'a'}
+
| Set{'b'}
+---------------------------------------------------------------+----------------+
+
|}
| Expression                                                   | Result        |
+
+===============================================================+================+
+
| OrderedSet{4, 5, 'test', 4} <> Set{4, 5, 'test'}             | false          |
+
+---------------------------------------------------------------+----------------+
+
| OrderedSet{4, 5, 'test', 4} <> Set{4, 'test', 5, 4}           | false          |
+
+---------------------------------------------------------------+----------------+
+
| OrderedSet{4, 5, 'test', 4} <> Set{4, 5, 'test', 2}           | true          |
+
+---------------------------------------------------------------+----------------+
+
  
Back to Contents_
 
  
<> ( orderedset : OrderedSet(T) ) : Boolean ___________________________________________________________________________
+
=== append ( object : T ) : OrderedSet(T) ===
Returns **true** if *self* does not contain the same objects as *orderedset*.
+
Returns an OrderedSet containing all elements of *self* followed by *object*.
+
examples:
+
+
.. class:: exampletable
+
+
+---------------------------------------------------------------+----------------+
+
| Expression                                                    | Result        |
+
+===============================================================+================+
+
| OrderedSet{4, 5, 'test', 4} <> OrderedSet{4, 5, 'test')      | false          |
+
+---------------------------------------------------------------+----------------+
+
| OrderedSet{4, 5, 'test', 4} <> OrderedSet{4, 'test', 5, 4}    | false          |
+
+---------------------------------------------------------------+----------------+
+
| OrderedSet{4, 5, 'test', 4} <> OrderedSet{4, 5, 'test', 2}    | true          |
+
+---------------------------------------------------------------+----------------+
+
  
Back to Contents_
+
{| border="1" cellpadding="5" cellspacing="0"
 +
|-
 +
! style="background: #BCBCBC;" align="center"| Expression
 +
! style="background: #BCBCBC;" align="center"| Result
 +
|-
 +
| OrderedSet{'a', 'b'}->append('c')
 +
| OrderedSet{'a', 'b', 'c'}
 +
|}
  
`-` ( set : Set(T) ) : Set(T)
 
___________________________________________________________________________
 
Returns a Set containing all elements of *self* minus all elements of *set*.
 
 
examples:
 
 
.. class:: exampletable
 
 
+-----------------------------------------------------+-----------------------------------+
 
| Expression                                          | Result                            |
 
+=====================================================+===================================+
 
| OrderedSet{'a', 'b', 'c'} - Set{'c', 'a'}          | Set{'b'}                          |
 
+-----------------------------------------------------+-----------------------------------+
 
  
Back to Contents_
+
=== at ( index : Integer ) : T ===
 +
Returns the element of *self* located at position *index* in the collection.
  
append ( object : T ) : OrderedSet(T)
+
{| border="1" cellpadding="5" cellspacing="0"
___________________________________________________________________________
+
|-
Returns an OrderedSet containing all elements of *self* followed by *object*.
+
! style="background: #BCBCBC;" align="center"| Expression
+
! style="background: #BCBCBC;" align="center"| Result
examples:
+
|-
+
| OrderedSet{'a', 'b'}->at(1)
.. class:: exampletable
+
| 'a'
+
|}
+-----------------------------------------------------+---------------------------+
+
| Expression                                         | Result                    |
+
+=====================================================+===========================+
+
| OrderedSet{'a', 'b'}->append('c')                   | OrderedSet{'a', 'b', 'c'} |
+
+-----------------------------------------------------+---------------------------+
+
  
Back to Contents_
 
  
at ( index : Integer ) : T ___________________________________________________________________________
+
=== first () : T ===
Returns the element of *self* located at position *index* in the collection.
+
Returns the first element of *self*.
+
examples:
+
+
.. class:: exampletable
+
+
+-----------------------------------------------------+-------------------------+
+
| Expression                                          | Result                  |
+
+=====================================================+=========================+
+
| OrderedSet{'a', 'b'}->at(1)                        | 'a'                    |
+
+-----------------------------------------------------+-------------------------+
+
  
Back to Contents_
+
{| border="1" cellpadding="5" cellspacing="0"
 +
|-
 +
! style="background: #BCBCBC;" align="center"| Expression
 +
! style="background: #BCBCBC;" align="center"| Result
 +
|-
 +
| OrderedSet{1, 2.0, '3'}->first()
 +
| 1
 +
|}
  
first () : T ___________________________________________________________________________
 
Returns the first element of *self*.
 
 
examples:
 
 
.. class:: exampletable
 
 
+-----------------------------------------------------+-------------------------+
 
| Expression                                          | Result                  |
 
+=====================================================+=========================+
 
| OrderedSet{1, 2.0, '3'}->first()                    | 1                      |
 
+-----------------------------------------------------+-------------------------+
 
  
Back to Contents_
+
=== indexOf ( object : T ) : Integer ===
 +
Returns the position of *object* in *self*.
  
indexOf ( object : T ) : Integer ___________________________________________________________________________
+
{| border="1" cellpadding="5" cellspacing="0"
Returns the position of *object* in *self*.
+
|-
+
! style="background: #BCBCBC;" align="center"| Expression
examples:
+
! style="background: #BCBCBC;" align="center"| Result
+
|-
.. class:: exampletable
+
| OrderedSet{'a', 'b'}->indexOf('a')
+
| 1
+-----------------------------------------------------+-------------------------+
+
|}
| Expression                                         | Result                  |
+
+=====================================================+=========================+
+
| OrderedSet{'a', 'b'}->indexOf('a')                 | 1                       |
+
+-----------------------------------------------------+-------------------------+
+
  
Back to Contents_
 
  
insertAt ( index : Integer, object : T ) : OrderedSet(T)
+
=== insertAt ( index : Integer, object : T ) : OrderedSet(T) ===
___________________________________________________________________________
+
Returns an OrderedSet containing *self* with *object* inserted at the *index* position.
Returns an OrderedSet containing *self* with *object* inserted at the *index* position.
+
+
examples:
+
+
.. class:: exampletable
+
+
+-----------------------------------------------------+---------------------------+
+
| Expression                                          | Result                    |
+
+=====================================================+===========================+
+
| OrderedSet{'a', 'b'}->insertAt(1, 'c')              | OrderedSet{'c', 'a', 'b'} |
+
+-----------------------------------------------------+---------------------------+
+
| OrderedSet{'a', 'b'}->insertAt(3, 'c')              | OrderedSet{'a', 'b', 'c'} |
+
+-----------------------------------------------------+---------------------------+
+
  
Back to Contents_
+
{| border="1" cellpadding="5" cellspacing="0"
 +
|-
 +
! style="background: #BCBCBC;" align="center"| Expression
 +
! style="background: #BCBCBC;" align="center"| Result
 +
|-
 +
| OrderedSet{'a', 'b'}->insertAt(1, 'c')
 +
| OrderedSet{'c', 'a', 'b'}
 +
|-
 +
| OrderedSet{'a', 'b'}->insertAt(3, 'c')
 +
| OrderedSet{'a', 'b', 'c'}
 +
|}
  
intersection ( bag : Bag(T) ) : Set(T)
 
___________________________________________________________________________
 
Returns a Set containing all elements of *self* that are also contained by *bag*.
 
 
examples:
 
 
.. class:: exampletable
 
 
+--------------------------------------------------------+--------------------------------+
 
| Expression                                            | Result                        |
 
+========================================================+================================+
 
| OrderedSet{'a', 'b', 'a'}->intersection(Bag{'a', 'b'}) | Set{'a', 'b'}                  |
 
+--------------------------------------------------------+--------------------------------+
 
  
Back to Contents_
+
=== intersection ( bag : Bag(T) ) : Set(T) ===
 +
Returns a Set containing all elements of *self* that are also contained by *bag*.
  
intersection ( set : Set(T) ) : Set(T)
+
{| border="1" cellpadding="5" cellspacing="0"
___________________________________________________________________________
+
|-
Returns a Set containing all elements of *self* that are also contained by *set*.
+
! style="background: #BCBCBC;" align="center"| Expression
+
! style="background: #BCBCBC;" align="center"| Result
examples:
+
|-
+
| OrderedSet{'a', 'b', 'a'}->intersection(Bag{'a', 'b'})
.. class:: exampletable
+
| Set{'a', 'b'}
+
|}
+--------------------------------------------------------+--------------------------------+
+
| Expression                                             | Result                        |
+
+========================================================+================================+
+
| OrderedSet{'a', 'b', 'a'}->intersection(Set{'a', 'b'}) | Set{'b', 'a'}                 |
+
+--------------------------------------------------------+--------------------------------+
+
  
Back to Contents_
 
  
last () : T ___________________________________________________________________________
+
=== intersection ( set : Set(T) ) : Set(T) ===
Returns the last element of *self*.
+
Returns a Set containing all elements of *self* that are also contained by *set*.
+
examples:
+
+
.. class:: exampletable
+
+
+-----------------------------------------------------+-------------------------+
+
| Expression                                          | Result                  |
+
+=====================================================+=========================+
+
|OrderedSet{1, 2.0, '3'}->last()                      | '3'                    |
+
+-----------------------------------------------------+-------------------------+
+
  
Back to Contents_
+
{| border="1" cellpadding="5" cellspacing="0"
 +
|-
 +
! style="background: #BCBCBC;" align="center"| Expression
 +
! style="background: #BCBCBC;" align="center"| Result
 +
|-
 +
| OrderedSet{'a', 'b', 'a'}->intersection(Set{'a', 'b'})
 +
| Set{'a', 'b'}
 +
|}
  
prepend ( object : T ) : OrderedSet(T)
 
___________________________________________________________________________
 
Returns an OrderedSet containing *object* followed by all elements of *self*.
 
 
examples:
 
 
.. class:: exampletable
 
 
+-----------------------------------------------------+---------------------------+
 
| Expression                                          | Result                    |
 
+=====================================================+===========================+
 
| OrderedSet{'a', 'b'}->prepend('c')                  | OrderedSet{'c', 'a', 'b'} |
 
+-----------------------------------------------------+---------------------------+
 
  
Back to Contents_
+
=== last () : T ===
 +
Returns the last element of *self*.
  
subOrderedSet ( startIndex : Integer, endIndex : Integer ) : OrderedSet(T)
+
{| border="1" cellpadding="5" cellspacing="0"
___________________________________________________________________________
+
|-
Returns an OrderedSet containing all elements of *self* between the positions *startIndex* and *endIndex*.
+
! style="background: #BCBCBC;" align="center"| Expression
+
! style="background: #BCBCBC;" align="center"| Result
examples:
+
|-
+
| OrderedSet{1, 2.0, '3'}->last()
.. class:: exampletable
+
| '3'
+
|}
+-----------------------------------------------------+---------------------------+
+
| Expression                                         | Result                    |
+
+=====================================================+===========================+
+
| OrderedSet{'a', 'b', 'c', 'd'}->subOrderedSet(2, 3) | OrderedSet{'b', 'c'}      |
+
+-----------------------------------------------------+---------------------------+
+
| OrderedSet{'a', 'b', 'c', 'd'}->subOrderedSet(4, 4) | OrderedSet{'d'}           |
+
+-----------------------------------------------------+---------------------------+
+
  
Back to Contents_
 
  
symmetricDifference ( set : Set(T) ) : Set(T)
+
=== prepend ( object : T ) : OrderedSet(T) ===
___________________________________________________________________________
+
Returns an OrderedSet containing *object* followed by all elements of *self*.
Returns a Set containing all of the elements of *self* and *set* that are not present in both.
+
+
examples:
+
+
.. class:: exampletable
+
+
+-------------------------------------------------------------------------+---------------+
+
| Expression                                                              | Result        |
+
+=========================================================================+===============+
+
| OrderedSet{'b', 'a', 'b', 'c'}->symmetricDifference(Set{'a', 'c', 'd'}) | Set{'d', 'b'} |
+
+-------------------------------------------------------------------------+---------------+
+
  
Back to Contents_
+
{| border="1" cellpadding="5" cellspacing="0"
 +
|-
 +
! style="background: #BCBCBC;" align="center"| Expression
 +
! style="background: #BCBCBC;" align="center"| Result
 +
|-
 +
| OrderedSet{'a', 'b'}->prepend('c')
 +
| OrderedSet{'c', 'a', 'b'}
 +
|}
  
union ( bag : Bag(T) ) : Bag(T)
 
___________________________________________________________________________
 
Returns a Bag containing all elements of *self* followed by all elements of *bag*.
 
 
examples:
 
 
.. class:: exampletable
 
 
+-----------------------------------------------------+-----------------------------------+
 
| Expression                                          | Result                            |
 
+=====================================================+===================================+
 
| OrderedSet{'a', 'b', 'a'}->union(Bag{'b', 'c'})    | Bag{'a', 'c', 'b', 'b'}          |
 
+-----------------------------------------------------+-----------------------------------+
 
  
Back to Contents_
+
=== subOrderedSet ( startIndex : Integer, endIndex : Integer ) : OrderedSet(T) ===
 +
Returns an OrderedSet containing all elements of *self* between the positions *startIndex* and *endIndex*.
  
union ( set : Set(T) ) : Set(T)
+
{| border="1" cellpadding="5" cellspacing="0"
___________________________________________________________________________
+
|-
Returns a Set containing all elements of *self* followed by all elements of *set*.
+
! style="background: #BCBCBC;" align="center"| Expression
+
! style="background: #BCBCBC;" align="center"| Result
examples:
+
|-
+
| OrderedSet{'a', 'b', 'c', 'd'}->subOrderedSet(2, 3)
.. class:: exampletable
+
| OrderedSet{'b', 'c'}
+
|-
+-----------------------------------------------------+-----------------------------------+
+
| OrderedSet{'a', 'b', 'c', 'd'}->subOrderedSet(4, 4)
| Expression                                         | Result                            |
+
| OrderedSet{'d'}
+=====================================================+===================================+
+
|}
| OrderedSet{'a', 'b', 'a'}->union(Set{'b', 'c'})    | Set{'a', 'c', 'b'}               |
+
+-----------------------------------------------------+-----------------------------------+
+
  
Back to Contents_
 
  
Ocl operations for type *Set*
+
=== symmetricDifference ( set : Set(T) ) : Set(T) ===
-----------------------------------------------------------------
+
Returns a Set containing all of the elements of *self* and *set* that are not present in both.
  
= ( set : Set(T) ) : Boolean ___________________________________________________________________________
+
{| border="1" cellpadding="5" cellspacing="0"
Returns **true** if *self* contains the same objects as *set*.
+
|-
+
! style="background: #BCBCBC;" align="center"| Expression
examples:
+
! style="background: #BCBCBC;" align="center"| Result
+
|-
.. class:: exampletable
+
| OrderedSet{'b', 'a', 'b', 'c'}->symmetricDifference(Set{'a', 'c', 'd'})
+
| Set{'d', 'b'}
+---------------------------------------------------------------+----------------+
+
|}
| Expression                                                   | Result        |
+
+===============================================================+================+
+
| Set{3, 5, 4} = Set{3, 5, 4}                                  | true          |
+
+---------------------------------------------------------------+----------------+
+
| Set{3, 5, 4} = Set{3, 4, 4, 5}                               | true          |
+
+---------------------------------------------------------------+----------------+
+
| Set{3, 5, 4} = Set{2, 3, 5, 4}                               | false          |
+
+---------------------------------------------------------------+----------------+
+
  
Back to Contents_
 
  
<> ( set : Set(T) ) : Boolean ___________________________________________________________________________
+
=== union ( bag : Bag(T) ) : Bag(T) ===
Returns **true** if *self* does not contain the same objects as *set*.
+
Returns a Bag containing all elements of *self* followed by all elements of *bag*.
+
examples:
+
+
.. class:: exampletable
+
+
+---------------------------------------------------------------+----------------+
+
| Expression                                                    | Result        |
+
+===============================================================+================+
+
| Set{4, 5, 'test', 4} <> Set{4, 5, 'test'}                    | false          |
+
+---------------------------------------------------------------+----------------+
+
| Set{4, 5, 'test', 4} <> Set{5, 4, 'test', 4}                  | false          |
+
+---------------------------------------------------------------+----------------+
+
| Set{4, 5, 'test', 4} <> Set{4, 'test', 5, 2}                  | true          |
+
+---------------------------------------------------------------+----------------+
+
  
Back to Contents_
+
{| border="1" cellpadding="5" cellspacing="0"
 +
|-
 +
! style="background: #BCBCBC;" align="center"| Expression
 +
! style="background: #BCBCBC;" align="center"| Result
 +
|-
 +
| OrderedSet{'a', 'b', 'a'}->union(Bag{'b', 'c'})
 +
| Bag{'a', 'c', 'b', 'b'}
 +
|}
  
`-` ( set : Set(T) ) : Set(T)
 
___________________________________________________________________________
 
Returns a Set containing all elements of *self* minus all elements of *set*.
 
 
examples:
 
 
.. class:: exampletable
 
 
+-----------------------------------------------------+-----------------------------------+
 
| Expression                                          | Result                            |
 
+=====================================================+===================================+
 
| Set{'a', 'b', 'c'} - Set{'c', 'a'}                  | Set{'b'}                          |
 
+-----------------------------------------------------+-----------------------------------+
 
  
Back to Contents_
+
=== union ( set : Set(T) ) : Set(T) ===
 +
Returns a Set containing all elements of *self* followed by all elements of *set*.
  
intersection ( bag : Bag(T) ) : Set(T)
+
{| border="1" cellpadding="5" cellspacing="0"
___________________________________________________________________________
+
|-
Returns a Bag containing all elements of *self* that are also contained in *bag*.
+
! style="background: #BCBCBC;" align="center"| Expression
+
! style="background: #BCBCBC;" align="center"| Result
examples:
+
|-
+
| OrderedSet{'a', 'b', 'a'}->union(Set{'b', 'c'})
.. class:: exampletable
+
| Set{'a', 'c', 'b'}
+
|}
+-------------------------------------------------------+-----------------------------------+
+
| Expression                                           | Result                            |
+
+=======================================================+===================================+
+
| Set{'a', 'b', 'a'}->intersection(Bag{'a', 'b', 'c'}) | Set{'a', 'b'}                     |
+
+-------------------------------------------------------+-----------------------------------+
+
  
Back to Contents_
 
  
intersection ( set : Set(T) ) : Set(T)
+
== Ocl operations for type *Set* ==
___________________________________________________________________________
+
Returns a Set containing all elements of *self* that are also contained in *set*.
+
+
examples:
+
+
.. class:: exampletable
+
+
+-------------------------------------------------------+-----------------------------------+
+
| Expression                                            | Result                            |
+
+=======================================================+===================================+
+
| Set{'a', 'b', 'a'}->intersection(Set{'a', 'b', 'c'})  | Set{'b', 'a'}                    |
+
+-------------------------------------------------------+-----------------------------------+
+
  
Back to Contents_
+
=== = ( set : Set(T) ) : Boolean ===
 +
Returns **true** if *self* contains the same objects as *set*.
  
symmetricDifference ( set : Set(T) ) : Set(T)
+
{| border="1" cellpadding="5" cellspacing="0"
___________________________________________________________________________
+
|-
Returns a Set containing all of the elements of *self* and *set* that are not present in both.
+
! style="background: #BCBCBC;" align="center"| Expression
+
! style="background: #BCBCBC;" align="center"| Result
examples:
+
|-
+
| Set{3, 5, 4} = Set{3, 5, 4}
.. class:: exampletable
+
| true
+
|-
+------------------------------------------------------------------+-------------------------+
+
| Set{3, 5, 4} = Set{3, 4, 4, 5}
| Expression                                                      | Result                  |
+
| true
+==================================================================+=========================+
+
|-
| Set{'b', 'a', 'b', 'c'}->symmetricDifference(Set{'a', 'c', 'd'}) | Set{'b', 'd'}           |
+
| Set{3, 5, 4} = Set{2, 3, 5, 4}
+------------------------------------------------------------------+-------------------------+
+
| false
 +
|}
  
Back to Contents_
 
  
union ( bag : Bag(T) ) : Bag(T)
+
=== <> ( set : Set(T) ) : Boolean ===
___________________________________________________________________________
+
Returns **true** if *self* does not contain the same objects as *set*.
Returns a Bag containing all elements of *self* and all elements of *bag*.
+
+
examples:
+
+
.. class:: exampletable
+
+
+-----------------------------------------------------+-----------------------------------+
+
| Expression                                          | Result                            |
+
+=====================================================+===================================+
+
| Set{'a', 'b', 'a'}->union(Bag{'b', 'c'})            | Bag{'a', 'c', 'b', 'b'}          |
+
+-----------------------------------------------------+-----------------------------------+
+
  
Back to Contents_
+
{| border="1" cellpadding="5" cellspacing="0"
 +
|-
 +
! style="background: #BCBCBC;" align="center"| Expression
 +
! style="background: #BCBCBC;" align="center"| Result
 +
|-
 +
| Set{4, 5, 'test', 4} <> Set{4, 5, 'test'}
 +
| false
 +
|-
 +
| Set{4, 5, 'test', 4} <> Set{5, 4, 'test', 4}
 +
| false
 +
|-
 +
| Set{4, 5, 'test', 4} <> Set{4, 'test', 5, 2}
 +
| true
 +
|}
  
union ( set : Set(T) ) : Set(T)
 
___________________________________________________________________________
 
Returns a Set containing all elements of *self* and all elements of *set*.
 
 
examples:
 
 
.. class:: exampletable
 
 
+-----------------------------------------------------+-----------------------------------+
 
| Expression                                          | Result                            |
 
+=====================================================+===================================+
 
| Set{'a', 'b', 'a'}->union(Set{'b', 'c'})            | Set{'a', 'c', 'b'}                |
 
+-----------------------------------------------------+-----------------------------------+
 
  
Back to Contents_
+
=== `-` ( set : Set(T) ) : Set(T) ===
 +
Returns a Set containing all elements of *self* minus all elements of *set*.
  
Ocl operations for type *Boolean*
+
{| border="1" cellpadding="5" cellspacing="0"
=================================
+
|-
 +
! style="background: #BCBCBC;" align="center"| Expression
 +
! style="background: #BCBCBC;" align="center"| Result
 +
|-
 +
| Set{'a', 'b', 'c'} - Set{'c', 'a'}
 +
| Set{'b'}
 +
|}
  
And
 
-----------------------------------------------------------------
 
  
.. list-table::
+
=== intersection ( bag : Bag(T) ) : Set(T) ===
:class: truthtable
+
Returns a Bag containing all elements of *self* that are also contained in *bag*.
:header-rows: 1
+
:stub-columns: 1
+
         
+
* - And
+
  - true
+
  - false
+
  - |invalid|
+
* - true
+
  - true
+
  - false
+
  - true
+
* - false
+
  - false
+
  - false
+
  - false
+
* - |invalid|
+
  - |invalid|
+
  - false
+
  - |invalid|
+
  
Back to Contents_
+
{| border="1" cellpadding="5" cellspacing="0"
 +
|-
 +
! style="background: #BCBCBC;" align="center"| Expression
 +
! style="background: #BCBCBC;" align="center"| Result
 +
|-
 +
| Set{'a', 'b', 'a'}->intersection(Bag{'a', 'b', 'c'})
 +
| Set{'a', 'b'}
 +
|}
  
Implies
 
-----------------------------------------------------------------
 
  
.. list-table::
+
=== intersection ( set : Set(T) ) : Set(T) ===
:class: truthtable
+
Returns a Set containing all elements of *self* that are also contained in *set*.
:header-rows: 1
+
:stub-columns: 1
+
         
+
* - Implies
+
  - true
+
  - false
+
  - |invalid|
+
* - true
+
  - true
+
  - false
+
  - |invalid|
+
* - false
+
  - true
+
  - true
+
  - true
+
* - |invalid|
+
  - true
+
  - |invalid|
+
  - |invalid|
+
  
Back to Contents_
+
{| border="1" cellpadding="5" cellspacing="0"
 +
|-
 +
! style="background: #BCBCBC;" align="center"| Expression
 +
! style="background: #BCBCBC;" align="center"| Result
 +
|-
 +
| Set{'a', 'b', 'a'}->intersection(Set{'a', 'b', 'c'})
 +
| Set{'b', 'a'}
 +
|}
  
Or
 
-----------------------------------------------------------------
 
 
.. list-table::
 
:class: truthtable
 
:header-rows: 1
 
:stub-columns: 1
 
 
* - Or
 
  - true
 
  - false
 
  - |invalid|
 
* - true
 
  - true
 
  - true
 
  - true
 
* - false
 
  - true
 
  - false
 
  - |invalid|
 
* - |invalid|
 
  - true
 
  - |invalid|
 
  - |invalid|
 
  
Back to Contents_
+
=== symmetricDifference ( set : Set(T) ) : Set(T) ===
 +
Returns a Set containing all of the elements of *self* and *set* that are not present in both.
  
Not
+
{| border="1" cellpadding="5" cellspacing="0"
-----------------------------------------------------------------
+
|-
 +
! style="background: #BCBCBC;" align="center"| Expression
 +
! style="background: #BCBCBC;" align="center"| Result
 +
|-
 +
| Set{'b', 'a', 'b', 'c'}->symmetricDifference(Set{'a', 'c', 'd'})
 +
| Set{'b', 'd'}
 +
|}
  
.. list-table::
 
:class: truthtable
 
:header-rows: 1
 
:stub-columns: 1
 
  
* - Not
+
=== union ( bag : Bag(T) ) : Bag(T) ===
  - Result
+
Returns a Bag containing all elements of *self* and all elements of *bag*.
* - true
+
  - false
+
* - false
+
  - true
+
* - |invalid|
+
  - |invalid|
+
  
Back to Contents_
+
{| border="1" cellpadding="5" cellspacing="0"
 +
|-
 +
! style="background: #BCBCBC;" align="center"| Expression
 +
! style="background: #BCBCBC;" align="center"| Result
 +
|-
 +
| Set{'a', 'b', 'a'}->union(Bag{'b', 'c'})
 +
| Bag{'a', 'c', 'b', 'b'}
 +
|}
  
Xor
 
-----------------------------------------------------------------
 
  
.. list-table::
+
=== union ( set : Set(T) ) : Set(T) ===
:class: truthtable
+
Returns a Set containing all elements of *self* and all elements of *set*.
:header-rows: 1
+
 
:stub-columns: 1
+
{| border="1" cellpadding="5" cellspacing="0"
         
+
|-
* - Xor
+
! style="background: #BCBCBC;" align="center"| Expression
  - true
+
! style="background: #BCBCBC;" align="center"| Result
  - false
+
|-
  - |invalid|
+
| Set{'a', 'b', 'a'}->union(Set{'b', 'c'})
* - true
+
| Set{'a', 'c', 'b'}
  - false
+
|}
  - true
+
 
  - |invalid|
+
 
* - false
+
== Ocl operations for type *Boolean* ==
  - true
+
 
  - false
+
=== And ===
  - |invalid|
+
 
* - |invalid|
+
{| border="1" cellpadding="5" cellspacing="0"
  - |invalid|
+
|-
  - |invalid|
+
! style="background: #BCBCBC;" align="center"| And
  - |invalid|
+
! style="background: #BCBCBC;" align="center"| True
 +
! style="background: #BCBCBC;" align="center"| False
 +
! style="background: #BCBCBC;" align="center"| Invalid
 +
|-
 +
! style="background: #BCBCBC;" align="center"| True
 +
| true
 +
| false
 +
| true
 +
|-
 +
! style="background: #BCBCBC;" align="center"| False
 +
| false
 +
| false
 +
| false
 +
|-
 +
! style="background: #BCBCBC;" align="center"| Invalid
 +
| invalid
 +
| false
 +
| invalid
 +
|}
 +
 
 +
=== Implies ===
 +
 
 +
{| border="1" cellpadding="5" cellspacing="0"
 +
|-
 +
! style="background: #BCBCBC;" align="center"| Implies
 +
! style="background: #BCBCBC;" align="center"| True
 +
! style="background: #BCBCBC;" align="center"| False
 +
! style="background: #BCBCBC;" align="center"| Invalid
 +
|-
 +
! style="background: #BCBCBC;" align="center"| True
 +
| true
 +
| false
 +
| invalid
 +
|-
 +
! style="background: #BCBCBC;" align="center"| False
 +
| true
 +
| true
 +
| true
 +
|-
 +
! style="background: #BCBCBC;" align="center"| Invalid
 +
| true
 +
| invalid
 +
| invalid
 +
|}
 +
 
 +
 
 +
=== Or ===
 +
 
 +
{| border="1" cellpadding="5" cellspacing="0"
 +
|-
 +
! style="background: #BCBCBC;" align="center"| Or
 +
! style="background: #BCBCBC;" align="center"| True
 +
! style="background: #BCBCBC;" align="center"| False
 +
! style="background: #BCBCBC;" align="center"| Invalid
 +
|-
 +
! style="background: #BCBCBC;" align="center"| True
 +
| true
 +
| true
 +
| true
 +
|-
 +
! style="background: #BCBCBC;" align="center"| False
 +
| true
 +
| false
 +
| invalid
 +
|-
 +
! style="background: #BCBCBC;" align="center"| Invalid
 +
| true
 +
| invalid
 +
| invalid
 +
|}
 +
 
 +
 
 +
=== Not ===
 +
{| border="1" cellpadding="5" cellspacing="0"
 +
|-
 +
! style="background: #BCBCBC;" align="center"| Not
 +
! style="background: #BCBCBC;" align="center"| Result
 +
|-
 +
! style="background: #BCBCBC;" align="center"| True
 +
| false
 +
|-
 +
! style="background: #BCBCBC;" align="center"| False
 +
| true
 +
|-
 +
! style="background: #BCBCBC;" align="center"| Invalid
 +
| invalid
 +
|}
 +
 
 +
 
 +
=== Xor ===
 +
 
 +
{| border="1" cellpadding="5" cellspacing="0"
 +
|-
 +
! style="background: #BCBCBC;" align="center"| Xor
 +
! style="background: #BCBCBC;" align="center"| True
 +
! style="background: #BCBCBC;" align="center"| False
 +
! style="background: #BCBCBC;" align="center"| Invalid
 +
|-
 +
! style="background: #BCBCBC;" align="center"| True
 +
| false
 +
| true
 +
| invalid
 +
|-
 +
! style="background: #BCBCBC;" align="center"| False
 +
| true
 +
| false
 +
| invalid
 +
|-
 +
! style="background: #BCBCBC;" align="center"| Invalid
 +
| invalid
 +
| invalid
 +
| invalid
 +
|}
  
  
 
{{Acceleo-index}}
 
{{Acceleo-index}}
 +
 +
[[Category:Modeling]]
 +
[[Category:M2T]]
 +
[[Category:Acceleo]]

Latest revision as of 01:40, 20 January 2011

Contents

[edit] OCL operation reference

[edit] Ocl operations for type *Classifier*

[edit] allInstances () : Set{T}

Returns a Set containing all of the existing instances of the current classifier (along with instances of all its inherited classifiers).

Expression Result
let a : String = 'a', b : String = 'b', c : Integer = 2 in String.allInstances() Set{'a','b'}


[edit] Ocl operations for type *OclAny*

[edit] oclAsType ( typespec : Classifier ) : T

Returns *self* statically typed as typespec if it is an instance of this type. *Note* that this does not alter the runtime value of *self*, it only enables access to subtype operations. This operation allows users to cast self to another type.

Expression Result
aPerson.oclAsType(Employee) an object of Employee type


[edit] oclIsInvalid () : Boolean

Returns true if self is equal to *invalid*.

Expression Result
let anObject : String = null in anObject.oclIsUndefined() false
let anObject : String = invalid in anObject.oclIsUndefined() true
let anObject : String = 'null' in anObject.oclIsUndefined() false


[edit] oclIsKindOf( Classifier typespec ) : Boolean

Returns **true** if the type of self corresponds to the type or supertype of typespec, false otherwise. This operation allows users to check the class hierarchy of self much like would an instanceof Java.

Expression Result
anEmployee.oclIsKindOf(Employee) true
anEmployee.oclIsKindOf(Person) true
aCat.oclIsKindOf(Person) false


[edit] oclIsTypeOf( typespec : Classifier ) : Boolean

Returns true if the type of self is the same as typespec, or **false** otherwise. This operation allows users to check the exact class type of self.

Expression Result
anEmployee.oclIsTypeOf(Employee) true
anEmployee.oclIsTypeOf(Person) false
aCat.oclIsTypeOf(Person) false


[edit] oclIsUndefined () : Boolean

Returns **true** if *self* is equal to *invalid* or *null*.

Expression Result
let anObject : String = null in anObject.oclIsUndefined() true
let anObject : String = invalid in anObject.oclIsUndefined() true
let anObject : String = 'null' in anObject.oclIsUndefined() false


[edit] <> ( object : OclAny ) : Boolean

Returns **true** if *self* is a different object from *object*.

Expression Result
let a : String = 'a', b : String = 'a' in a <> b false
let a : Integer = 2, b : Real = 2.0 in a <> b false
let a : Integer = -2, b : Integer = 2 in a <> b true


[edit] = ( object : OclAny) : Boolean

Returns **true** if *self* is equal to *object*.

Expression Result
let a : String = 'a', b : String = 'a' in a = b true
let a : Integer = 2, b : Real = 2.0 in a = b true
let a : Integer = -2, b : Integer = 2 in a = b false


[edit] < ( object : T ) : Boolean

Returns **true** if *self* is comparable to *object* and less than *object*.

Expression Result
let a : Integer = 1, b : Integer = 2 in a < b true
let a : Real = 1.5, b : Integer = 2 in a < b true
let a : String = 'Anteater', b : String = 'Aardvark' in a < b false


[edit] > ( object : T ) : Boolean

Returns **true** if *self* is comparable to *object* and greater than *object*.

Expression Result
let a : Integer = 1, b : Integer = 2 in a > b false
let a : Real = 1.5, b : Integer = 2 in a > b false
let a : String = 'Anteater', b : String = 'Aardvark' in a > b true


[edit] <= ( object : T ) : Boolean

Returns **true** if *self* is comparable to *object* and less than or equal to *object*.

Expression Result
let a : Integer = 1, b : Integer = 2 in a <= b true
let a : Real = 1.5, b : Integer = 2 in a <= b true
let a : String = 'Anteater', b : String = 'Aardvark' in a <= b false


[edit] >= ( object : T ) : Boolean

Returns **true** if *self* is comparable to *object* and greater than or equal to *object*.

Expression Result
let a : Integer = 1, b : Integer = 2 in a >= b false
let a : Real = 1.5, b : Integer = 2 in a >= b false
let a : String = 'Anteater', b : String = 'Aardvark' in a >= b true


[edit] Ocl operations for type *String*

    • A note on Strings** : OCL Strings begin at index *1*, not *0* as in most languages. Thus *'test'.at(0)* fails in
  • invalid* whereas *'test'.at(1)* yields *'t'*. Likewise, *'test'.substring(2, 2)* returns *'e'*.

[edit] concat ( s : String ) : String

Returns a string containing *self* followed by *s*.

Expression Result
'concat'.concat(' ').concat('operation') 'concat operation'


[edit] size () : Integer

Returns the number of characters composing *self*.

Expression Result
'size operation'.size() 14


[edit] substring ( lower : Integer, upper : Integer ) : String

Returns a string containing all characters from *self* starting from index *lower* up to index *upper* included. Both *lower* and *upper* parameters should be contained between *1* and *self.size()* included. *lower* cannot be greater than *upper*.

Expression Result
'substring operation'.substring(11, 19) 'operation'
'substring operation'.substring(1, 1) 's'
'substring operation'.substring(0, 1) invalid


[edit] toInteger () : Integer

Returns an Integer of value equal to *self*, or |invalid| if *self* does not represent an integer.

Expression Result
'3.0'.toInteger() invalid
'4'.toInteger() 4
'toInteger'.toInteger() invalid


[edit] toLower () : String

Returns *self* with all characters converted to lowercase.

Expression Result
'LoWeR OpErAtIoN'.toLower() 'lower operation'


[edit] toReal () : Real

Returns a Real of value equal to *self*, or |invalid| if *self* does not represent a real.

Expression Result
'3.0'.toReal() 3.0
'4'.toReal() 4.0
'toReal'.toReal() invalid


[edit] toUpper () : String

Returns *self* with all characters converted to uppercase.

Expression Result
'UpPeR OpErAtIoN'.toUpper() 'UPPER OPERATION'


[edit] Ocl operations for type *Number*

In addition to the basic math functions (+, -, /, \*) are a number of advanced functions. Take note that *Number* denotes both *Integer* and *Real*, and they're substitutive unless otherwise specified.

[edit] Number::abs () : Number

Returns the absolute value of *self*, *self* if it is already a positive number.

Expression Result
(-2.3).abs() 2.3
-5.abs() 5


[edit] Number::floor () : Integer

Returns the integer part of *self* if it is a Real, *self* if it is an Integer.

Expression Result
(2.3).floor() 2
(2.8).floor() 2
2.floor() 2


[edit] Number::max ( r : Number ) : Number

Returns the greatest number between *self* and *r*.

Expression Result
6.max(3) 6
6.max(5.2) 6.0
(2.3).max(3) 3.0
(2.3).max(5.2) 5.2


[edit] Number::min ( r : Number ) : Number

Returns the lowest number between *self* and *r*.

Expression Result
6.min(3) 3
6.min(5.2) 5.2
(2.3).min(3) 2.3
(2.3).min(5.2) 2.3


[edit] Number::round () : Integer

Returns the nearest integer to *self* if it is a Real, *self* if it is an Integer.

Expression Result
(2.3).round() 2
(2.5).round() 3
(2.8).round() 3
2.round() 2


[edit] Integer::div ( i : Integer ) : Integer

Returns the integer quotient of the division of *self* by *i*.

Expression Result
3.div(2) 1
11.div(3) 3


[edit] Integer::mod ( i : Integer ) : Integer

Returns the integer remainder of the division of *self* by *i*.

Expression Result
3.mod(2) 1
11.mod(3) 2


[edit] Ocl operations for type *Collection*

Please note that OCL collections can contain the *null* value (null) but not the *invalid* value (|invalid|). Trying to add |invalid| within a new or existing collection will yield |invalid| as a result. OCL proposes four distinct kinds of collections offering all possibilities of ordering/unicity.


Collection type Ordered Unique
Sequence true false
OrderedSet true true
Bag false false
Set false true


[edit] any ( expr : OclExpression ) : T

Returns any element contained in *self* that validates the condition *expr*, null otherwise. Evaluation is shortcut as soon as an element validating *expr* is found. Note that the result of this on unordered collections will be random if more than one element validates *expr*.

Expression Result
Sequence{1.2, 2.3, 5.2, 0.9}->any(self < 1) 0.9
Sequence{1.2, 2.3, 5.2, 0.9}->any(self < 2) 1.2


[edit] asBag () : Bag(T)

Returns a Bag containing all elements of *self*.

Expression Result
Sequence{'3', 1, 2.0, '3'}->asBag() Bag{2.0, '3', 1, '3'}
Bag{1, 2.0, '3'}->asBag() Bag{2.0, 1, '3'}
OrderedSet{1, 2.0, '3'}->asBag() Bag{2.0, 1, '3'}
OrderedSet{1, 1, 2.0, '3'}->asBag() Bag{'3', 1, 2.0}
Set{1, 2.0, '3'}->asBag() Bag{2.0, 1, '3'}
Set{1, 1, 2.0, '3'}->asBag() Bag{2.0, '3', 1}


[edit] asOrderedSet () : OrderedSet(T)

Returns an OrderedSet containing all elements of *self*. Element ordering is preserved when possible.

Expression Result
Sequence{1, 2.0, '3'}->asOrderedSet() OrderedSet{1, '3', 2.0}
Sequence{1, 1, 2.0, '3'}->asOrderedSet() OrderedSet{'3', 1, 2.0}
Bag{1, 2.0, '3'}->asOrderedSet() OrderedSet{2.0, 1, '3'}
Bag{1, 1, 2.0, '3'}->asOrderedSet() OrderedSet{1, '3', 2.0}
OrderedSet{1, 2.0, '3'}->asOrderedSet() OrderedSet{1, 2.0, '3'}
Set{1, 2.0, '3'}->asOrderedSet() OrderedSet{'3', 1, 2.0}


[edit] asSequence () : Boolean

Returns a Sequence containing all elements of *self*. Element ordering is preserved when possible.

Expression Result
Sequence{1, 2.0, '3'}->asSequence() Sequence{1, 2.0, '3'}
Bag{1, 2.0, '3'}->asSequence() Sequence{2.0, 1, '3'}
OrderedSet{1, 2.0, '3'}->asSequence() Sequence{1, 2.0, '3'}
Set{1, 2.0, '3'}->asSequence() Sequence{'3', 1, 2.0}


[edit] asSet () : Set(T)

Returns a Set containing all elements of *self*.

Expression Result
Sequence{1, 2.0, '3'}->asSet() Set{1, '3', 2.0}
Sequence{1, 1, 2.0, '3'}->asSet() Set{'3', 1, 2.0}
Bag{1, 2.0, '3'}->asSet() Set{2.0, 1, '3'}
Bag{1, 1, 2.0, '3'}->asSet() Set{1, '3', 2.0}
OrderedSet{1, 2.0, '3'}->asSet() Set{1, '3', 2.0}
OrderedSet{1, 1, 2.0, '3'}->asSet() Set{'3', 1, 2.0}
Set{1, 2.0, '3'}->asSet() Set{2.0, 1, '3'}
Set{1, 1, 2.0, '3'}->asSet() Set{'3', 1, 2.0}


[edit] collect ( expr : OclExpression ) : Collection(T2)

Returns a collection containing the result of applying *expr* on all elements contained in *self*.

Expression Result
Sequence{'first', 'second'}->collect(toUpper()) Sequence{'FIRST', 'SECOND'}


[edit] collectNested ( expr : OclExpression ) : Collection(T2)

Returns a collection containing all the elements contained in *self* on which we applied the OclExpression *expr*. The results won't be flattened. The type of the resulting collection depends on the type of *self*.

For the purpose of these examples we'll assume here that we have a Class *Person* with a reference *children*. Our model contains two persons such as *person1.children = {James, Jane}* and *person2.children = {John}*.

Expression Result
self.persons->collectNested(children.firstname) Sequence{Sequence{James, Jane}, Sequence{John}}


[edit] count ( object : T ) : Integer

Returns how many times *object* is in the collection *self*.

Expression Result
Sequence{2.3, 5.2}->count(5.2) 1
Set{3, 'test', 4.0, 4, 4.0, 'test'}->count(null) 0
Set{3, null, 4.0, null, 'test'}->count(null) 1
Bag{3, null, 4.0, null, 'test'}->count(null) 2


[edit] excludes ( object : T ) : Boolean

Returns **true** if *object* is not contained in *self*, **false** otherwise.

Expression Result
Sequence{2.3}->excludes(2.1) true
Sequence{2.0}->excludes(2) false


[edit] excludesAll ( c2 : Collection(T) ) : Boolean

Returns **true** if no element of *c2* is contained in *self*, **false** otherwise.

Expression Result
Sequence{2.3, 5.2, 'a', 3, null}->excludesAll(Set{4, null}) false
Sequence{2.3, 5.2, 'a', 3}->excludesAll(Set{4, null}) true


[edit] excluding ( object : T ) : Collection(T)

Returns a collection containing all elements of *self* minus all occurences of *object*. **Note** : at the time of writing, the OCL standard library sports a bug which changes *OrderedSets* in *Sets* when excluding elements.

Expression Result
Sequence{'b', 'a', 'b', 'c'}->excluding('b') Sequence{'a', 'c'}
Bag{'b', 'a', 'b', 'c'}->excluding('b') Bag{'c', 'a'}
OrderedSet{'b', 'a', 'b', 'c'}->excluding('b') Set{'c', 'a'}
Set{'b', 'a', 'b', 'c'}->excluding('b') Set{'c', 'a'}


[edit] exists ( expr : OclExpression ) : Boolean

Returns **true** if at least one element in *self* validates the condition *expr*, **false** otherwise. The evaluation stops as soon as one element validating *expr* is found.

Expression Result
Sequence{2.3, 5.2}->exists(self > 3) true


[edit] flatten () : Collection(T2)

Returns a collection containing all elements of *self* recursively flattened. **Note** : at the time of writing, the OCL standard library sports a bug which changes *OrderedSets* in *Sets* when flattening.

Expression Result
Sequence{Set{1, 2, 3}, Sequence{2.0, 3.0}, Bag{'test'}}->flatten() Sequence{1, 2, 3, 2.0, 3.0, 'test'}
Bag{Set{Bag{'test', 2, 3.0}}, Sequence{OrderedSet{2.0, 3, 1}}}->flatten() Bag{1, 2, 3, 2.0, 3.0, 'test'}
OrderedSet{Set{Bag{'test', 2, 3.0}}, Sequence{Set{2.0, 3, 1}}}->flatten() Set{3.0, 2, 1, 3, 'test', 2.0}
Set{Set{Bag{'test', 2, 3.0}}, Sequence{OrderedSet{2.0, 3, 1}}}->flatten() Set{3.0, 2, 1, 3, 'test', 2.0}


[edit] forAll ( expr : OclExpression ) : Boolean

Returns **true** if the all the elements contained in *self* validate the condition *expr*, **false** otherwise.

Expression Result
Sequence{2.3, 5.2}->forAll(self > 3) false
Sequence{2.3, 5.2}->forAll(self > 1.2) true


[edit] includes ( object : T ) : Boolean

Returns **true** if *object* is contained in *self*, **false** otherwise.

Expression Result
Sequence{2.3}->includes(2.1) false
Sequence{2.0}->includes(2) true


[edit] includesAll ( c2 : Collection(T) ) : Boolean

Returns **true** if all element of *c2* are contained in *self*, **false** otherwise.

Expression Result
Sequence{2.3, 5.2, 'a', 3, null}->includesAll(Set{3, null}) true
Sequence{2.3, 5.2, 'a', 3}->includesAll(Set{3, null}) false


[edit] including ( object : T ) : Collection(T)

Returns a collection containing all elements of *self* followed by *object*. **Note** : at the time of writing, the OCL standard library sports a bug which changes *OrderedSets* in *Sets* when including elements.

Expression Result
Sequence{'a', 'b'}->including('c') Sequence{'a', 'b', 'c'}
Bag{'a', 'b'}->including('c') Bag{'a', 'c', 'b'}
OrderedSet{'a', 'b'}->including('c') Set{'a', 'c', 'b'}
Set{'a', 'b'}->including('c') Set{'a', 'c', 'b'}


[edit] isEmpty () : Boolean

Returns **true** if *self* is empty, **false** otherwise.

Expression Result
Sequence{2, 'a'}->isEmpty() false
Sequence{null}->isEmpty() false
Sequence{}->isEmpty() true


[edit] isUnique ( expr : OclExpression ) : Boolean

Returns **true** if all elements contained in *self* evaluate to a distinct value for *expr*.

Expression Result
Sequence{2.3, 5.2}->isUnique(self > 3) true
Sequence{2.3, 5.2}->isUnique(self > 1) false


[edit] notEmpty () : Boolean

Returns **true** if *self* contains at least one element, **false** otherwise.

Expression Result
Sequence{2, 'a'}->notEmpty() true
Sequence{null}->notEmpty() true
Sequence{}->notEmpty() false


[edit] one ( expr : OclExpression ) : Boolean

Returns **true** if there is only one element contained in *self* that validates the condition *expr*, **false** otherwise.

Expression Result
Sequence{1.2, 2.3, 5.2, 0.9}->one(self < 1) true
Sequence{1.2, 2.3, 5.2, 0.9}->one(self < 2) false


[edit] product ( c2 : Collection(T2) ) : Set(Tuple(first : T, second : T2))

Returns a Set of Tuples which represents the cartesian product of *self* with *c2*.

Expression Result
Sequence{3, 4}->product(Bag{3.0, 4.0}) Set{Tuple{3, 3.0}, Tuple{3, 4.0}, Tuple{4, 3.0}, Tuple{4, 4.0}}
Set{3, 4}->product(OrderedSet{3.0, 4.0}) Set{Tuple{3, 3.0}, Tuple{3, 4.0}, Tuple{4, 3.0}, Tuple{4, 4.0}}


[edit] reject ( expr : OclExpression ) : Collection(T)

Returns a collection with all elements of *self* except for those who validate the OclExpression *expr*.

Expression Result
i > 1 ) Sequence{1}
i > 1 ) Bag{1}
i > 1 ) OrderedSet{1}
i > 1 ) Set{1}


[edit] select ( expr : OclExpression ) : Collection(T)

Returns a collection with all elements of *self* that validate the OclExpression *expr*.

Expression Result
i > 1) Sequence{2, 3}
i > 1 ) Bag{3, 2}
i > 1 ) OrderedSet{2, 3}
i > 1 ) Set{3, 2}


[edit] size () : Integer

Returns the number of elements contained in *self*.

Expression Result
Sequence{2.3, 5}->size() 2
Sequence{}->size() 0


[edit] sortedBy ( expr : OclExpression ) : Sequence(T)

Returns a sorted collection containing all elements from *self* sorted in accordance with the OclExpression *expr*. This can be used on all kind of collections yet will always yield a Sequence-typed result except for OrderedSet which returns an OrderedSet.

For the purpose of these examples we'll assume here that we have a Class *Employee* with an attribute *age*. Our model contains two employees such as *employee1.age = 24* and *employee2.age = 27*.

Expression Result
self.employees->sortedBy(age) Sequence{employee1, employee2}


[edit] sum () : Real

Returns the sum of all elements contained in *self* if they support the '+' operation.

Expression Result
Sequence{2.3, 5.2} in c->sum() 7.5
Sequence{2, 4} in c->sum() 6
Sequence{2, '4'} in c->sum() invalid


[edit] Ocl operations for type *Sequence*

[edit] = ( seq : Sequence(T) ) : Boolean

Returns **true** if *self* contains the very same objects as *seq* in the very same order as they are in *seq*.

Expression Result
Sequence{4, 5, 'test'} = Sequence{4, 5, 'test'} true
Sequence{4, 5, 'test'} = Sequence{4, 'test', 5} false
Sequence{4, 5, 'test', 5} = Sequence{4, 5, 'test'} false


[edit] <> ( seq : Sequence(T) ) : Boolean

Returns **true** if *self* does not contain the same objects as *seq*, or if these objects are not in the same order as they are in *seq*.

Expression Result
Sequence{4, 5, 'test'} = Sequence{4, 5, 'test'} false
Sequence{4, 5, 'test'} = Sequence{4, 'test', 5} true
Sequence{4, 5, 'test', 5} = Sequence{4, 5, 'test'} true


[edit] append ( object : T ) : Sequence(T)

Returns a Sequence containing all elements of *self* followed by *object*.

Expression Result
Sequence{'a', 'b'}->append('c') Sequence{'a', 'b', 'c'}


[edit] at ( index : Integer ) : T

Returns the element of *self* at the *index* position.

Expression Result
Sequence{'a', 'b'}->at(1) a


[edit] first () : T

Returns the first element of *self*.

Expression Result
Sequence{1, 2.0, '3'}->first() 1


[edit] indexOf ( object : T ) : Integer

Returns the position of *object* in sequence *self*.

Expression Result
Sequence{'a', 'b'}->indexOf('a') 1


[edit] insertAt ( index : Integer, object : T) : Sequence(T)

Returns a Sequence containing *self* with *object* inserted at the *index* position.

Expression Result
Sequence{'a', 'b'}->insertAt(0, 'c') invalid
Sequence{'a', 'b'}->insertAt(1, 'c') Sequence{'c', 'a', 'b'}
Sequence{'a', 'b'}->insertAt(3, 'c') Sequence{'a', 'b', 'c'}
Sequence{'a', 'b'}->insertAt(4, 'c') invalid


[edit] last () : T

Returns the last element of *self*.

Expression Result
Sequence{1, 2.0, '3'}->last() '3'


[edit] prepend ( object : T ) : Sequence(T)

Returns a Sequence containing *object* followed by all elements of *self* .

Expression Result
Sequence{'a', 'b'}->prepend('c') Sequence{'c', 'a', 'b'}


[edit] subSequence ( startIndex : Integer, endIndex : Integer ) : Sequence(T)

Returns a Sequence containing all elements of *self* between the positions 'startIndex' and 'endIndex'.

Expression Result
Sequence{'a', 'b', 'c', 'd'}->subSequence(2, 3) Sequence{'b', 'c'}
Sequence{'a', 'b', 'c', 'd'}->subSequence(4, 4) Sequence{'d'}


[edit] union ( seq : Sequence(T) ) : Sequence(T)

Returns a Sequence containing all elements of *self* followed by all elements of *seq*.

Expression Result
Sequence{'a', 'b', 'a'}->union(Sequence{'b', 'c'}) Sequence{'a', 'b', 'a', 'b', 'c'}


[edit] Ocl operations for type *Bag*

[edit] = ( bag : Bag(T) ) : Boolean

Returns **true** if *self* contains the same objects as *bag* in the same quantities.

Expression Result
Bag{4, 5, 'test', 4} = Bag{4, 'test', 5, 4} true
Bag{4, 5, 'test'} = Bag{4, 'test', 5} true
Bag{4, 5, 'test', 5} = Bag{4, 5, 'test'} false


[edit] <> ( bag : Bag(T) ) : Boolean

Returns **true** if *self* does not contain the same objects as *bag* in the same quantities.

Expression Result
Bag{4, 5, 'test'} = Bag{4, 5, 'test'} false
Bag{4, 5, 'test'} = Bag{4, 'test', 5} false
Bag{4, 5, 'test', 5} = Bag{4, 5, 'test'} true


[edit] intersection ( bag : Bag(T) ) : Bag(T)

Returns a Bag containing all elements of *self* that are also contained by *bag*.

Expression Result
Bag{'a', 'b', 'a'}->intersection(Bag{'a', 'b'}) Bag{'a', 'b'}
Bag{'a', 'b', 'a', 'b'}->intersection(Bag{'a', 'b', 'b'}) Bag{'b', 'a', 'b'}


[edit] intersection ( set : Set(T) ) : Set(T)

Returns a Set containing all elements of *self* that are also contained by *set*.

Expression Result
Bag{'a', 'b', 'a'}->intersection(Set{'a', 'b', 'c'}) Set{'a', 'b'}


[edit] union ( bag : Bag(T) ) : Bag(T)

Returns a Bag containing all elements of *self* and all elements of *bag*.

Expression Result
Bag{'a', 'b', 'a'}->union(Bag{'b', 'c'}) Bag{'b', 'a', 'b', 'a', 'c'}


[edit] union ( set : Set(T) ) : Bag(T)

Returns a Bag containing all elements of *self* and all elements of *set*.

Expression Result
Bag{'a', 'b', 'a'}->union(Set{'b', 'c'}) Bag{'b', 'c', 'a', 'b', 'a'}


[edit] Ocl operations for type *OrderedSet*

[edit] = ( set : Set(T) ) : Boolean

Returns **true** if *self* contains the same objects as *set*.

Expression Result
OrderedSet{3, 5, 4} = Set{3, 5, 4} true
OrderedSet{3, 5, 4} = Set{4, 3, 5, 4, 4} true
OrderedSet{3, 5, 4} = Set{2, 5 ,4, 4} false


[edit] = ( orderedset : OrderedSet(T) ) : Boolean

Returns **true** if *self* contains the same objects as *orderedset* regardless of element ordering.

Expression Result
OrderedSet{3, 5, 4} = OrderedSet{3, 5, 4} true
OrderedSet{4, 5, 'test', 5} = OrderedSet{4, 5, 'test'} true
OrderedSet{4, 5, 'test'} = OrderedSet{4, 'test', 5} true
OrderedSet{4, 5, 'test'} = OrderedSet{4, 'test'} false


[edit] <> ( set : Set(T) ) : Boolean

Returns **true** if *self* does not contain the same objects as *set*.

Expression Result
OrderedSet{4, 5, 'test', 4} <> Set{4, 5, 'test'} false
OrderedSet{4, 5, 'test', 4} <> Set{4, 'test', 5, 4} false
OrderedSet{4, 5, 'test', 4} <> Set{4, 5, 'test', 2} true


[edit] <> ( orderedset : OrderedSet(T) ) : Boolean

Returns **true** if *self* does not contain the same objects as *orderedset*.

Expression Result
OrderedSet{4, 5, 'test', 4} <> OrderedSet{4, 5, 'test') false
OrderedSet{4, 5, 'test', 4} <> OrderedSet{4, 'test', 5, 4} false
OrderedSet{4, 5, 'test', 4} <> OrderedSet{4, 5, 'test', 2} true


[edit] `-` ( set : Set(T) ) : Set(T)

Returns a Set containing all elements of *self* minus all elements of *set*.

Expression Result
OrderedSet{'a', 'b', 'c'} - Set{'c', 'a'} Set{'b'}


[edit] append ( object : T ) : OrderedSet(T)

Returns an OrderedSet containing all elements of *self* followed by *object*.

Expression Result
OrderedSet{'a', 'b'}->append('c') OrderedSet{'a', 'b', 'c'}


[edit] at ( index : Integer ) : T

Returns the element of *self* located at position *index* in the collection.

Expression Result
OrderedSet{'a', 'b'}->at(1) 'a'


[edit] first () : T

Returns the first element of *self*.

Expression Result
OrderedSet{1, 2.0, '3'}->first() 1


[edit] indexOf ( object : T ) : Integer

Returns the position of *object* in *self*.

Expression Result
OrderedSet{'a', 'b'}->indexOf('a') 1


[edit] insertAt ( index : Integer, object : T ) : OrderedSet(T)

Returns an OrderedSet containing *self* with *object* inserted at the *index* position.

Expression Result
OrderedSet{'a', 'b'}->insertAt(1, 'c') OrderedSet{'c', 'a', 'b'}
OrderedSet{'a', 'b'}->insertAt(3, 'c') OrderedSet{'a', 'b', 'c'}


[edit] intersection ( bag : Bag(T) ) : Set(T)

Returns a Set containing all elements of *self* that are also contained by *bag*.

Expression Result
OrderedSet{'a', 'b', 'a'}->intersection(Bag{'a', 'b'}) Set{'a', 'b'}


[edit] intersection ( set : Set(T) ) : Set(T)

Returns a Set containing all elements of *self* that are also contained by *set*.

Expression Result
OrderedSet{'a', 'b', 'a'}->intersection(Set{'a', 'b'}) Set{'a', 'b'}


[edit] last () : T

Returns the last element of *self*.

Expression Result
OrderedSet{1, 2.0, '3'}->last() '3'


[edit] prepend ( object : T ) : OrderedSet(T)

Returns an OrderedSet containing *object* followed by all elements of *self*.

Expression Result
OrderedSet{'a', 'b'}->prepend('c') OrderedSet{'c', 'a', 'b'}


[edit] subOrderedSet ( startIndex : Integer, endIndex : Integer ) : OrderedSet(T)

Returns an OrderedSet containing all elements of *self* between the positions *startIndex* and *endIndex*.

Expression Result
OrderedSet{'a', 'b', 'c', 'd'}->subOrderedSet(2, 3) OrderedSet{'b', 'c'}
OrderedSet{'a', 'b', 'c', 'd'}->subOrderedSet(4, 4) OrderedSet{'d'}


[edit] symmetricDifference ( set : Set(T) ) : Set(T)

Returns a Set containing all of the elements of *self* and *set* that are not present in both.

Expression Result
OrderedSet{'b', 'a', 'b', 'c'}->symmetricDifference(Set{'a', 'c', 'd'}) Set{'d', 'b'}


[edit] union ( bag : Bag(T) ) : Bag(T)

Returns a Bag containing all elements of *self* followed by all elements of *bag*.

Expression Result
OrderedSet{'a', 'b', 'a'}->union(Bag{'b', 'c'}) Bag{'a', 'c', 'b', 'b'}


[edit] union ( set : Set(T) ) : Set(T)

Returns a Set containing all elements of *self* followed by all elements of *set*.

Expression Result
OrderedSet{'a', 'b', 'a'}->union(Set{'b', 'c'}) Set{'a', 'c', 'b'}


[edit] Ocl operations for type *Set*

[edit] = ( set : Set(T) ) : Boolean

Returns **true** if *self* contains the same objects as *set*.

Expression Result
Set{3, 5, 4} = Set{3, 5, 4} true
Set{3, 5, 4} = Set{3, 4, 4, 5} true
Set{3, 5, 4} = Set{2, 3, 5, 4} false


[edit] <> ( set : Set(T) ) : Boolean

Returns **true** if *self* does not contain the same objects as *set*.

Expression Result
Set{4, 5, 'test', 4} <> Set{4, 5, 'test'} false
Set{4, 5, 'test', 4} <> Set{5, 4, 'test', 4} false
Set{4, 5, 'test', 4} <> Set{4, 'test', 5, 2} true


[edit] `-` ( set : Set(T) ) : Set(T)

Returns a Set containing all elements of *self* minus all elements of *set*.

Expression Result
Set{'a', 'b', 'c'} - Set{'c', 'a'} Set{'b'}


[edit] intersection ( bag : Bag(T) ) : Set(T)

Returns a Bag containing all elements of *self* that are also contained in *bag*.

Expression Result
Set{'a', 'b', 'a'}->intersection(Bag{'a', 'b', 'c'}) Set{'a', 'b'}


[edit] intersection ( set : Set(T) ) : Set(T)

Returns a Set containing all elements of *self* that are also contained in *set*.

Expression Result
Set{'a', 'b', 'a'}->intersection(Set{'a', 'b', 'c'}) Set{'b', 'a'}


[edit] symmetricDifference ( set : Set(T) ) : Set(T)

Returns a Set containing all of the elements of *self* and *set* that are not present in both.

Expression Result
Set{'b', 'a', 'b', 'c'}->symmetricDifference(Set{'a', 'c', 'd'}) Set{'b', 'd'}


[edit] union ( bag : Bag(T) ) : Bag(T)

Returns a Bag containing all elements of *self* and all elements of *bag*.

Expression Result
Set{'a', 'b', 'a'}->union(Bag{'b', 'c'}) Bag{'a', 'c', 'b', 'b'}


[edit] union ( set : Set(T) ) : Set(T)

Returns a Set containing all elements of *self* and all elements of *set*.

Expression Result
Set{'a', 'b', 'a'}->union(Set{'b', 'c'}) Set{'a', 'c', 'b'}


[edit] Ocl operations for type *Boolean*

[edit] And

And True False Invalid
True true false true
False false false false
Invalid invalid false invalid

[edit] Implies

Implies True False Invalid
True true false invalid
False true true true
Invalid true invalid invalid


[edit] Or

Or True False Invalid
True true true true
False true false invalid
Invalid true invalid invalid


[edit] Not

Not Result
True false
False true
Invalid invalid


[edit] Xor

Xor True False Invalid
True false true invalid
False true false invalid
Invalid invalid invalid invalid



Acceleo Portal
Project Project · Installation · New & noteworthy · Release review · API policy · Retention policy · Next · Checklist
Features Acceleo Features · Runtime · Acceleo editor · Views & Perspective · Debugger · Profiler · Traceability · Wishlist · Interpreter · Maven
User documentation Getting Started · Acceleo operations reference · OCL operations reference · Text Production Rules · Migration From Acceleo 2.x · Best Practices · Videos · FAQ
Developer documentation Source code · How to contribute · Compatibility · MOFM2T specification · OCL specification
Community Conferences · Twitter & Blogs · Professional Support · Report a bug