Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Problem using SimpleAnyType
Problem using SimpleAnyType [message #425532] Mon, 01 December 2008 05:30 Go to next message
Bryan Hunt is currently offline Bryan HuntFriend
Messages: 366
Registered: July 2009
Senior Member
I've modified my workflow editor to allow the creation of a
SimpleAnyType, and I've run into a problem re-loading the model after
specifying the Instance Type and Value attributes. See the exception
trace below. I'm setting (using the properties editor) Instance Type
to EString, and Value to Hello. I'm leaving the other attributes
blank. Do I need to do anything with the Any or Any Attribute
attributes?

This exception occurs when I try to bring up the model in the editor
and it has a SimpleAnyType with Instance Type and Value set as
described above.

java.lang.ClassCastException: org.eclipse.emf.ecore.impl.EDataTypeImpl
at org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.getType(XMLHelp erImpl.java:903)
at
org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.createObject(XM LHelperImpl.java:920)
at

org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectFromFa ctory(XMLHandler.java:2171)
at

org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectFromTy peName(XMLHandler.java:2081)
at

org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObject(XMLHa ndler.java:2016)
at org.eclipse.emf.ecore.xmi.impl.XMIHandler.createObject(XMIHa ndler.java:131)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleFeature(XMLH andler.java:1825)
at

org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XML Handler.java:1023)
at org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMI Handler.java:87)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:1001)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:712)
at org.eclipse.emf.ecore.xmi.impl.XMIHandler.startElement(XMIHa ndler.java:167)
at
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .startElement(AbstractSAXParser.java:533)
at

com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.j ava:878)
at

com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFra gmentScannerImpl.java:1693)
at

com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java: 368)
at

com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(XML11Configuration.java:834)
at

com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(XML11Configuration.java:764)
at

com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(X MLParser.java:148)
at
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .parse(AbstractSAXParser.java:1242)
at

javax.xml.parsers.SAXParser.parse(SAXParser.java:375)
at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl. java:181)
at
org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLRes ourceImpl.java:180)
at

org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1444)
at
org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1240)
at

org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo ad(ResourceSetImpl.java:255)
at

org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo adHelper(ResourceSetImpl.java:270)
at

org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:397)
at

org.eclipse.emf.internal.workfflow.launcher.WorkflowLaunchCo nfigurationDelegate.launch(WorkflowLaunchConfigurationDelega te.java:47)
at

org.eclipse.debug.internal.core.LaunchConfiguration.launch(L aunchConfiguration.java:860)
at

org.eclipse.debug.internal.core.LaunchConfiguration.launch(L aunchConfiguration.java:710)
at

org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(D ebugUIPlugin.java:866)
at

org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlu gin.java:1069)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
Re: Problem using SimpleAnyType [message #425541 is a reply to message #425532] Mon, 01 December 2008 11:24 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------020600040401010107070208
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Bryan,

Are you using an extended metadata option?

public EClassifier getType(EFactory eFactory, String typeName)
{
if (eFactory != null)
{
EPackage ePackage = eFactory.getEPackage();
if (extendedMetaData != null)
{
return extendedMetaData.getType(ePackage, typeName);
}
else
{
EClass eClass = (EClass)ePackage.getEClassifier(typeName);
if (eClass == null && xmlMap != null)
{
return xmlMap.getClassifier(ePackage.getNsURI(), typeName);
}
return eClass;
}
}
return null;
}

The cast to EClass seems kind of pointless here, but later where the is
used, the extended metadata issues arises again.

public EObject createObject(EFactory eFactory, EClassifier type)
{
EObject newObject = null;
if (eFactory != null)
{
if (extendedMetaData != null)
{
if (type == null)
{
return null;
}
else if (type instanceof EClass)
{
newObject = eFactory.create((EClass)type);
}
else
{
SimpleAnyType result =
(SimpleAnyType)EcoreUtil.create(anySimpleType);
result.setInstanceType((EDataType)type);
newObject = result;
}
}
else
{
if (type != null)
{
newObject = eFactory.create((EClass)type);
}
}
}
return newObject;
}


Bryan Hunt wrote:
> I've modified my workflow editor to allow the creation of a
> SimpleAnyType, and I've run into a problem re-loading the model after
> specifying the Instance Type and Value attributes. See the exception
> trace below. I'm setting (using the properties editor) Instance Type
> to EString, and Value to Hello. I'm leaving the other attributes
> blank. Do I need to do anything with the Any or Any Attribute
> attributes?
>
> This exception occurs when I try to bring up the model in the editor
> and it has a SimpleAnyType with Instance Type and Value set as
> described above.
>
> java.lang.ClassCastException: org.eclipse.emf.ecore.impl.EDataTypeImpl
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.getType(XMLHelp erImpl.java:903)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.createObject(XM LHelperImpl.java:920)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectFromFa ctory(XMLHandler.java:2171)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectFromTy peName(XMLHandler.java:2081)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObject(XMLHa ndler.java:2016)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMIHandler.createObject(XMIHa ndler.java:131)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleFeature(XMLH andler.java:1825)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XML Handler.java:1023)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMI Handler.java:87)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:1001)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:712)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMIHandler.startElement(XMIHa ndler.java:167)
>
> at
> com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .startElement(AbstractSAXParser.java:533)
>
> at
> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.j ava:878)
>
> at
> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFra gmentScannerImpl.java:1693)
>
> at
> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java: 368)
>
> at
> com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(XML11Configuration.java:834)
>
> at
> com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(XML11Configuration.java:764)
>
> at
> com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(X MLParser.java:148)
>
> at
> com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .parse(AbstractSAXParser.java:1242)
>
> at
> javax.xml.parsers.SAXParser.parse(SAXParser.java:375)
> at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl. java:181)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLRes ourceImpl.java:180)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1444)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1240)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo ad(ResourceSetImpl.java:255)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo adHelper(ResourceSetImpl.java:270)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:397)
>
> at
> org.eclipse.emf.internal.workfflow.launcher.WorkflowLaunchCo nfigurationDelegate.launch(WorkflowLaunchConfigurationDelega te.java:47)
>
> at
> org.eclipse.debug.internal.core.LaunchConfiguration.launch(L aunchConfiguration.java:860)
>
> at
> org.eclipse.debug.internal.core.LaunchConfiguration.launch(L aunchConfiguration.java:710)
>
> at
> org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(D ebugUIPlugin.java:866)
>
> at
> org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlu gin.java:1069)
>
> at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
>

