OCLOperators
Peter Mugabe (talk | contribs) No edit summary |
Peter Mugabe (talk | contribs) No edit summary |
||
Line 260: | Line 260: | ||
|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 | |'''[[OCLOperators size|->]]'''[[OCLOperators size|size]] | ||
|Returns the number of elements contained in ''self''. | |Returns the number of elements contained in ''self''. | ||
|- | |- | ||
|'''[[OCLOperators | |'''[[OCLOperators sortedBY|->]]'''[[OCLOperators sortedBY|sortedBy]] | ||
|Returns a sorted collection containing all elements from ''self'' sorted in accordance with the OclExpression ''expr''. | |Returns a sorted collection containing all elements from ''self'' sorted in accordance with the OclExpression ''expr''. | ||
|- | |- |
Revision as of 12:00, 18 December 2019
General operators
To find all available you can open the OCL-Editor and type in a class:
Operators | Description |
---|---|
Allinstances | All the objects of the class |
allinstancesAtTime | All the currently loaded instances |
allLoadedObjects | All objects currently in memory, exckluding 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 ajson string defined by the ViewModel |
atTime | |
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 | |
Contraints | Meta information on what constraints the class has |
count | Returns how many times object is in the collection self. |
Default | |
Empty | |
emptylist | Returns an empty list typed to hold objects of the class |
existing | |
externalId | |
format | |
IsDirty | |
IsNew | IsNew operator returns true if the object has never been saved to the database. |
isDirtyMember | |
isNull | |
nullValue | A typed null value |
objectFromExternalId | An external identity will be resolved to the object |
oclAsType | The type of the class |
oclGetStates | |
oclIsInvalid | Returns true if self is equal to *invalid*. |
oclIsKindOf | This is to if a class is a subclass or a the class itself and not unrelated |
oclIsTypeOf | Returns true if |
OnCreate | |
OnUpdate | |
oclSingleton | Classes that implements the Singleton pattern – by setting IsSingleton=true – will return the singleton instance with this operator |
oclIsUndefined | Returns true if self is equal to invalid or null. |
OclType | |
safeCast | |
superTypes | |
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 that are applicable to it.
See this page for examples on collection operators
Again you can use the OCL-Editor to see what they are:
Operators | Description |
---|---|
->any | Returns any element contained in self that validates the condition expr, null otherwise. |
->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. |
->collectNested | Returns a collection containing all the elements contained in self on which we applied the OclExpression expr. |
->count | Count how many meet a certain criteria |
->excludes | Returns true if object is not contained in self, false otherwise. |
->excludesAll | Returns true if no element of *c2* is contained in self, false otherwise. |
->dictionary | Efficiently looks up values |
->difference | The difference between 2 collections |
->excluding | The collection except this single object |
->exists | Returns true if at least one element in self validates the condition expr, false otherwise. |
->flatten | Returns a collection containing all elements of self recursively flattened. |
->filterOnType | Only keep the ones of a certain type |
->first | Return the first object |
->forAll | Returns true if the all the elements contained in self validate the condition expr, false otherwise. |
->groupBy | Build 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 |
->isUnique | Returns true if all elements contained in self evaluate to a distinct value for expr. |
->notEmpty | Returns true if self contains at least one element, false otherwise. |
->one | Returns true if there is only one element contained in self that validates the condition expr, false otherwise. |
->product | Returns a Set of Tuples which represents the Cartesian product of self with *c2*. |
->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. |
->sortedBy | Returns a sorted collection containing all elements from self sorted in accordance with the OclExpression expr. |
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 of 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 Eauropean (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 self, self 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. |
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*. |
Viewmodel operators (on selfVM variable)
See page SelfVM
This page was edited more than 1 years ago on 01/11/2024. What links here