JAXB Make QName in Objectfactory accessible

风格不统一 提交于 2020-01-04 06:10:58

问题


When you generate java classes with JAXB you'll always get a Class named ObjectFactory. In this class there is a private attribute QName with the namespace in it.

Is it possible to tell the generator to make this attribute accessible from the outside. So maybe make it public or create a getter for it?


回答1:


I believe those private static QName fields are only generated if the ObjectFactory needs methods that create JAXBElement<...> instances. If you call one of those methods to get a JAXBElement instance, you can then invoke its getName method to retrieve its associated QName.




回答2:


I am not aware of a way to do this using the XJC tool that comes with the JAXB reference implementation. However, XJC does allow you to create custom plugins that may let you do need to:

  • http://download.oracle.com/docs/cd/E17802_01/webservices/webservices/docs/2.0/jaxb/developPlugins.html


来源:https://stackoverflow.com/questions/3716631/jaxb-make-qname-in-objectfactory-accessible

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!