--------------020600040401010107070208
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Bryan,<br>
<br>
Are you using an extended metadata option?<br>
<blockquote><small>&nbsp; public EClassifier getType(EFactory eFactory,
String typeName)</small><br>
<small>&nbsp; {</small><br>
<small>&nbsp;&nbsp;&nbsp; if (eFactory != null)</small><br>
<small>&nbsp;&nbsp;&nbsp; {</small><br>
<small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; EPackage ePackage = eFactory.getEPackage();</small><br>
<small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (extendedMetaData != null)</small><br>
<small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; return extendedMetaData.getType(ePackage, typeName);</small><br>
<small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</small><br>
<small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else</small><br>
<small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; EClass eClass =
(EClass)ePackage.getEClassifier(typeName);</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; if (eClass == null &amp;&amp; xmlMap != null)</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; {</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return xmlMap.getClassifier(ePackage.getNsURI(),
typeName);</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; }</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; return eClass;</small><br>
<small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</small><br>
<small>&nbsp;&nbsp;&nbsp; }</small><br>
<small>&nbsp;&nbsp;&nbsp; return null;</small><br>
<small>&nbsp; }</small><br>
</blockquote>
The cast to EClass seems kind of pointless here, but later where the is
used, the extended metadata issues arises again.<br>
<blockquote><small>&nbsp; public EObject createObject(EFactory eFactory,
EClassifier type)<br>
&nbsp; {<br>
&nbsp;&nbsp;&nbsp; EObject newObject = null;<br>
&nbsp;&nbsp;&nbsp; if (eFactory != null)<br>
&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (extendedMetaData != null)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; if (type == null)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return null;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; }<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; else if (type instanceof EClass)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; newObject = eFactory.create((EClass)type);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; }<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; else<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; SimpleAnyType result =
(SimpleAnyType)EcoreUtil.create(anySimpleType);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; result.setInstanceType((EDataType)type);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; newObject = result;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; }<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; if (type != null)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; newObject = eFactory.create((EClass)type);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; }<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; return newObject;<br>
&nbsp; }</small><br>
</blockquote>
<br>
Bryan Hunt wrote:
<blockquote cite="mid:ggvsq9$ufu$1@build.eclipse.org" type="cite">I've
modified my workflow editor to allow the creation of a SimpleAnyType,
and I've run into a problem re-loading the model after specifying the
Instance Type and Value attributes.&nbsp; See the exception trace below.&nbsp;
I'm setting&nbsp; (using the properties editor) Instance Type to EString,
and Value to Hello.&nbsp; I'm leaving the other attributes blank.&nbsp; Do I need
to do anything with the Any or Any Attribute attributes?
<br>
<br>
This exception occurs when I try to bring up the model in the editor
and it has a SimpleAnyType with Instance Type and Value set as
described above.
<br>
<br>
java.lang.ClassCastException: org.eclipse.emf.ecore.impl.EDataTypeImpl
<br>
at
org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.getType(XMLHelp erImpl.java:903)
<br>
at
org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.createObject(XM LHelperImpl.java:920)
<br>
at <br>
org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectFromFa ctory(XMLHandler.java:2171)
<br>
at <br>
org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectFromTy peName(XMLHandler.java:2081)
<br>
at <br>
org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObject(XMLHa ndler.java:2016)
<br>
at
org.eclipse.emf.ecore.xmi.impl.XMIHandler.createObject(XMIHa ndler.java:131)
<br>
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleFeature(XMLH andler.java:1825)
<br>
at <br>
org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XML Handler.java:1023)
<br>
at
org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMI Handler.java:87)
<br>
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:1001)
<br>
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:712)
<br>
at
org.eclipse.emf.ecore.xmi.impl.XMIHandler.startElement(XMIHa ndler.java:167)
<br>
at
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .startElement(AbstractSAXParser.java:533)
<br>
at <br>
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.j ava:878)
<br>
at <br>
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFra gmentScannerImpl.java:1693)
<br>
at <br>
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java: 368)
<br>
at <br>
com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(XML11Configuration.java:834)
<br>
at <br>
com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(XML11Configuration.java:764)
<br>
at <br>
com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(X MLParser.java:148)
<br>
at
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .parse(AbstractSAXParser.java:1242)
<br>
at <br>
javax.xml.parsers.SAXParser.parse(SAXParser.java:375)
<br>
at
org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl. java:181)
<br>
at
org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLRes ourceImpl.java:180)
<br>
at <br>
org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1444)
<br>
at
org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1240)
<br>
at <br>
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo ad(ResourceSetImpl.java:255)
<br>
at <br>
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo adHelper(ResourceSetImpl.java:270)
<br>
at <br>
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:397)
<br>
at <br>
org.eclipse.emf.internal.workfflow.launcher.WorkflowLaunchCo nfigurationDelegate.launch(WorkflowLaunchConfigurationDelega te.java:47)
<br>
at <br>
org.eclipse.debug.internal.core.LaunchConfiguration.launch(L aunchConfiguration.java:860)
<br>
at <br>
org.eclipse.debug.internal.core.LaunchConfiguration.launch(L aunchConfiguration.java:710)
<br>
at <br>
org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(D ebugUIPlugin.java:866)
<br>
at <br>
org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlu gin.java:1069)
<br>
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
<br>
<br>
</blockquote>
</body>
</html>

