JAXB使Objectfactory中的QName可访问 [英] JAXB Make QName in Objectfactory accessible

查看:75
本文介绍了JAXB使Objectfactory中的QName可访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用JAXB生成Java类时,您将始终获得一个名为ObjectFactory的类. 在此类中,有一个私有属性QName及其名称空间.

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?

推荐答案

我相信只有ObjectFactory需要创建JAXBElement<...>实例的方法时,才会生成这些private static QName字段.如果调用这些方法之一来获取JAXBElement实例,则可以调用其getName方法来检索与其关联的QName.

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.

这篇关于JAXB使Objectfactory中的QName可访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