Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Extend data types from the Standard Library in UML model
Extend data types from the Standard Library in UML model [message #1754388] Fri, 17 February 2017 07:57 Go to next message
Denis Nikiforov is currently offline Denis NikiforovFriend
Messages: 344
Registered: August 2013
Senior Member
Hi

It's possible to create custom data types or classes with custom operations in an UML model. For example I can create the DateTime class with the operation toString() in my model.

Is it possible to add operations to standard primitive types? For example, can I declare operation toDateTime() for the String primitive type? And also can I declare custom iterations in an UML model? For example can I declare Sequence(String)::sep(delimiter : String) iteration?

In the OCL Specification 2.4, subsection 11.8.1 "Extending the Standard Library with Iterator Expressions" it's said:
Quote:
It is possible to add new iterator expressions in the standard library. If this is done the semantics of a new iterator should be defined by mapping it to existing constructs, in the same way the semantics of pre-defined iterators is done (see sub clause 11.9)


I understand that I can extend Standard Library programmatically. But is there a way to extend it using some magic stereotypes in an UML model? I don't need to implement these operations in the UML model. I need only to declare them.

I think that I need UML primitive types and OCL collection types to be something like partial classes so I can extend them in my UML model:
https://en.wikipedia.org/wiki/C_Sharp_2.0#Partial_class
https://en.wikipedia.org/wiki/Class_(computer_programming)#Partial
Re: Extend data types from the Standard Library in UML model [message #1754389 is a reply to message #1754388] Fri, 17 February 2017 08:01 Go to previous messageGo to next message
Denis Nikiforov is currently offline Denis NikiforovFriend
Messages: 344
Registered: August 2013
Senior Member
For now to construct new DateTime from string I declared the static operation DateTime::new(str : String) : DateTime. But I can't declare String::toDateTime() : DateTime.
Re: Extend data types from the Standard Library in UML model [message #1754393 is a reply to message #1754389] Fri, 17 February 2017 08:28 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

The intention is that you can extend by:

*.ecore/*.oclinecore/*.uml - OCL embedded within your primary model
*.ocl - OCL that complements another metamodel; you can complement primitive types
*.oclstdlib - OCL standard library definitions extensions

In principle you can import/load *.ocl or *.oclstdlib to extend.

Adding a UML 'import' to avoid the need for a manual load is still under consideration. Potentially the existing import could just work and so avoid any UML specification or tool change.

There is an open Bugzilla calling on me to provide a custom OCLstdlib tutorial. I did some work on a math.oclstdlib just before Neon and concluded that there were a number of bugs that needed fixing. Not ready for prime time.

Regards

Ed Willink

Previous Topic:false or null = null?
Next Topic:OCL AST - Editing, Parsing and Cloning
Goto Forum:
  


Current Time: Thu Apr 25 05:38:55 GMT 2024

Powered by FUDForum. Page generated in 0.03679 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top