--------------020600040401010107070208--


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Problem using SimpleAnyType [message #425591 is a reply to message #425541] Tue, 02 December 2008 18:27 Go to previous messageGo to next message
Bryan Hunt is currently offline Bryan HuntFriend
Messages: 366
Registered: July 2009
Senior Member
Ed,

I'm not sure what the extended metadata option is, so let's assume for
now the answer is: no, I'm not using the extended metadata option. I
think I might have found the problem ... when I set the value of the
parameter map entry, the model is serialized as follows:

<?xml version="1.0" encoding="UTF-8"?>
<org.eclipse.emf.workflow.runtime:WorkflowContext xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
xmlns:org.eclipse.emf.workflow.runtime="http://www.eclipse.org/emf/workflow/runtime.ecore">


<parameters>
<value xsi:type="ecore:EString">
Hello <instanceType
href="http://www.eclipse.org/emf/2002/Ecore#//EString"/>
</value>
</parameters>
</org.eclipse.emf.workflow.runtime:WorkflowContext>

It seems that SimpleAnyType is not being serialized correctly. Why is
the value type EString? Shouldn't it be SimpleAnyType? Does this look
incorrect to you? Since I've never used SimpleAnyType, I'm not sure
what to expect when it gets serialized.

Bryan

On 2008-12-01 05:24:36 -0600, Ed Merks <Ed.Merks@gmail.com> said:

>
> Bryan,
>
> Are you using an extended metadata option?
>
> public EClassifier getType(EFactory eFactory, String typeName)
> {
> if (eFactory != null)
> {
> EPackage ePackage = eFactory.getEPackage();
> if (extendedMetaData != null)
> {
> return extendedMetaData.getType(ePackage, typeName);
> }
> else
> {
> EClass eClass = (EClass)ePackage.getEClassifier(typeName);
> if (eClass == null && xmlMap != null)
> {
> return xmlMap.getClassifier(ePackage.getNsURI(), typeName);
> }
> return eClass;
> }
> }
> return null;
> }
>
> The cast to EClass seems kind of pointless here, but later where the is
> used, the extended metadata issues arises again.
>
> public EObject createObject(EFactory eFactory, EClassifier type)
> {
> EObject newObject = null;
> if (eFactory != null)
> {
> if (extendedMetaData != null)
> {
> if (type == null)
> {
> return null;
> }
> else if (type instanceof EClass)
> {
> newObject = eFactory.create((EClass)type);
> }
> else
> {
> SimpleAnyType result =
> (SimpleAnyType)EcoreUtil.create(anySimpleType);
> result.setInstanceType((EDataType)type);
> newObject = result;
> }
> }
> else
> {
> if (type != null)
> {
> newObject = eFactory.create((EClass)type);
> }
> }
> }
> return newObject;
> }
>
>
> Bryan Hunt wrote:
>> I've modified my workflow editor to allow the creation of a
>> SimpleAnyType, and I've run into a problem re-loading the model after
>> specifying the Instance Type and Value attributes. See the exception
>> trace below. I'm setting (using the properties editor) Instance Type
>> to EString, and Value to Hello. I'm leaving the other attributes
>> blank. Do I need to do anything with the Any or Any Attribute
>> attributes?
>>
>> This exception occurs when I try to bring up the model in the editor
>> and it has a SimpleAnyType with Instance Type and Value set as
>> described above.
>>
>> java.lang.ClassCastException: org.eclipse.emf.ecore.impl.EDataTypeImpl
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.getType(XMLHelp erImpl.java:903)
>>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.createObject(XM LHelperImpl.java:920)

at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectFromFa ctory(XMLHandler.java:2171)

at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectFromTy peName(XMLHandler.java:2081)

at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObject(XMLHa ndler.java:2016)

at
org.eclipse.emf.ecore.xmi.impl.XMIHandler.createObject(XMIHa ndler.java:131)

at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleFeature(XMLH andler.java:1825)

at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XML Handler.java:1023)

at
org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMI Handler.java:87)

at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:1001)

at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:712)

at
org.eclipse.emf.ecore.xmi.impl.XMIHandler.startElement(XMIHa ndler.java:167)

at
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .startElement(AbstractSAXParser.java:533)

at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.j ava:878)

at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFra gmentScannerImpl.java:1693)

at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java: 368)

at
com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(XML11Configuration.java:834)

at
com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(XML11Configuration.java:764)

at
com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(X MLParser.java:148)

at
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .parse(AbstractSAXParser.java:1242)

at
javax.xml.parsers.SAXParser.parse(SAXParser.java:375)
at
>>
>> org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl. java:181)
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLRes ourceImpl.java:180)
>>
>> at
>> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1444)
>>
>> at
>> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1240)
>>
>> at
>> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo ad(ResourceSetImpl.java:255)

at
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo adHelper(ResourceSetImpl.java:270)

at
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:397)

at
org.eclipse.emf.internal.workfflow.launcher.WorkflowLaunchCo nfigurationDelegate.launch(WorkflowLaunchConfigurationDelega te.java:47)

at
org.eclipse.debug.internal.core.LaunchConfiguration.launch(L aunchConfiguration.java:860)

at
org.eclipse.debug.internal.core.LaunchConfiguration.launch(L aunchConfiguration.java:710)

at
org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(D ebugUIPlugin.java:866)

at
org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlu gin.java:1069)

at
>>
>> org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
>>
>
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
> <html>
> <head>
> <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
> </head>
> <body bgcolor="#ffffff" text="#000000">
> Bryan,<br>
> <br>
> Are you using an extended metadata option?<br>
> <blockquote><small>&nbsp; public EClassifier getType(EFactory eFactory,
> String typeName)</small><br>
> <small>&nbsp; {</small><br>
> <small>&nbsp;&nbsp;&nbsp; if (eFactory != null)</small><br>
> <small>&nbsp;&nbsp;&nbsp; {</small><br>
> <small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; EPackage ePackage =
> eFactory.getEPackage();</small><br>
> <small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (extendedMetaData !=
> null)</small><br>
> <small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</small><br>
> <small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; return
> extendedMetaData.getType(ePackage, typeName);</small><br>
> <small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</small><br>
> <small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else</small><br>
> <small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</small><br>
> <small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; EClass eClass =
> (EClass)ePackage.getEClassifier(typeName);</small><br>
> <small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; if (eClass == null
> &amp;&amp; xmlMap != null)</small><br>
> <small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; {</small><br>
> <small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return
> xmlMap.getClassifier(ePackage.getNsURI(),
> typeName);</small><br>
> <small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; }</small><br>
> <small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; return eClass;</small><br>
> <small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</small><br>
> <small>&nbsp;&nbsp;&nbsp; }</small><br>
> <small>&nbsp;&nbsp;&nbsp; return null;</small><br>
> <small>&nbsp; }</small><br>
> </blockquote>
> The cast to EClass seems kind of pointless here, but later where the is
> used, the extended metadata issues arises again.<br>
> <blockquote><small>&nbsp; public EObject createObject(EFactory eFactory,
> EClassifier type)<br>
> &nbsp; {<br>
> &nbsp;&nbsp;&nbsp; EObject newObject = null;<br>
> &nbsp;&nbsp;&nbsp; if (eFactory != null)<br>
> &nbsp;&nbsp;&nbsp; {<br>
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (extendedMetaData != null)<br>
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; if (type == null)<br>
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; {<br>
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return null;<br>
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; }<br>
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; else if (type instanceof EClass)<br>
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; {<br>
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; newObject =
> eFactory.create((EClass)type);<br>
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; }<br>
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; else<br>
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; {<br>
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; SimpleAnyType result =
> (SimpleAnyType)EcoreUtil.create(anySimpleType);<br>
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
> result.setInstanceType((EDataType)type);<br>
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; newObject = result;<br>
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; }<br>
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else<br>
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; if (type != null)<br>
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; {<br>
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; newObject =
> eFactory.create((EClass)type);<br>
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; }<br>
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
> &nbsp;&nbsp;&nbsp; }<br>
> &nbsp;&nbsp;&nbsp; return newObject;<br>
> &nbsp; }</small><br>
> </blockquote>
> <br>
> Bryan Hunt wrote:
> <blockquote cite="mid:ggvsq9$ufu$1@build.eclipse.org" type="cite">I've
> modified my workflow editor to allow the creation of a SimpleAnyType,
> and I've run into a problem re-loading the model after specifying the
> Instance Type and Value attributes.&nbsp; See the exception trace below.&nbsp;
> I'm setting&nbsp; (using the properties editor) Instance Type to EString,
> and Value to Hello.&nbsp; I'm leaving the other attributes blank.&nbsp;
> Do I need
> to do anything with the Any or Any Attribute attributes?
> <br>
> <br>
> This exception occurs when I try to bring up the model in the editor
> and it has a SimpleAnyType with Instance Type and Value set as
> described above.
> <br>
> <br>
> java.lang.ClassCastException: org.eclipse.emf.ecore.impl.EDataTypeImpl
> <br>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.getType(XMLHelp erImpl.java:903)
> <br>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.createObject(XM LHelperImpl.java:920)

