Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » custom data types
custom data types [message #916000] Tue, 18 September 2012 11:37 Go to next message
José Miguel P. is currently offline José Miguel P.Friend
Messages: 65
Registered: March 2010


I've been doing a test with spacial types in my Ecore model. I have define the follow datatype:

<eClassifiers xsi:type="ecore:EDataType" name="IpV4" instanceClassName=""/>
<eClassifiers xsi:type="ecore:EDataType" name="IpV6" instanceClassName=""/>

datatype IpV4 :;
datatype IpV6 :;

When I generate my EMF code for mange the model, I define who I want serialize and deserialize this types like this:

 * @generated NOT
public Inet4Address createIpV4FromString(EDataType eDataType, String initialValue) {
	try {
		return (Inet4Address) Inet4Address.getByName(initialValue);
	} catch (UnknownHostException e) {
		throw new IllegalArgumentException(e.getMessage());

 * @generated NOT
public String convertIpV4ToString(EDataType eDataType, Object instanceValue) {
	if(instanceValue == null) return null;
	return ((Inet4Address) instanceValue).toString().replace("/", "");

 * @generated NOT
public Inet6Address createIpV6FromString(EDataType eDataType, String initialValue) { ... }

 * @generated NOT
public String convertIpV6ToString(EDataType eDataType, Object instanceValue)  {...}

This works ok when I use EMF, because this code serialize and deserialize it without problem, but, when I use ATL, the engine don't know how to deserialize it, and I get the follow error:

Error loading file://home/jozemi/WS/runtime-EclipseApplication/Objetos/My.objects: org.eclipse.emf.ecore.xmi.IllegalValueException: Value '' is not legal. (file://home/jozemi/WS/runtime-EclipseApplication/Objetos/My.objects, 7, 107)

Is there any way to specify to the ATL VM how to deserialize this kind of data types, or manage it like other, for example, a string?

Thanks in advance Smile

Re: custom data types [message #986429 is a reply to message #916000] Tue, 20 November 2012 11:56 Go to previous messageGo to next message
Jörn Guy  Süß is currently offline Jörn Guy SüßFriend
Messages: 83
Registered: July 2009
Location: Germany

I have the same question. Auspicious silence...
Re: custom data types [message #986826 is a reply to message #986429] Wed, 21 November 2012 19:36 Go to previous message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 365
Registered: September 2012
Location: Belgium
Senior Member

Op 20/11/12 12:56, Jörn Guy Süss schreef:
> I have the same question. Auspicious silence...

Never tried this in regular ATL, but apparently it works in EMFTVM:

-- @atlcompiler emftvm
-- @nsURI CDTT=http://cdtt/1.0
module CDTTCopy;

create OUT : CDTT from IN : CDTT;

rule Host {
from s : CDTT!Host
to t : CDTT!Host (
ipv4Address <- s.ipv4Address,
ipv6Address <- s.ipv6Address)

However, you can't specify String literals in ATL, and expect them to be
converted to Java objects. The FactoryImpl converters only work for
loading/saving models.

If you want to construct native objects within ATL, you can use something like
this (only in EMFTVM):

helper def : random() : Real =

Unfortunately, that does not work for InetAddress types, because ATL cannot
express static method invocations. Best to include extra native EOperations in
your metamodel to wrap the required static method calls.


Previous Topic:Containment references cannot span across models
Next Topic:ATL.ecore validation fails
Goto Forum:

Current Time: Sat Jun 23 06:27:45 GMT 2018

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

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

Back to the top