org.eclipse.emf.ecore.xmi.IllegalValueException

I hate exceptions. Yes, I really hate exceptions.

I’ve defined a EDataType EPoint that uses the java class org.eclipse.draw2d.geometry.Point.

Ecore model

In the code I set the start and end point of the ElementView by the corresponding setter that I pass instances of the class Point ( and not EPoint! ).

ElementView view = factory.createElementView();
view.setStartPoint(new Point(20, 20));
view.setEndPoint(new Point(100, 100));

Saving the model produces the following file content:


...
<diagrams name="NewDiagram">
    <diagramView diagram="//@diagrams.0">
      <elementViews startPoint="Point(20, 20)" endPoint="Point(100, 100)"/>
    </diagramView>
  </diagrams>
...

The instances are serialized by the method toString() of the class Point which outputs Point(xx, yy) but these values lead the loading process fail while this message appears:

org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1DiagnosticWrappedException: org.eclipse.emf.ecore.xmi.IllegalValueException: Value 'Point(20, 20)' is not legal. (file:/.../test1/model.pe, 7, 76)
18:28:12 zprototype.model.impl.ModelManagerImpl::load   Model could not be loaded (org.eclipse.emf.ecore.xmi.IllegalValueException: Value 'Point(20, 20)' is not legal. (file:/.../test1/model.pe, 7, 76))
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.handleDemandLoadException(ResourceSetImpl.java:315)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(ResourceSetImpl.java:274)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResource(ResourceSetImpl.java:397)
	at zprototype.model.impl.ModelManagerImpl.load(ModelManagerImpl.java:63)

I tried to replace the Point class by another one but it’s the same problem with that. Now my question is why the value is not legal? Does the deserializer not know how to create the objects from the string?

DeliciousDiggTechnorati FavoritesRedditLinkedInFacebookSpurlTwitterWebnewsYiGGMySpaceYahoo BookmarksFriendFeedGoogle BookmarksLiveJournalShare

One Response

Write a Comment»
  1. Ok it’s quite simple. In the factory implementation there is a method createEPointFromString(EDataType, String) that one has to change. But don’t forget to remove the @generated tag to not override it next time the model code is regenerated.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>