>
> <br>
> at <br>
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectFromFa ctory(XMLHandler.java:2171)

>
> <br>
> at <br>
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectFromTy peName(XMLHandler.java:2081)

>
> <br>
> at <br>
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObject(XMLHa ndler.java:2016)
> <br>
> at
> org.eclipse.emf.ecore.xmi.impl.XMIHandler.createObject(XMIHa ndler.java:131)
> <br>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleFeature(XMLH andler.java:1825)
> <br>
> at <br>
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XML Handler.java:1023)
> <br>
> at
> org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMI Handler.java:87)
> <br>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:1001)
> <br>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:712)
> <br>
> at
> org.eclipse.emf.ecore.xmi.impl.XMIHandler.startElement(XMIHa ndler.java:167)
> <br>
> at
> com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .startElement(AbstractSAXParser.java:533)

>
> <br>
> at <br>
> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.j ava:878)

>
> <br>
> at <br>
> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFra gmentScannerImpl.java:1693)

>
> <br>
> at <br>
> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java: 368)

>
> <br>
> at <br>
> com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(XML11Configuration.java:834)

>
> <br>
> at <br>
> com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(XML11Configuration.java:764)

>
> <br>
> at <br>
> com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(X MLParser.java:148)
> <br>
> at
> com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .parse(AbstractSAXParser.java:1242)

>
> <br>
> at <br>
> javax.xml.parsers.SAXParser.parse(SAXParser.java:375)
> <br>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl. java:181)
> <br>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLRes ourceImpl.java:180)
> <br>
> at <br>
> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1444)
> <br>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1240)
> <br>
> at <br>
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo ad(ResourceSetImpl.java:255)

>
> <br>
> at <br>
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo adHelper(ResourceSetImpl.java:270)

>
> <br>
> at <br>
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:397)

>
> <br>
> at <br>
> org.eclipse.emf.internal.workfflow.launcher.WorkflowLaunchCo nfigurationDelegate.launch(WorkflowLaunchConfigurationDelega te.java:47)

>
> <br>
> at <br>
> org.eclipse.debug.internal.core.LaunchConfiguration.launch(L aunchConfiguration.java:860)

>
> <br>
> at <br>
> org.eclipse.debug.internal.core.LaunchConfiguration.launch(L aunchConfiguration.java:710)

>
> <br>
> at <br>
> org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(D ebugUIPlugin.java:866)

