You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xmlbeans.apache.org by "Green, Jason M." <ja...@ngc.com> on 2007/07/17 14:48:21 UTC
Enumerated types base index
Hey all,
I have been attempting to use the Enum.forInt method for some of my
enumerated types. I am passing in a value that is provided in a text
file. Often times the value is zero, but when I pass that in, I get a
XmlValueNotNillableException. I know what this means, but I am confused
as to why the enumerated values would start at 1 and not 0. In the
schema, there is obv no numberign associated. Since nearly every
language that I know of is 0 based, why would this be 1 based? Is there
a way to change this?
Thanks,
Jason
Re: Enumerated types base index
Posted by Jacob Danner <ja...@gmail.com>.
Hi Jason,
I'm not sure why this is the case, but if its really an issue, I think
you could modify the generated src or modify your index to start at
one.
static final int INT_FOO = 1;
static final int INT_BAZ = 2;
I've attached an example src file in case you wanted to peek at it.
I've never needed an Enum value to have a int val beginning at zero
switch(enumVal)
case Enum.INT_FOO:
doSomething();
break;
// ....
And so using this code, I do not need the enumeration value to be a
specific int. This also makes the code a little easier to read as
well.
Hope this helps,
-Jacob Danner
On 7/17/07, Green, Jason M. <ja...@ngc.com> wrote:
>
>
>
> Hey all,
> I have been attempting to use the Enum.forInt method for some of my
> enumerated types. I am passing in a value that is provided in a text file.
> Often times the value is zero, but when I pass that in, I get a
> XmlValueNotNillableException. I know what this means, but I am confused as
> to why the enumerated values would start at 1 and not 0. In the schema,
> there is obv no numberign associated. Since nearly every language that I
> know of is 0 based, why would this be 1 based? Is there a way to change
> this?
>
> Thanks,
>
> Jason