Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 61361
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T18:18:26+00:00 2026-05-10T18:18:26+00:00

When compiling the following simpleType with the XJC compile (from the JAXB package)… <xs:simpleType

  • 0

When compiling the following simpleType with the XJC compile (from the JAXB package)…

<xs:simpleType name='test'>     <xs:annotation>         <xs:appinfo>             <jaxb:typesafeEnumClass/>         </xs:appinfo>     </xs:annotation>     <xs:restriction base='xs:string'>       <xs:enumeration value='4'>         <xs:annotation>           <xs:appinfo>             <jaxb:typesafeEnumMember name='FOUR'/>           </xs:appinfo>         </xs:annotation>       </xs:enumeration>             <xs:enumeration value='6'>         <xs:annotation>           <xs:appinfo>             <jaxb:typesafeEnumMember name='SIX'/>           </xs:appinfo>         </xs:annotation>       </xs:enumeration>      </xs:restriction> </xs:simpleType> 

I end up with the following enum in Java (import statements and comments removed)

@XmlEnum public enum Test {      @XmlEnumValue('4')     FOUR('4'),     @XmlEnumValue('6')     SIX('6');     private final String value;      Test(String v) {         value = v;     }      public String value() {         return value;     }      public static Test fromValue(String v) {         for (Test c: Test.values()) {             if (c.value.equals(v)) {                 return c;             }         }         throw new IllegalArgumentException(v.toString());     }  } 

This is exactly what I want… except for the public String value() method. I would expect the method to be called public String getValue() according to Sun’s naming conventions. That way I can easily use it in a JSP-page using EL. Now I have to work my way around it.

Does anybody have any experience in further tweaking the XJC compilation to a more useful enumeration with a getValue() method, instead of a value() method? Or can I add a method or something?

P.S. This occurred in v2.0.3 of JAXB. I downloaded the latest version v2.1.8 and it’s the same there…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T18:18:26+00:00Added an answer on May 10, 2026 at 6:18 pm

    There’s nothing in the JAXB spec that seems to allow this change. I think the only way to do this would be to write a JAXB Plugin.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

On compiling the following code with Scala 2.7.3, package spoj object Prime1 { def
When I try compiling the following: #include <iostream> class Test { public: void* operator
When compiling the following code: void DoSomething(int Numbers[]) { int SomeArray[] = Numbers; }
I get the following error pretty regularly when compiling in Visual Studio and running
When compiling the following instruction: movl 4(%ebp), 8(%ebp) I got: too many memory reference
While compiling the following code {\centering {\includegraphics[scale=.5]{splash.eps}} \caption{Splash Screen} \par} \end{figure} Splash screen is
I tried compiling the following code in Linux and VS 2008: #include <iostream> //
I'm having problems compiling the following program. I'm using gcc -framework Foundation inherit8.1m and
I have a problem compiling the following code: #include <stdio.h> #include <limits.h> int main
I am having problems compiling the following snippet int temp; vector<int> origins; vector<string> originTokens

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.