>
> <br>
> at <br>
> org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlu gin.java:1069)
> <br>
> at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
> <br>
> <br>
> </blockquote>
> </body>
> </html>
Re: Problem using SimpleAnyType [message #425592 is a reply to message #425591] Tue, 02 December 2008 18:36 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Bryan,

Comments below.

Bryan Hunt wrote:
> Ed,
>
> I'm not sure what the extended metadata option is, so let's assume for
> now the answer is: no, I'm not using the extended metadata option.
/**
* This option allows you to tailor the XML serialization of objects.
* You should provide an ExtendedMetaData as the value of this option.
* @see org.eclipse.emf.ecore.util.BasicExtendedMetaData
*/
String OPTION_EXTENDED_META_DATA = "EXTENDED_META_DATA";

You can provide Boolean.TRUE as well to let it create the right instance
and you need that for both load and save.
> I think I might have found the problem ... when I set the value of the
> parameter map entry, the model is serialized as follows:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <org.eclipse.emf.workflow.runtime:WorkflowContext xmi:version="2.0"
> xmlns:xmi="http://www.omg.org/XMI"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
> xmlns:org.eclipse.emf.workflow.runtime="http://www.eclipse.org/emf/workflow/runtime.ecore">
>
>
>
> <parameters>
> <value xsi:type="ecore:EString">
> Hello <instanceType
> href="http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> </value>
Yes, that's no good.
> </parameters>
> </org.eclipse.emf.workflow.runtime:WorkflowContext>
>
> It seems that SimpleAnyType is not being serialized correctly. Why is
> the value type EString?
It's supposed to serialize like <value
xsi:type="ecore:EString">Hello</value>
> Shouldn't it be SimpleAnyType?
No, that part's "implicit". I.e., when the xsi:type refers to an
EClassifier that is an EDataType, and instance of SimpleAnyType will be
created.
> Does this look incorrect to you?
No, you'll need to use the extended meta data option as a load and a
save option.
> Since I've never used SimpleAnyType, I'm not sure what to expect when
> it gets serialized.
>
> Bryan
>
> On 2008-12-01 05:24:36 -0600, Ed Merks <Ed.Merks@gmail.com> said:
>
>>
>> Bryan,
>>
>> Are you using an extended metadata option?
>>
>> public EClassifier getType(EFactory eFactory, String typeName)
>> {
>> if (eFactory != null)
>> {
>> EPackage ePackage = eFactory.getEPackage();
>> if (extendedMetaData != null)
>> {
>> return extendedMetaData.getType(ePackage, typeName);
>> }
>> else
>> {
>> EClass eClass = (EClass)ePackage.getEClassifier(typeName);
>> if (eClass == null && xmlMap != null)
>> {
>> return xmlMap.getClassifier(ePackage.getNsURI(),
>> typeName);
>> }
>> return eClass;
>> }
>> }
>> return null;
>> }
>>
>> The cast to EClass seems kind of pointless here, but later where the is
>> used, the extended metadata issues arises again.
>>
>> public EObject createObject(EFactory eFactory, EClassifier type)
>> {
>> EObject newObject = null;
>> if (eFactory != null)
>> {
>> if (extendedMetaData != null)
>> {
>> if (type == null)
>> {
>> return null;
>> }
>> else if (type instanceof EClass)
>> {
>> newObject = eFactory.create((EClass)type);
>> }
>> else
>> {
>> SimpleAnyType result =
>> (SimpleAnyType)EcoreUtil.create(anySimpleType);
>> result.setInstanceType((EDataType)type);
>> newObject = result;
>> }
>> }
>> else
>> {
>> if (type != null)
>> {
>> newObject = eFactory.create((EClass)type);
>> }
>> }
>> }
>> return newObject;
>> }
>>
>>
>> Bryan Hunt wrote:
>>> I've modified my workflow editor to allow the creation of a
>>> SimpleAnyType, and I've run into a problem re-loading the model after
>>> specifying the Instance Type and Value attributes. See the exception
>>> trace below. I'm setting (using the properties editor) Instance Type
>>> to EString, and Value to Hello. I'm leaving the other attributes
>>> blank. Do I need to do anything with the Any or Any Attribute
>>> attributes?
>>>
>>> This exception occurs when I try to bring up the model in the editor
>>> and it has a SimpleAnyType with Instance Type and Value set as
>>> described above.
>>>
>>> java.lang.ClassCastException: org.eclipse.emf.ecore.impl.EDataTypeImpl
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.getType(XMLHelp erImpl.java:903)
>>>
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.createObject(XM LHelperImpl.java:920)
>>>
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectFromFa ctory(XMLHandler.java:2171)
>
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectFromTy peName(XMLHandler.java:2081)
>
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObject(XMLHa ndler.java:2016)
>
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMIHandler.createObject(XMIHa ndler.java:131)
>
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleFeature(XMLH andler.java:1825)
>
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XML Handler.java:1023)
>
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMI Handler.java:87)
>
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:1001)
>
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:712)
>
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMIHandler.startElement(XMIHa ndler.java:167)
>
>
> at
> com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .startElement(AbstractSAXParser.java:533)
>
>
> at
> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.j ava:878)
>
>
> at
> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFra gmentScannerImpl.java:1693)
>
>
> at
> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java: 368)
>
>
> at
> com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(XML11Configuration.java:834)
>
>
> at
> com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(XML11Configuration.java:764)
>
>
> at
> com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(X MLParser.java:148)
>
>
> at
> com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .parse(AbstractSAXParser.java:1242)
>
>
> at
> javax.xml.parsers.SAXParser.parse(SAXParser.java:375)
> at
>>>
>>> org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl. java:181)
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLRes ourceImpl.java:180)
>>>
>>>
>>> at
>>> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1444)
>>>
>>>
>>> at
>>> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1240)
>>>
>>>
>>> at
>>> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo ad(ResourceSetImpl.java:255)
>>>
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo adHelper(ResourceSetImpl.java:270)
>
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:397)
>
>
> at
> org.eclipse.emf.internal.workfflow.launcher.WorkflowLaunchCo nfigurationDelegate.launch(WorkflowLaunchConfigurationDelega te.java:47)
>
>
> at
> org.eclipse.debug.internal.core.LaunchConfiguration.launch(L aunchConfiguration.java:860)
>
>
> at
> org.eclipse.debug.internal.core.LaunchConfiguration.launch(L aunchConfiguration.java:710)
>
>
> at
> org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(D ebugUIPlugin.java:866)
>
>
> at
> org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlu gin.java:1069)
>
>
> at
>>>
>>> org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
>>>
>>
>>
>> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
>> <html>
>> <head>
>> <meta content="text/html;charset=ISO-8859-1"
>> http-equiv="Content-Type">
>> </head>
>> <body bgcolor="#ffffff" text="#000000">
>> Bryan,<br>
>> <br>
>> Are you using an extended metadata option?<br>
>> <blockquote><small>&nbsp; public EClassifier getType(EFactory eFactory,
>> String typeName)</small><br>
>> <small>&nbsp; {</small><br>
>> <small>&nbsp;&nbsp;&nbsp; if (eFactory != null)</small><br>
>> <small>&nbsp;&nbsp;&nbsp; {</small><br>
>> <small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; EPackage ePackage =
>> eFactory.getEPackage();</small><br>
>> <small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (extendedMetaData !=
>> null)</small><br>
>> <small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</small><br>
>> <small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; return
>> extendedMetaData.getType(ePackage, typeName);</small><br>
>> <small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</small><br>
>> <small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else</small><br>
>> <small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</small><br>
>> <small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; EClass eClass =
>> (EClass)ePackage.getEClassifier(typeName);</small><br>
>> <small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; if (eClass ==
>> null &amp;&amp; xmlMap != null)</small><br>
>> <small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; {</small><br>
>> <small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
>> return xmlMap.getClassifier(ePackage.getNsURI(),
>> typeName);</small><br>
>> <small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; }</small><br>
>> <small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; return
>> eClass;</small><br>
>> <small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</small><br>
>> <small>&nbsp;&nbsp;&nbsp; }</small><br>
>> <small>&nbsp;&nbsp;&nbsp; return null;</small><br>
>> <small>&nbsp; }</small><br>
>> </blockquote>
>> The cast to EClass seems kind of pointless here, but later where the is
>> used, the extended metadata issues arises again.<br>
>> <blockquote><small>&nbsp; public EObject createObject(EFactory eFactory,
>> EClassifier type)<br>
>> &nbsp; {<br>
>> &nbsp;&nbsp;&nbsp; EObject newObject = null;<br>
>> &nbsp;&nbsp;&nbsp; if (eFactory != null)<br>
>> &nbsp;&nbsp;&nbsp; {<br>
>> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (extendedMetaData != null)<br>
>> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
>> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; if (type == null)<br>
>> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; {<br>
>> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return null;<br>
>> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; }<br>
>> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; else if (type instanceof
>> EClass)<br>
>> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; {<br>
>> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; newObject =
>> eFactory.create((EClass)type);<br>
>> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; }<br>
>> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; else<br>
>> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; {<br>
>> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; SimpleAnyType
>> result =
>> (SimpleAnyType)EcoreUtil.create(anySimpleType);<br>
>> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
>> result.setInstanceType((EDataType)type);<br>
>> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; newObject =
>> result;<br>
>> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; }<br>
>> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
>> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else<br>
>> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
>> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; if (type != null)<br>
>> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; {<br>
>> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; newObject =
>> eFactory.create((EClass)type);<br>
>> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; }<br>
>> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
>> &nbsp;&nbsp;&nbsp; }<br>
>> &nbsp;&nbsp;&nbsp; return newObject;<br>
>> &nbsp; }</small><br>
>> </blockquote>
>> <br>
>> Bryan Hunt wrote:
>> <blockquote cite="mid:ggvsq9$ufu$1@build.eclipse.org" type="cite">I've
>> modified my workflow editor to allow the creation of a SimpleAnyType,
>> and I've run into a problem re-loading the model after specifying the
>> Instance Type and Value attributes.&nbsp; See the exception trace
>> below.&nbsp;
>> I'm setting&nbsp; (using the properties editor) Instance Type to
>> EString,
>> and Value to Hello.&nbsp; I'm leaving the other attributes
>> blank.&nbsp; Do I need
>> to do anything with the Any or Any Attribute attributes?
>> <br>
>> <br>
>> This exception occurs when I try to bring up the model in the editor
>> and it has a SimpleAnyType with Instance Type and Value set as
>> described above.
>> <br>
>> <br>
>> java.lang.ClassCastException: org.eclipse.emf.ecore.impl.EDataTypeImpl
>> <br>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.getType(XMLHelp erImpl.java:903)
>>
>> <br>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.createObject(XM LHelperImpl.java:920)
>>
>
>>
>> <br>
>> at <br>
>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectFromFa ctory(XMLHandler.java:2171)
>>
>
>>
>> <br>
>> at <br>
>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectFromTy peName(XMLHandler.java:2081)
>>
>
>>
>> <br>
>> at <br>
>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObject(XMLHa ndler.java:2016)
>>
>> <br>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMIHandler.createObject(XMIHa ndler.java:131)
>>
>> <br>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleFeature(XMLH andler.java:1825)
>>
>> <br>
>> at <br>
>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XML Handler.java:1023)
>>
>> <br>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMI Handler.java:87)
>>
>> <br>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:1001)
>>
>> <br>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:712)
>>
>> <br>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMIHandler.startElement(XMIHa ndler.java:167)
>>
>> <br>
>> at
>> com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .startElement(AbstractSAXParser.java:533)
>>
>
>>
>> <br>
>> at <br>
>> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.j ava:878)
>>
>
>>
>> <br>
>> at <br>
>> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFra gmentScannerImpl.java:1693)
>>
>
>>
>> <br>
>> at <br>
>> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java: 368)
>>
>
>>
>> <br>
>> at <br>
>> com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(XML11Configuration.java:834)
>>
>
>>
>> <br>
>> at <br>
>> com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(XML11Configuration.java:764)
>>
>
>>
>> <br>
>> at <br>
>> com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(X MLParser.java:148)
>>
>> <br>
>> at
>> com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .parse(AbstractSAXParser.java:1242)
>>
>
>>
>> <br>
>> at <br>
>> javax.xml.parsers.SAXParser.parse(SAXParser.java:375)
>> <br>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl. java:181)
>> <br>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLRes ourceImpl.java:180)
>>
>> <br>
>> at <br>
>> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1444)
>>
>> <br>
>> at
>> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1240)
>>
>> <br>
>> at <br>
>> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo ad(ResourceSetImpl.java:255)
>>
>
>>
>> <br>
>> at <br>
>> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo adHelper(ResourceSetImpl.java:270)
>>
>
>>
>> <br>
>> at <br>
>> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:397)
>>
>
>>
>> <br>
>> at <br>
>> org.eclipse.emf.internal.workfflow.launcher.WorkflowLaunchCo nfigurationDelegate.launch(WorkflowLaunchConfigurationDelega te.java:47)
>>
>
>>
>> <br>
>> at <br>
>> org.eclipse.debug.internal.core.LaunchConfiguration.launch(L aunchConfiguration.java:860)
>>
>
>>
>> <br>
>> at <br>
>> org.eclipse.debug.internal.core.LaunchConfiguration.launch(L aunchConfiguration.java:710)
>>
>
>>
>> <br>
>> at <br>
>> org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(D ebugUIPlugin.java:866)
>>
>
>>
>> <br>
>> at <br>
>> org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlu gin.java:1069)
>>
>> <br>
>> at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
>> <br>
>> <br>
>> </blockquote>
>> </body>
>> </html>
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Problem using SimpleAnyType [message #425597 is a reply to message #425592] Wed, 03 December 2008 03:08 Go to previous message
Bryan Hunt is currently offline Bryan HuntFriend
Messages: 366
Registered: July 2009
Senior Member
Ed,

That fixed my problem. I have my "Hello workflow world" tutorial
working using SimpleAnyType as parameter values.

Thanks!

Bryan

On 2008-12-02 12:36:02 -0600, Ed Merks <Ed.Merks@gmail.com> said:

> Bryan,
>
> Comments below.
>
> Bryan Hunt wrote:
>> Ed,
>>
>> I'm not sure what the extended metadata option is, so let's assume for
>> now the answer is: no, I'm not using the extended metadata option.
> /**
> * This option allows you to tailor the XML serialization of objects.
> * You should provide an ExtendedMetaData as the value of this option.
> * @see org.eclipse.emf.ecore.util.BasicExtendedMetaData
> */
> String OPTION_EXTENDED_META_DATA = "EXTENDED_META_DATA";
>
> You can provide Boolean.TRUE as well to let it create the right
> instance and you need that for both load and save.
>> I think I might have found the problem ... when I set the value of the
>> parameter map entry, the model is serialized as follows:
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <org.eclipse.emf.workflow.runtime:WorkflowContext xmi:version="2.0"
>> xmlns:xmi="http://www.omg.org/XMI"
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
>> xmlns:org.eclipse.emf.workflow.runtime="http://www.eclipse.org/emf/workflow/runtime.ecore">


<parameters>

>>
>> <value xsi:type="ecore:EString">
>> Hello <instanceType
>> href="http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>> </value>
> Yes, that's no good.
>> </parameters>
>> </org.eclipse.emf.workflow.runtime:WorkflowContext>
>>
>> It seems that SimpleAnyType is not being serialized correctly. Why is
>> the value type EString?
> It's supposed to serialize like <value xsi:type="ecore:EString">Hello</value>
>> Shouldn't it be SimpleAnyType?
> No, that part's "implicit". I.e., when the xsi:type refers to an
> EClassifier that is an EDataType, and instance of SimpleAnyType will be
> created.
>> Does this look incorrect to you?
> No, you'll need to use the extended meta data option as a load and a
> save option.
>> Since I've never used SimpleAnyType, I'm not sure what to expect when
>> it gets serialized.
>>
>> Bryan
>>
>> On 2008-12-01 05:24:36 -0600, Ed Merks <Ed.Merks@gmail.com> said:
>>
>>>
>>> Bryan,
>>>
>>> Are you using an extended metadata option?
>>>
>>> public EClassifier getType(EFactory eFactory, String typeName)
>>> {
>>> if (eFactory != null)
>>> {
>>> EPackage ePackage = eFactory.getEPackage();
>>> if (extendedMetaData != null)
>>> {
>>> return extendedMetaData.getType(ePackage, typeName);
>>> }
>>> else
>>> {
>>> EClass eClass = (EClass)ePackage.getEClassifier(typeName);
>>> if (eClass == null && xmlMap != null)
>>> {
>>> return xmlMap.getClassifier(ePackage.getNsURI(), typeName);
>>> }
>>> return eClass;
>>> }
>>> }
>>> return null;
>>> }
>>>
>>> The cast to EClass seems kind of pointless here, but later where the is
>>> used, the extended metadata issues arises again.
>>>
>>> public EObject createObject(EFactory eFactory, EClassifier type)
>>> {
>>> EObject newObject = null;
>>> if (eFactory != null)
>>> {
>>> if (extendedMetaData != null)
>>> {
>>> if (type == null)
>>> {
>>> return null;
>>> }
>>> else if (type instanceof EClass)
>>> {
>>> newObject = eFactory.create((EClass)type);
>>> }
>>> else
>>> {
>>> SimpleAnyType result =
>>> (SimpleAnyType)EcoreUtil.create(anySimpleType);
>>> result.setInstanceType((EDataType)type);
>>> newObject = result;
>>> }
>>> }
>>> else
>>> {
>>> if (type != null)
>>> {
>>> newObject = eFactory.create((EClass)type);
>>> }
>>> }
>>> }
>>> return newObject;
>>> }
>>>
>>>
>>> Bryan Hunt wrote:
>>>> I've modified my workflow editor to allow the creation of a
>>>> SimpleAnyType, and I've run into a problem re-loading the model after
>>>> specifying the Instance Type and Value attributes. See the exception
>>>> trace below. I'm setting (using the properties editor) Instance Type
>>>> to EString, and Value to Hello. I'm leaving the other attributes
>>>> blank. Do I need to do anything with the Any or Any Attribute
>>>> attributes?
>>>>
>>>> This exception occurs when I try to bring up the model in the editor
>>>> and it has a SimpleAnyType with Instance Type and Value set as
>>>> described above.
>>>>
>>>> java.lang.ClassCastException: org.eclipse.emf.ecore.impl.EDataTypeImpl
>>>> at
>>>> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.getType(XMLHelp erImpl.java:903)
>>>>
>>>> at
>>>> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.createObject(XM LHelperImpl.java:920)

at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectFromFa ctory(XMLHandler.java:2171)

at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectFromTy peName(XMLHandler.java:2081)

at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObject(XMLHa ndler.java:2016)

at
org.eclipse.emf.ecore.xmi.impl.XMIHandler.createObject(XMIHa ndler.java:131)

at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleFeature(XMLH andler.java:1825)

at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XML Handler.java:1023)

