OCLOperators
No edit summary
No edit summary
Line 13: Line 13:
|All the currently loaded instances
|All the currently loaded instances
|-
|-
|[[OCLOperators allLoadedObjects|allLoadedObjects]]
|[[OCLOperators allLoadedObjects|'''allLoadedObjects''']]
|All objects currently in memory, excluding deleted objects
|All objects currently in memory, excluding deleted objects
|-
|-
Line 25: Line 25:
|Meta information on all the super-classes – in inheritance order the class has
|Meta information on all the super-classes – in inheritance order the class has
|-
|-
|[[OCLOperators ASCII|ASCII]]
|[[OCLOperators ASCII|'''ASCII''']]
|
|
|-
|-
Line 31: Line 31:
|Returns a collection of strings with association names for the class
|Returns a collection of strings with association names for the class
|-
|-
|[[OCLOperators associationEndsWithType|associationEndsWithType]]
|[[OCLOperators associationEndsWithType|'''associationEndsWithType''']]
|Returns a collection of strings with association names and type information for the class
|Returns a collection of strings with association names and type information for the class
|-
|-
Line 37: Line 37:
|The string representation of the class – the asString operation is available on everything
|The string representation of the class – the asString operation is available on everything
|-
|-
|[[OCLOperators AsTaJson|asTaJson]]
|[[OCLOperators AsTaJson|'''asTaJson''']]
|Returns a json string defined by the ViewModel
|Returns a json string defined by the ViewModel
|-
|-
|[[OCLOperators atTime|atTime]]
|[[OCLOperators atTime|'''atTime''']]
|Gives the read-only representation of a versioned object as it was at time X.
|Gives the read-only representation of a versioned object as it was at time X.
|-
|-
Line 46: Line 46:
|Meta information about what attributes the class has
|Meta information about what attributes the class has
|-
|-
|[[OCLOperators BigEndianUnicode|BigEndianUnicode]]
|[[OCLOperators BigEndianUnicode|'''BigEndianUnicode''']]
|
|
|-
|-
|[[OCLOperators brokenConstraints|brokenConstraints]]
|[[OCLOperators brokenConstraints|'''brokenConstraints''']]
|Returns a collection of the names of broken constraints for the class and object.
|Returns a collection of the names of broken constraints for the class and object.
|-
|-
|[[OCLOperators canAccess|canAccess]]
|[[OCLOperators canAccess|'''canAccess''']]
|Check ViewModels Access expression for root
|Check ViewModels Access expression for root
|-
|-
Line 58: Line 58:
|Meta information on what constraints the class has
|Meta information on what constraints the class has
|-
|-
|[[OCLOperators count|count]]
|[[OCLOperators count|'''count''']]
|Returns how many times the ''object'' is in the collection ''self''.
|Returns how many times the ''object'' is in the collection ''self''.
|-
|-
|[[OCLOperators Default|Default]]
|[[OCLOperators Default|'''Default''']]
|
|
|-
|-
|[[OCLOperators Empty|Empty]]
|[[OCLOperators Empty|'''Empty''']]
|
|
|-
|-
Line 70: Line 70:
|Returns an empty list typed to hold objects of the class
|Returns an empty list typed to hold objects of the class
|-
|-
|[[OCLOperators existing|existing]]
|[[OCLOperators existing|'''existing''']]
|The existing operator returns true if the object hasn't been deleted.
|The existing operator returns true if the object hasn't been deleted.
|-
|-
|[[OCLOperators externalId|externalId]]
|[[OCLOperators externalId|'''externalId''']]
|Returns the external ID for the object operated on.
|Returns the external ID for the object operated on.
|-
|-
|[[OCLOperators format|format]]
|[[OCLOperators format|'''format''']]
|
|
|-
|-
|[[OCLOperators IsDirty|IsDirty]]
|[[OCLOperators IsDirty|'''IsDirty''']]
|Returns true if the objects have been changed since the last save.
|Returns true if the objects have been changed since the last save.
|-
|-
|[[OCLOperators IsNew|IsNew]]
|[[OCLOperators IsNew|'''IsNew''']]
|IsNew operator returns true if the object has never been saved to the database.
|IsNew operator returns true if the object has never been saved to the database.
|-
|-
Line 91: Line 91:
|Returns true if the value is null (not assigned any value).
|Returns true if the value is null (not assigned any value).
|-
|-
|[[OCLOperators maxValue|maxValue]]
|[[OCLOperators maxValue|'''maxValue''']]
|Gets the maximum value in a collection of values
|Gets the maximum value in a collection of values
|-
|-
|[[OCLOperators minValue|minValue]]
|[[OCLOperators minValue|'''minValue''']]
|Gets the minimum value in a collection of values
|Gets the minimum value in a collection of values
|-
|-
Line 106: Line 106:
|The type of the class
|The type of the class
|-
|-
|[[OCLOperators oclGetStates|oclGetStates]]
|[[OCLOperators oclGetStates|'''oclGetStates''']]
|Gets a list of the objects all state machines currently state as strings.
|Gets a list of the objects all state machines currently state as strings.
|-
|-
Line 118: Line 118:
|Returns true if
|Returns true if
|-
|-
|[[OCLOperators OnCreate|OnCreate]]
|[[OCLOperators OnCreate|'''OnCreate''']]
|Is often called when a new object has been created.
|Is often called when a new object has been created.
|-
|-
|[[OCLOperators OnUpdate|OnUpdate]]
|[[OCLOperators OnUpdate|'''OnUpdate''']]
|Is called just before the object is saved to the database.
|Is called just before the object is saved to the database.
|-
|-
|[[oclIsUndefined]]
|[[oclIsUndefined|'''oclIsUndefined''']]
|Returns true if ''self'' is equal to invalid or null.
|Returns true if ''self'' is equal to invalid or null.
|-
|-
Line 130: Line 130:
|When used on an object, you get the type of the object.
|When used on an object, you get the type of the object.
|-
|-
|[[OCLOperators random|random]]
|[[OCLOperators random|'''random''']]
|
|
|-
|-
Line 136: Line 136:
|
|
|-
|-
|[[OCLOperators Sqlpassthrough|sqlpassthrough]]
|[[OCLOperators Sqlpassthrough|'''sqlpassthrough''']]
|Calls a stored procedure
|Calls a stored procedure
|-
|-
|[[OCLOperators sqlpassthroughobjects|sqlpassthroughobjects]]
|[[OCLOperators sqlpassthroughobjects|'''sqlpassthroughobjects''']]
|Return a primary key of SomeClass. This can be combined with other Ocl-PS via ->intersection or union.  
|Return a primary key of SomeClass. This can be combined with other Ocl-PS via ->intersection or union.  
|-
|-
Line 239: Line 239:
|Returns true if the collection is empty
|Returns true if the collection is empty
|-
|-
|'''[[OCLOperators notEmpty|->]]'''[[OCLOperators notEmpty|notEmpty]]
|'''[[OCLOperators notEmpty|->]][[OCLOperators notEmpty|notEmpty]]'''
|Returns true if ''self'' contains at least one element, false otherwise.
|Returns true if ''self'' contains at least one element, false otherwise.
|-
|-
|'''[[OCLOperators reject|->]]'''[[OCLOperators reject|reject]]
|'''[[OCLOperators reject|->]][[OCLOperators reject|reject]]'''
|Returns a collection with all elements of ''self'' except for those who validate the OclExpression ''expr''.
|Returns a collection with all elements of ''self'' except for those who validate the OclExpression ''expr''.
|-
|-
|'''[[OCLOperators select|->]]'''[[OCLOperators select|select]]
|'''[[OCLOperators select|->]][[OCLOperators select|select]]'''
|Returns a collection with all elements of ''self'' that validate the OclExpression ''expr''.
|Returns a collection with all elements of ''self'' that validate the OclExpression ''expr''.
|-
|-
|'''[[OCLOperators size|->]]'''[[OCLOperators size|size]]
|'''[[OCLOperators size|->]][[OCLOperators size|size]]'''
|Returns the number of elements contained in ''self''.
|Returns the number of elements contained in ''self''.
|-
|-
|'''[[OCLOperators sum|->]]'''[[OCLOperators sum|sum]]
|'''[[OCLOperators sum|->]][[OCLOperators sum|sum]]'''
|Returns the sum of all elements contained in ''self'' if they support the '+' operation.
|Returns the sum of all elements contained in ''self'' if they support the '+' operation.
|-
|-
Line 296: Line 296:
!Description
!Description
|-
|-
|[[Escape codes]]
|[[Escape codes|'''Escape codes''']]
|Escape (special) characters used in OCL
|Escape (special) characters used in OCL
|-
|-
|[[OCLOperators StringToAnsiBase64|StringToAnsiBase64]]
|[[OCLOperators StringToAnsiBase64|'''StringToAnsiBase64''']]
|Convert a string to an ANSI (1252) and as a base64 string
|Convert a string to an ANSI (1252) and as a base64 string
|-
|-
|[[OCLOperators StringToEncodedBase64|StringToEncodedBase64]]
|[[OCLOperators StringToEncodedBase64|'''StringToEncodedBase64''']]
|Convert a string to a specific encoding and as a base64 string. For example Western European (ISO) Codepage 28591
|Convert a string to a specific encoding and as a base64 string. For example Western European (ISO) Codepage 28591
|-
|-
|[[OCLOperators Size () : Integer|size () : Integer]]
|[[OCLOperators Size () : Integer|'''size () : Integer''']]
|Returns the number of characters composing ''self''.
|Returns the number of characters composing ''self''.
|-
|-
|[[OCLOperators subString|subString]]
|[[OCLOperators subString|'''subString''']]
|Returns the substring of the string operated on. The substring starts at parameter 1 and ends at parameter 2. The counting is 1-based.
|Returns the substring of the string operated on. The substring starts at parameter 1 and ends at parameter 2. The counting is 1-based.
|-
|-
|[https://wiki.mdriven.net/index.php/OCLOperators_toInteger_()_:_Integer toInteger () : Integer]
|[https://wiki.mdriven.net/index.php/OCLOperators_toInteger_()_:_Integer '''toInteger () : Integer''']
|Returns ''self'' with all characters converted to lowercase.
|Returns ''self'' with all characters converted to lowercase.
|-
|-
|[[OCLOperators ToLower () : String|toLower () : String]]
|[[OCLOperators ToLower () : String|'''toLower () : String''']]
|Returns ''self'' with all characters converted to lowercase.
|Returns ''self'' with all characters converted to lowercase.
|-
|-
|[[OCLOperators ToReal () : Real|toReal () : Real]]
|[[OCLOperators ToReal () : Real|'''toReal () : Real''']]
|Returns a Real of value equal to ''self''<nowiki>, or |invalid| if </nowiki>''self'' does not represent a real.
|Returns a Real of value equal to ''self''<nowiki>, or |invalid| if </nowiki>''self'' does not represent a real.
|-
|-
|[[OCLOperators ToUpper () : String|toUpper () : String]]
|[[OCLOperators ToUpper () : String|'''toUpper () : String''']]
|Returns self with all characters converted to uppercase.
|Returns self with all characters converted to uppercase.
|}
|}
Line 330: Line 330:
!Description
!Description
|-
|-
|[[OCLOperators Number::abs () : Number|Number::abs () : Number]]
|[[OCLOperators Number::abs () : Number|'''Number::abs () : Number''']]
|Returns the absolute value of ''self'', ''self'' if it is already a positive number.
|Returns the absolute value of ''self'', ''self'' if it is already a positive number.
|-
|-
|[[OCLOperators Number::floor () : Integer|Number::floor () : Integer]]
|[[OCLOperators Number::floor () : Integer|'''Number::floor () : Integer''']]
|Returns the integer part of self if it is a Real, self if it is an Integer.
|Returns the integer part of self if it is a Real, self if it is an Integer.
|-
|-
|[[OCLOperators Number::max ( r : Number ) : Number|Number::max ( r : Number ) : Number]]
|[[OCLOperators Number::max ( r : Number ) : Number|'''Number::max ( r : Number ) : Number''']]
|Returns the greatest number between self and *r*.
|Returns the greatest number between self and *r*.
|-
|-
|[[OCLOperators Number::min ( r : Number ) : Number|Number::min ( r : Number ) : Number]]
|[[OCLOperators Number::min ( r : Number ) : Number|'''Number::min ( r : Number ) : Number''']]
|Returns the lowest number between ''self'' and *r*.
|Returns the lowest number between ''self'' and *r*.
|-
|-
|[[OCLOperators Number::round () : Integer|Number::round () : Integer]]
|[[OCLOperators Number::round () : Integer|'''Number::round () : Integer''']]
|Returns the nearest integer to ''self'' if it is a Real, ''self'' if it is an Integer.
|Returns the nearest integer to ''self'' if it is a Real, ''self'' if it is an Integer.
|-
|-
Line 348: Line 348:
|Reminder of division with r, ie modulus or mod or %
|Reminder of division with r, ie modulus or mod or %
|-
|-
|[[OCLOperators Integer::div ( i : Integer ) : Integer|Integer::div ( i : Integer ) : Integer]]
|[[OCLOperators Integer::div ( i : Integer ) : Integer|'''Integer::div ( i : Integer ) : Integer''']]
|Returns the integer quotient of the division of ''self'' by *i*.
|Returns the integer quotient of the division of ''self'' by *i*.
|-
|-
|[[OCLOperators Integer::mod ( i : Integer ) : Integer|Integer::mod ( i : Integer ) : Integer]]
|[[OCLOperators Integer::mod ( i : Integer ) : Integer|'''Integer::mod ( i : Integer ) : Integer''']]
|Returns the integer remainder of the division of ''self'' by *i*.
|Returns the integer remainder of the division of ''self'' by *i*.
|}
|}
Line 359: Line 359:
!Description
!Description
|-
|-
|[[OCLOperators And|And]]
|[[OCLOperators And|'''And''']]
|
|
{| class="wikitable"
{| class="wikitable"
Line 383: Line 383:
|}
|}
|-
|-
|[[OCLOperators Implies|Implies]]
|[[OCLOperators Implies|'''Implies''']]
|
|
{| class="wikitable"
{| class="wikitable"
Line 407: Line 407:
|}
|}
|-
|-
|[[OCLOperators Or|Or]]
|[[OCLOperators Or|'''Or''']]
|
|
{| class="wikitable"
{| class="wikitable"
Line 431: Line 431:
|}
|}
|-
|-
|[[OCLOperators Not|Not]]
|[[OCLOperators Not|'''Not''']]
|
|
{| class="wikitable"
{| class="wikitable"
Line 447: Line 447:
|}
|}
|-
|-
|[[OCLOperators Xor|Xor]]
|[[OCLOperators Xor|'''Xor''']]
|
|
{| class="wikitable"
{| class="wikitable"

Revision as of 06:35, 13 April 2023

General Operators

To find all available operators, you can open the OCL-Editor and type in a class:

Ocl-editor 1.png

Operators Description
allInstances All the objects of the class
allinstancesAtTime All the currently loaded instances
allLoadedObjects All objects currently in memory, excluding deleted objects
allStates Meta information about available states in state machines the class may contain
allSubClasses Meta information on all the sub-classes this class has
allSuperTypes Meta information on all the super-classes – in inheritance order the class has
ASCII
associationEnds Returns a collection of strings with association names for the class
associationEndsWithType Returns a collection of strings with association names and type information for the class
asString The string representation of the class – the asString operation is available on everything
asTaJson Returns a json string defined by the ViewModel
atTime Gives the read-only representation of a versioned object as it was at time X.
Attributes Meta information about what attributes the class has
BigEndianUnicode
brokenConstraints Returns a collection of the names of broken constraints for the class and object.
canAccess Check ViewModels Access expression for root
Constraints Meta information on what constraints the class has
count Returns how many times the object is in the collection self.
Default
Empty
emptylist Returns an empty list typed to hold objects of the class
existing The existing operator returns true if the object hasn't been deleted.
externalId Returns the external ID for the object operated on.
format
IsDirty Returns true if the objects have been changed since the last save.
IsNew IsNew operator returns true if the object has never been saved to the database.
isDirtyMember Called on a class attribute to check if this attribute has changes pending to be saved.
isNull Returns true if the value is null (not assigned any value).
maxValue Gets the maximum value in a collection of values
minValue Gets the minimum value in a collection of values
nullValue A typed null value
objectFromExternalId An external identity will be resolved to the object
oclAsType The type of the class
oclGetStates Gets a list of the objects all state machines currently state as strings.
oclIsInvalid Returns true if self is equal to *invalid*.
oclIsKindOf This is to if a class is a subclass or as the class itself and not unrelated
oclIsTypeOf Returns true if
OnCreate Is often called when a new object has been created.
OnUpdate Is called just before the object is saved to the database.
oclIsUndefined Returns true if self is equal to invalid or null.
OclType When used on an object, you get the type of the object.
random
safeCast
sqlpassthrough Calls a stored procedure
sqlpassthroughobjects Return a primary key of SomeClass. This can be combined with other Ocl-PS via ->intersection or union.
superTypes Returns the set of all direct supertypes of the type.
TaggedValue Meta information on tagged values set in the class
TaggedValueOnFeature Meta information on Tagged values set on a named feature in the class
Typename The type name as a string
ViewModels A tuple with the ViewModels for this class a members

Collection Operators

Once you have a collection of objects, there are certain operators applicable to them.

See this page for examples on collection operators.

Again, you can use the OCL-Editor to see what they are:

Collection of objects operators.png

Operators Description
->append Add another object last
->asBag Returns a Bag containing all elements of self.
->asSequence Returns a Sequence containing all elements of self. Element ordering is preserved when possible.
->asSet Returns a Set containing all elements of self.
->at Get the objects at X where the first index is 1
->at0 Get the objects at X where the first index is 0
->collect Returns a collection containing the result of applying expr on all elements contained in self.
->count Count how many meet a certain criteria
->dictionary Efficiently looks up values
->difference The difference between 2 collections
->excluding The collection except for this single object
->exists Returns true if at least one element in self validates the condition expr, false otherwise.
->filterOnType Only keep the ones of a certain type
->first Return the first object
->forAll Returns true if all the elements contained in self validate the condition expr, false otherwise.
->groupBy Build a collection of tuples grouped by some aspect
->includes Does the collection include the object
->includesAll Does the collection include the whole other collection
->including Returns the list with the element in the parameter included.
->IndexOf The 1 based index of an object in the collection possibly -1 if not existing
->indexOf0 The 0 based index of an object in the collection possibly -1 if not existing
->intersection The intersection of two collections
->isEmpty Returns true if the collection is empty
->notEmpty Returns true if self contains at least one element, false otherwise.
->reject Returns a collection with all elements of self except for those who validate the OclExpression expr.
->select Returns a collection with all elements of self that validate the OclExpression expr.
->size Returns the number of elements contained in self.
->sum Returns the sum of all elements contained in self if they support the '+' operation.
->last Returns the last object in the collection
->notEmpty Returns true if the collection is not empty
->orderBy Sorts the collection on one or more properties
->orderDescending Sort the from biggest to smallest
->orderGeneric Sorts the list of properties with interchangeable sort order: (expr1, OclSortDirection::ascending, expr2, OclSortDirection::descending...)
->prepend Returns an OrderedSet containing object followed by all elements of self.
->reject Returns the objects not matching the criteria
->select Returns the objects matching the criteria
->size Returns the number of elements in the collection
->subsequence Returns a smaller collection from a start to stop
->symmetricDifference The symmetric difference between the collections; ie all the objects in collection1 or collection2 but not in both
->union The set of objects in collection1 and objects in collection2

String Operators

Operators Description
Escape codes Escape (special) characters used in OCL
StringToAnsiBase64 Convert a string to an ANSI (1252) and as a base64 string
StringToEncodedBase64 Convert a string to a specific encoding and as a base64 string. For example Western European (ISO) Codepage 28591
size () : Integer Returns the number of characters composing self.
subString Returns the substring of the string operated on. The substring starts at parameter 1 and ends at parameter 2. The counting is 1-based.
toInteger () : Integer Returns self with all characters converted to lowercase.
toLower () : String Returns self with all characters converted to lowercase.
toReal () : Real Returns a Real of value equal to self, or |invalid| if self does not represent a real.
toUpper () : String Returns self with all characters converted to uppercase.

Number Operators

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.

Operators Description
Number::abs () : Number Returns the absolute value of selfself if it is already a positive number.
Number::floor () : Integer Returns the integer part of self if it is a Real, self if it is an Integer.
Number::max ( r : Number ) : Number Returns the greatest number between self and *r*.
Number::min ( r : Number ) : Number Returns the lowest number between self and *r*.
Number::round () : Integer Returns the nearest integer to self if it is a Real, self if it is an Integer.
Number::ieeereminder(r:Number):Integer Reminder of division with r, ie modulus or mod or %
Integer::div ( i : Integer ) : Integer Returns the integer quotient of the division of self by *i*.
Integer::mod ( i : Integer ) : Integer Returns the integer remainder of the division of self by *i*.

Boolean Operators

Operators Description
And
And True False Invalid
True true false true
False false false false
Invalid invalid false invalid
Implies
Implies True False Invalid
True true false invalid
False true true true
Invalid true invalid invalid
Or
Or True False Invalid
True true true true
False true false invalid
Invalid true invalid invalid
Not
Not Result
True false
False true
Invalid invalid
Xor
Xor True False Invalid
True false true invalid
False true false invalid
Invalid invalid invalid invalid

ViewModel Operators (on selfVM variable)

See page: SelfVM

This page was edited 119 days ago on 01/11/2024. What links here