jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • castor
  • CASTOR-2141

Castor snapshot 1.1.3 source generator enum default values not being set correctly.

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Blocker Blocker
  • Resolution: Fixed
  • Affects Version/s: 1.2
  • Fix Version/s: 1.2
  • Component/s: XML code generator
  • Labels:
    None
  • Environment:
    Windows using Intellij Idea. Java 1.5.

Description

I just tried out the snapshot release of Castor 1.1.3 and found what seems to be a bug. My schema has an element, screenSize, that is an enumeration that consists of the values Small, Medium, and Large. I set the enumeration to have the default value of Medium. screenSize is an element in a complex type typeMyUser. The source generator created the classes TypeMyUser.java and ScreenSizeType.java. TypeMyUser.java has a member variable called _screenSize with a default value being set. The problem is the way the default value is being set. It has something like

private ScreenSizeType _screenSize = ScreenSizeType.valueOf("Medium");

The problem is the enum constant name that it is passing into the valueOf method does not exist. The enum constants that were created were SMALL, MEDIUM, and LARGE (all caps). So, the line above should have passed the all caps enum constant name instead:

private ScreenSizeType _screenSize = ScreenSizeType.valueOf("MEDIUM");

  • Options
    • Sort By Name
    • Sort By Date
    • Ascending
    • Descending
    • Download All

Attachments

  1. XML File
    MyUser.xsd
    05/Sep/07 1:45 PM
    1.0 kB
    Ron Corcuera
  2. Text File
    patch.c2141.20070906.txt
    06/Sep/07 4:55 AM
    10 kB
    Matthias Epheser

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
Werner Guttmann added a comment - 06/Sep/07 3:50 AM

Just to make sure that I get a few things right:

  • you want Java 5.0 code to be generated, right ?
  • you want an enum to be generated for the screenSizeType definition ?

Actually, why not attach the castorbuilder.properties you are using, in case you are using one ?

Show
Werner Guttmann added a comment - 06/Sep/07 3:50 AM Just to make sure that I get a few things right:
  • you want Java 5.0 code to be generated, right ?
  • you want an enum to be generated for the screenSizeType definition ?
Actually, why not attach the castorbuilder.properties you are using, in case you are using one ?
Hide
Permalink
Werner Guttmann added a comment - 06/Sep/07 3:50 AM

Matthias, assigning this to yourself as you've been working on this recently.

Show
Werner Guttmann added a comment - 06/Sep/07 3:50 AM Matthias, assigning this to yourself as you've been working on this recently.
Hide
Permalink
Werner Guttmann added a comment - 06/Sep/07 3:52 AM

Btw, can you please attach a XML document instance that - in your view - should successfully unmarshal ?

Show
Werner Guttmann added a comment - 06/Sep/07 3:52 AM Btw, can you please attach a XML document instance that - in your view - should successfully unmarshal ?
Hide
Permalink
Werner Guttmann added a comment - 06/Sep/07 3:57 AM

Matthias, by the looks of it, the way we generate default values needs to be changed much in the same way as everything else .. to cater for (extended) Java 5 enums.

Show
Werner Guttmann added a comment - 06/Sep/07 3:57 AM Matthias, by the looks of it, the way we generate default values needs to be changed much in the same way as everything else .. to cater for (extended) Java 5 enums.
Hide
Permalink
Matthias Epheser added a comment - 06/Sep/07 4:03 AM

Yes, I was about to write the same. I'm currently looking for the place where the default values are created.
We then need to use the FROMVALUE method instead of the VALUEOF method for extended java5 enums.

The fromValue method takes the "Medium" value from the xsd and maps it to the "MEDIUM" enum constant instance that represents this value.

Show
Matthias Epheser added a comment - 06/Sep/07 4:03 AM Yes, I was about to write the same. I'm currently looking for the place where the default values are created. We then need to use the FROMVALUE method instead of the VALUEOF method for extended java5 enums. The fromValue method takes the "Medium" value from the xsd and maps it to the "MEDIUM" enum constant instance that represents this value.
Hide
Permalink
Matthias Epheser added a comment - 06/Sep/07 4:14 AM

I found the right place in MemberFactory line 558
We need to check if we are creating complex java5 enums there. I'm working on a patch.

Show
Matthias Epheser added a comment - 06/Sep/07 4:14 AM I found the right place in MemberFactory line 558 We need to check if we are creating complex java5 enums there. I'm working on a patch.
Hide
Permalink
Matthias Epheser added a comment - 06/Sep/07 4:55 AM

Patch includes fix for correct default value call, as well as testcases for xmlctf (java4_default and java5_default).

Please review, your problem should be solved with this patch.

Show
Matthias Epheser added a comment - 06/Sep/07 4:55 AM Patch includes fix for correct default value call, as well as testcases for xmlctf (java4_default and java5_default). Please review, your problem should be solved with this patch.
Hide
Permalink
Werner Guttmann added a comment - 06/Sep/07 11:14 AM

Will make available a snapshot release as time permits.

Show
Werner Guttmann added a comment - 06/Sep/07 11:14 AM Will make available a snapshot release as time permits.

People

  • Assignee:
    Matthias Epheser
    Reporter:
    Ron Corcuera
Vote (0)
Watch (0)

Dates

  • Created:
    05/Sep/07 1:45 PM
    Updated:
    14/Mar/08 6:41 AM
    Resolved:
    06/Sep/07 11:13 AM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.