at
org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMI Handler.java:87)

at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:1001)

at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:712)

at
org.eclipse.emf.ecore.xmi.impl.XMIHandler.startElement(XMIHa ndler.java:167)

at
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .startElement(AbstractSAXParser.java:533)

at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.j ava:878)

at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFra gmentScannerImpl.java:1693)

at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java: 368)

at
com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(XML11Configuration.java:834)

at
com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(XML11Configuration.java:764)

at
com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(X MLParser.java:148)

at
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .parse(AbstractSAXParser.java:1242)

at
javax.xml.parsers.SAXParser.parse(SAXParser.java:375)
at

org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl. java:181)
at
org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLRes ourceImpl.java:180)

at
org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1444)

at
org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1240)

at
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo ad(ResourceSetImpl.java:255)

at
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo adHelper(ResourceSetImpl.java:270)

at
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:397)

at
org.eclipse.emf.internal.workfflow.launcher.WorkflowLaunchCo nfigurationDelegate.launch(WorkflowLaunchConfigurationDelega te.java:47)

at
org.eclipse.debug.internal.core.LaunchConfiguration.launch(L aunchConfiguration.java:860)

at
org.eclipse.debug.internal.core.LaunchConfiguration.launch(L aunchConfiguration.java:710)

at
org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(D ebugUIPlugin.java:866)

