EMF throws an IllegalValueException [message #506052] |
Tue, 05 January 2010 21:30 |
No real name Messages: 2 Registered: January 2010 |
Junior Member |
|
|
I'm not using EMF that much so hopefully someone can help me solving my problem.
In my EMF model I've defined a EDataType EPoint that uses the java class org.eclipse.draw2d.geometry.Point.
In the code I instantiate Point ( and not EPoint ) while calling the setters.
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 Point instances are serialized by toString() and stored in startPoint and endPoint. For whatever reasons these values lead the loading process fail. 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?
I'm pretty sure that I have to pass an EClass instead of a Point but how to create instances of EPoint?
[Updated on: Tue, 05 January 2010 21:40] Report message to a moderator
|
|
|
Re: EMF throws an IllegalValueException [message #506055 is a reply to message #506052] |
Tue, 05 January 2010 17:20 |
Ed Merks Messages: 33137 Registered: July 2009 |
Senior Member |
|
|
Have a look at the "Data types" section of
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .emf.doc/references/overview/EMF.html
You'll have to specialize the generated factory to be able to create a
Point from whatever string format you choose to use.
slopjong@gmail.com wrote:
> I'm not using EMF that much so hopefully someone can help me solving
> my problem.
>
> In my EMF model I've defined a EDataType EPoint that uses the java
> class org.eclipse.draw2d.geometry.Point.
>
> In the code I instantiate Point ( and not EPoint ) while calling the
> setters.
>
>
> 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 Point instances are serialized by toString() and stored in
> startPoint and endPoint. For whatever reasons these values lead the
> loading process fail. This message appears:
>
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1Diagnos ticWrappedException:
> 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.handleDe mandLoadException(ResourceSetImpl.java:315)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo adHelper(ResourceSetImpl.java:274)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(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?
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
Powered by
FUDForum. Page generated in 0.03320 seconds