users@jaxb.java.net

enum problem in JAXB2 upgrade

From: Rochak Gupta <rochak005_at_gmail.com>
Date: Mon, 3 May 2010 16:46:58 +0530

Hi ,

 We are getting strange error while upgrading our code from JAXB1.x to
JAXB2.x .

Here

 <simpleType name="ReturnCode">

          <restriction base="string">

              <enumeration value="Mal-formed Input"/>

              <enumeration value="TN/CLS and SO combination is not found"/>

              <enumeration value="SO failed provisioning"/>

              <enumeration value="SO not found"/>

          </restriction>

     </simpleType>





In JAXB2.X Returncode enum type is created. I have used the decompiler and
pasted here

 *// Decompiled by DJ v3.7.7.81 Copyright 2004 Atanas Neshkov Date:
5/1/2010 3:21:30 PM*

*// Home Page : http://members.fortunecity.com/neshkov/dj.html - Check
often for new version!*

*// Decompiler options: packimports(3) *

*// Source File Name: ReturnCode.java*

 package com.bellsouth.snt.broadbandos.idm.xml.techaccess.schema;





public final class ReturnCode extends Enum

{



    public static ReturnCode[] values()

    {

        return (ReturnCode[])$VALUES.clone();

    }



    public static ReturnCode valueOf(String name)

    {

        return(ReturnCode)Enum.valueOf(com/bellsouth/snt/broadbandos/idm/xml/techaccess/schema/ReturnCode,
name);

    }



    private ReturnCode(String s, int i, String v)

    {

        super(s, i);

        value = v;

    }



    public String value()

    {

        return value;

    }



    public static ReturnCode fromValue(String v)

    {

        ReturnCode arr$[] = values();

        int len$ = arr$.length;

        for(int i$ = 0; i$ < len$; i$++)

        {

            ReturnCode c = arr$[i$];

            if(c.value.equals(v))

                return c;

        }



        throw new IllegalArgumentException(v);

    }



    public static final ReturnCode MAL_FORMED_INPUT;

    public static final ReturnCode TN_CLS_AND_SO_COMBINATION_IS_NOT_FOUND;

    public static final ReturnCode SO_FAILED_PROVISIONING;

    public static final ReturnCode SO_NOT_FOUND;

    private final String value;

    private static final ReturnCode $VALUES[];



    static

    {

        MAL_FORMED_INPUT = new ReturnCode("MAL_FORMED_INPUT", 0, "Mal-formed
Input");

        TN_CLS_AND_SO_COMBINATION_IS_NOT_FOUND = new ReturnCode("
TN_CLS_AND_SO_COMBINATION_IS_NOT_FOUND", 1, "TN/CLS and SO combination is
not found");

        SO_FAILED_PROVISIONING = new ReturnCode("SO_FAILED_PROVISIONING", 2,
"SO failed provisioning");

        SO_NOT_FOUND = new ReturnCode("SO_NOT_FOUND", 3, "SO not found");

        $VALUES = (new ReturnCode[] {

            MAL_FORMED_INPUT, TN_CLS_AND_SO_COMBINATION_IS_NOT_FOUND,
SO_FAILED_PROVISIONING, SO_NOT_FOUND

        });

    }

}





Now if there is any other value it throws exception . Our concern is can we
some way or through some external binding some default value to the enum so
that if its null it takes default value .

 Thanks and regards,

Rochak