at
org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlu gin.java:1069)

at

org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)



<!DOCTYPE
>>>>
>>> html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
>>> <html>
>>> <head>
>>> <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
>>> </head>
>>> <body bgcolor="#ffffff" text="#000000">
>>> Bryan,<br>
>>> <br>
>>> Are you using an extended metadata option?<br>
>>> <blockquote><small>&nbsp; public EClassifier getType(EFactory eFactory,
>>> String typeName)</small><br>
>>> <small>&nbsp; {</small><br>
>>> <small>&nbsp;&nbsp;&nbsp; if (eFactory != null)</small><br>
>>> <small>&nbsp;&nbsp;&nbsp; {</small><br>
>>> <small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; EPackage ePackage =
>>> eFactory.getEPackage();</small><br>
>>> <small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (extendedMetaData !=
>>> null)</small><br>
>>> <small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</small><br>
>>> <small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; return
>>> extendedMetaData.getType(ePackage, typeName);</small><br>
>>> <small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</small><br>
>>> <small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else</small><br>
>>> <small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</small><br>
>>> <small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; EClass eClass =
>>> (EClass)ePackage.getEClassifier(typeName);</small><br>
>>> <small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; if (eClass == null
>>> &amp;&amp; xmlMap != null)</small><br>
>>> <small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; {</small><br>
>>> <small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return
>>> xmlMap.getClassifier(ePackage.getNsURI(),
>>> typeName);</small><br>
>>> <small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; }</small><br>
>>> <small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; return eClass;</small><br>
>>> <small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</small><br>
>>> <small>&nbsp;&nbsp;&nbsp; }</small><br>
>>> <small>&nbsp;&nbsp;&nbsp; return null;</small><br>
>>> <small>&nbsp; }</small><br>
>>> </blockquote>
>>> The cast to EClass seems kind of pointless here, but later where the is
>>> used, the extended metadata issues arises again.<br>
>>> <blockquote><small>&nbsp; public EObject createObject(EFactory eFactory,
>>> EClassifier type)<br>
>>> &nbsp; {<br>
>>> &nbsp;&nbsp;&nbsp; EObject newObject = null;<br>
>>> &nbsp;&nbsp;&nbsp; if (eFactory != null)<br>
>>> &nbsp;&nbsp;&nbsp; {<br>
>>> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (extendedMetaData != null)<br>
>>> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
>>> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; if (type == null)<br>
>>> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; {<br>
>>> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return null;<br>
>>> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; }<br>
>>> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; else if (type instanceof EClass)<br>
>>> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; {<br>
>>> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; newObject =
>>> eFactory.create((EClass)type);<br>
>>> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; }<br>
>>> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; else<br>
>>> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; {<br>
>>> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; SimpleAnyType result =
>>> (SimpleAnyType)EcoreUtil.create(anySimpleType);<br>
>>> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
>>> result.setInstanceType((EDataType)type);<br>
>>> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; newObject = result;<br>
>>> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; }<br>
>>> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
>>> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else<br>
>>> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
>>> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; if (type != null)<br>
>>> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; {<br>
>>> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; newObject =
>>> eFactory.create((EClass)type);<br>
>>> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; }<br>
>>> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
>>> &nbsp;&nbsp;&nbsp; }<br>
>>> &nbsp;&nbsp;&nbsp; return newObject;<br>
>>> &nbsp; }</small><br>
>>> </blockquote>
>>> <br>
>>> Bryan Hunt wrote:
>>> <blockquote cite="mid:ggvsq9$ufu$1@build.eclipse.org" type="cite">I've
>>> modified my workflow editor to allow the creation of a SimpleAnyType,
>>> and I've run into a problem re-loading the model after specifying the
>>> Instance Type and Value attributes.&nbsp; See the exception trace below.&nbsp;
>>> I'm setting&nbsp; (using the properties editor) Instance Type to EString,
>>> and Value to Hello.&nbsp; I'm leaving the other attributes blank.&nbsp;
>>> Do I need
>>> to do anything with the Any or Any Attribute attributes?
>>> <br>
>>> <br>
>>> This exception occurs when I try to bring up the model in the editor
>>> and it has a SimpleAnyType with Instance Type and Value set as
>>> described above.
>>> <br>
>>> <br>
>>> java.lang.ClassCastException: org.eclipse.emf.ecore.impl.EDataTypeImpl
>>> <br>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.getType(XMLHelp erImpl.java:903)
>>> <br>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.createObject(XM LHelperImpl.java:920)



