Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » How to obtain an instanceClass from an EENum?
How to obtain an instanceClass from an EENum? [message #394096] Sat, 02 July 2005 20:21 Go to next message
Koen van Dijken is currently offline Koen van DijkenFriend
Messages: 67
Registered: July 2009
Member
I am using XSDEcoreBuilder.getEDataType() to obtain a EDataType which
represents an enumerated type in an XSD type definition. This returns an
EEnum. I would like to know its base type (for example String, integer,
double) but I do not know how. For not enumerated types I use
getInstanceClass() which works fine. The EEnum which is returned however has
its instanceClass == null.

I can obtain the base type from the XSD typedefinition by calling its
getRootTypeDefinition().getName(), but then I still only have a XML typename
yet, not a Java class. Also, I really want to get to know the basetype from
the EDataType as this is the only item which is carried around in my
process.

When I generate a Ecore model from an XSD with an xsd:integer enumeration in
it, the resulting class with an attribute of this type knows the enumeration
is of type BigInteger. The ecore code generator can do it (although I'm not
sure it uses XSDEcoreBuilder), so I must be able to do it as well.

The only way I can think of, is to ask any literal of this enum for its
instance, and get the type from that instance, but there must be some better
way (this would also fail with an enumeration without any values, quite
useless, but still).

Koen
Re: How to obtain an instanceClass from an EENum? [message #394133 is a reply to message #394096] Tue, 05 July 2005 14:36 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
Koen,

When an EEnum is generated from an simple type with an enumeration
restriction, which happens only if all the values are valid Java
identifiers, the base type is not reused at all and so is not
recorded. Instances of the enum would not be compatible with the base
type anyway, i.e., an enumerator instance of the EEnum won't be a String
or any other type. Since integer value (BigInteger values) can never be
a valid Java identifier, when that's the base type, you don't get an
EEnum, you just get a restricted type where
ExtendedMetaData.INSTANCE.getEnumerationFacet allows you to see the
enumerated values. In general, you can use
ExtendedMetaData.INSTANCE.getBaseType to determine the base type of an
EDataType, but in the case of an EEnum, this too will be null. It
sounds like you are trying to do something that can't be done (and that
hopefully you don't need to do).


Koen van Dijken wrote:

>I am using XSDEcoreBuilder.getEDataType() to obtain a EDataType which
>represents an enumerated type in an XSD type definition. This returns an
>EEnum. I would like to know its base type (for example String, integer,
>double) but I do not know how. For not enumerated types I use
>getInstanceClass() which works fine. The EEnum which is returned however has
>its instanceClass == null.
>
>I can obtain the base type from the XSD typedefinition by calling its
>getRootTypeDefinition().getName(), but then I still only have a XML typename
>yet, not a Java class. Also, I really want to get to know the basetype from
>the EDataType as this is the only item which is carried around in my
>process.
>
>When I generate a Ecore model from an XSD with an xsd:integer enumeration in
>it, the resulting class with an attribute of this type knows the enumeration
>is of type BigInteger. The ecore code generator can do it (although I'm not
>sure it uses XSDEcoreBuilder), so I must be able to do it as well.
>
>The only way I can think of, is to ask any literal of this enum for its
>instance, and get the type from that instance, but there must be some better
>way (this would also fail with an enumeration without any values, quite
>useless, but still).
>
>Koen
>
>
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Mixing static/dynamic EMF model
Next Topic:NullPointerException for handleDanglingHREF
Goto Forum:
  


Current Time: Fri Apr 26 04:22:03 GMT 2024

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

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

Back to the top