Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » NumberFormatException specifying hex
NumberFormatException specifying hex [message #417717] Mon, 24 March 2008 14:06 Go to next message
Andy Emmett is currently offline Andy EmmettFriend
Messages: 9
Registered: July 2009
Junior Member
Hi All

I am Wondering if anyone knows how to specify a hex value for an enum.
I am using eclipse 3.3

When I use the emf editor, I see a NumberFormatException when entering the
value. Is there some special syntax or is this perpahs already fixed in
3.3.1.1 ?


I also tried to import some annotated code like the following...


public enum MYENUM implements Enumerator {

/**
* @model
*/
public static final int MYENUM_GOOD = 0x00000000;


/**
* @model
*/
public static final int MYENUM_BAD = 0xDEADBEEF;

}



this would work when i used classes, as in ....


public class MYENUM extends AbstractEnumerator {

/**
* @model
*/
public static final int MYENUM_GOOD = 0x00000000;


/**
* @model
*/
public static final int MYENUM_BAD = 0xDEADBEEF;

}
Re: NumberFormatException specifying hex [message #417720 is a reply to message #417717] Mon, 24 March 2008 15:04 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Andy,

You could open a bug so that we accept things other than decimal
literals in annotated Java, but in general, when we generate code, we'll
still generate a decimal integer value. You could include a
documentation annotation to describe the value in a way that will show
up in the generated Javadoc as a hexadecimal value..


Andy wrote:
> Hi All
>
> I am Wondering if anyone knows how to specify a hex value for an enum.
> I am using eclipse 3.3
>
> When I use the emf editor, I see a NumberFormatException when entering
> the value. Is there some special syntax or is this perpahs already
> fixed in 3.3.1.1 ?
>
>
> I also tried to import some annotated code like the following...
>
>
> public enum MYENUM implements Enumerator {
>
> /**
> * @model
> */
> public static final int MYENUM_GOOD = 0x00000000;
>
>
> /**
> * @model
> */
> public static final int MYENUM_BAD = 0xDEADBEEF;
>
> }
>
>
>
> this would work when i used classes, as in ....
>
>
> public class MYENUM extends AbstractEnumerator {
>
> /**
> * @model
> */
> public static final int MYENUM_GOOD = 0x00000000;
>
>
> /**
> * @model
> */
> public static final int MYENUM_BAD = 0xDEADBEEF;
>
> }
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: NumberFormatException specifying hex [message #417721 is a reply to message #417720] Mon, 24 March 2008 18:48 Go to previous message
Andy Emmett is currently offline Andy EmmettFriend
Messages: 9
Registered: July 2009
Junior Member
Ed,
Thanks very much for your prompt reply.

The reason I wanted to do this, is because I am parsing many c header
files to generate the annotated java files (with the @model tags), and
some of them have hex values for #define.

The number of files I have is significant to not want to convert
(appreciate I could do this in my c app), so this was useful to me when
implementing AbstractEnumerator for my class type enums previously.

I will therefore open a Bug report.

Thanks again and many regards,
Andy
Previous Topic:no Ns-Uri is generated
Next Topic:Selection order in tree-based EMF editors
Goto Forum:
  


Current Time: Wed Apr 24 22:46:38 GMT 2024

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

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

Back to the top