简体   繁体   English

JAXB:将自己的类导入生成的类

[英]JAXB: Import own class into generated Class

I'm using JAXB 2.2 and I'm into some trouble. 我正在使用JAXB 2.2,但遇到了一些麻烦。

I have the following XML in my xsd: 我的xsd中有以下XML:

<xs:complexType name="Party" abstract="true">
    <xs:annotation>
        <xs:appinfo>
            <ci:code>
                public ElectronicAddress
                getFirstPrimaryElectronicAddressPhone() {
                for (ElectronicAddress
                eAddress : electronicAddresses) {
                if (checkRefCodeTypeCode(eAddress,
                CodeHelper.ADDRTYPEELECORG_PHONE_CODE,
                CodeHelper.ADDRTYPEELECPERS_PHONE_CODE)) {
                return eAddress;
                }
                }
                return
                null;
                }
          [...]

Now, I need to import my own (CodeHelper) class into the generated class, because CodeHelper is not in the same package as the generated source. 现在,我需要将自己的(CodeHelper)类导入到生成的类中,因为CodeHelper与生成的源不在同一个包中。

Is there any possibility to do that? 有可能这样做吗?

Thanks! 谢谢!

You could possibly write an XJC plugin to get this behaviour. 您可以编写一个XJC插件来获得此行为。 The link below has some pointers for creating a plugin: 以下链接提供了一些用于创建插件的指针:

The example in the above article is actually a code injector plug-in. 上面文章中的示例实际上是一个代码注入器插件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM