How to disable Java Naming Conventions in xjc?

前端 未结 2 585
醉酒成梦
醉酒成梦 2020-12-06 13:18

For example sOmE_PROPerty in xsd must be sOmE_PROPerty in java class not someProperty.

I tried to use globalBindings enableJavaNamingConventions=\"false\" but it doe

2条回答
  •  渐次进展
    2020-12-06 14:09

    Solved by changing source code of jaxb in class com.sun.xml.bind.api.impl.NameConverter like this:

    public static final NameConverter standard = new Standard();
    
    static class Standard extends NameUtil implements NameConverter {
        public String toClassName(String s) {
            return s;//toMixedCaseName(toWordList(s), true);
        }
        public String toVariableName(String s) {
            return s;//toMixedCaseName(toWordList(s), false);
        }
        public String toInterfaceName( String token ) {
            return token;//toClassName(token);
        }
        public String toPropertyName(String s) {
            String prop = s;//toClassName(s);
            // property name "Class" with collide with Object.getClass,
            // so escape this.
            if(prop.equals("Class"))
                prop = "Clazz";
            return prop;
        }
    

提交回复
热议问题