2016-06-24 12 views
0

JAXB生成後、私のint配列に間違った型を含むクラスがあり、int []ではなくInteger型でアノテートします。ここJAXB生成後のアノテーションタイプが正しくありません

は私のXSDです:

<complexType name="GenericChartTask"> 
    <sequence> 
     <element name="clients" type="struct:IDNameSiteServiceImageIndex" 
      maxOccurs="unbounded" minOccurs="0"> 
     </element> 
     <element name="commonTasks" type="struct:NameAndID" 
      maxOccurs="unbounded" minOccurs="0"> 
     </element> 
     <element name="groups" type="int" maxOccurs="unbounded" 
      minOccurs="0"></element> 
     <element name="siteServices" type="struct:SiteService" 
      maxOccurs="unbounded" minOccurs="0"> 
     </element> 
    </sequence> 
</complexType> 

そして、ここでは、私が作成した後に得るものです:

public class GenericChartTask { 

    @XmlElement(namespace = "http://american-data.com/ecs/struct") 
    protected ad.ecs.struct.IDNameSiteServiceImageIndex[] clients; 
    @XmlElement(namespace = "http://american-data.com/ecs/struct") 
    protected ad.ecs.struct.NameAndID[] commonTasks; 
    @XmlElement(namespace = "http://american-data.com/ecs/struct", type = Integer.class) 
    protected int[] groups; 
    @XmlElement(namespace = "http://american-data.com/ecs/struct") 
    protected ad.ecs.struct.SiteService[] siteServices; 
    ... 

JAXBは「doesnのため、私はまた、リストの代わりに配列を生成するために結合しています法的なBeanを生成したい(リストのためのsetterを落と​​す)。私の質問は次のようになり

<jxb:bindings node="//xs:element[@name='groups']"> 
    <jxb:property collectionType="indexed" /> 
</jxb:bindings> 

、その故障部品タイプ= Integer.classを取り除く方法はありますか?なぜなら、このオブジェクトに対してJSONを逆シリアル化するときに問題が発生するからです。

答えて

0

minOccurs=0が設定されているため、タイプIntegerが生成されています。

intがnullでない場合、整数はnull可能です。

この属性を削除すると、intとして生成されます。

<xs:element name="groups" type="xs:int"> 
</xs:element> 
+0

病気はこれを試してみて、あなたはこれで問題が解決しない – serge

+0

を教えて - 私はそれが非リストフィールドになったことを行う場合にもまだ – serge

+0

てみドロップのmaxOccursを生成します。全体の問題はリストについてです... – Revive

関連する問題