>>>
>>> <br>
>>> at <br>
>>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectFromFa ctory(XMLHandler.java:2171)



>>>
>>> <br>
>>> at <br>
>>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectFromTy peName(XMLHandler.java:2081)



>>>
>>> <br>
>>> at <br>
>>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObject(XMLHa ndler.java:2016)
>>> <br>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMIHandler.createObject(XMIHa ndler.java:131)
>>> <br>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleFeature(XMLH andler.java:1825)
>>> <br>
>>> at <br>
>>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XML Handler.java:1023)
>>> <br>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMI Handler.java:87)
>>> <br>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:1001)
>>> <br>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:712)
>>> <br>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMIHandler.startElement(XMIHa ndler.java:167)
>>> <br>
>>> at
>>> com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .startElement(AbstractSAXParser.java:533)



>>>
>>> <br>
>>> at <br>
>>> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.j ava:878)



>>>
>>> <br>
>>> at <br>
>>> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFra gmentScannerImpl.java:1693)



>>>
>>> <br>
>>> at <br>
>>> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java: 368)



>>>
>>> <br>
>>> at <br>
>>> com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(XML11Configuration.java:834)



>>>
>>> <br>
>>> at <br>
>>> com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(XML11Configuration.java:764)



>>>
>>> <br>
>>> at <br>
>>> com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(X MLParser.java:148)
>>> <br>
>>> at
>>> com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .parse(AbstractSAXParser.java:1242)



>>>
>>> <br>
>>> at <br>
>>> javax.xml.parsers.SAXParser.parse(SAXParser.java:375)
>>> <br>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl. java:181)
>>> <br>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLRes ourceImpl.java:180)
>>> <br>
>>> at <br>
>>> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1444)
>>> <br>
>>> at
>>> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1240)
>>> <br>
>>> at <br>
>>> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo ad(ResourceSetImpl.java:255)



>>>
>>> <br>
>>> at <br>
>>> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo adHelper(ResourceSetImpl.java:270)



>>>
>>> <br>
>>> at <br>
>>> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:397)



>>>
>>> <br>
>>> at <br>
>>> org.eclipse.emf.internal.workfflow.launcher.WorkflowLaunchCo nfigurationDelegate.launch(WorkflowLaunchConfigurationDelega te.java:47)



>>>
>>> <br>
>>> at <br>
>>> org.eclipse.debug.internal.core.LaunchConfiguration.launch(L aunchConfiguration.java:860)



>>>
>>> <br>
>>> at <br>
>>> org.eclipse.debug.internal.core.LaunchConfiguration.launch(L aunchConfiguration.java:710)



>>>
>>> <br>
>>> at <br>
>>> org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(D ebugUIPlugin.java:866)



>>>
>>> <br>
>>> at <br>
>>> org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlu gin.java:1069)
>>> <br>
>>> at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
>>> <br>
>>> <br>
>>> </blockquote>
>>> </body>
>>> </html>
Previous Topic:Retrieve ItemProvider based on the EClass
Next Topic:XPAth Syntax - /@defines.1/@defines....
Goto Forum:
  


Current Time: Sat Apr 20 01:06:57 GMT 2024

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

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

Back to the top