2013-07-12 27 views
0

在我的xsd模式中,我有一个complexType“表达式”,其中有27个元素,它们都扩展了一个常见的complexType“StepElement”。这里是表达复杂类型的样本。(为简单起见,我只显示其中8人)。JAXB生成可笑的奇怪和长的方法名称

<xs:complexType name="expression"> 
      <xs:sequence maxOccurs="unbounded"> 
       <xs:element name="STEP_ANIMATION" type="Animation_Attributes" minOccurs="0" maxOccurs="unbounded"/> 
       <xs:element name="STEP_EXPECT_REPLY" type="Expect_Reply_Attributes" minOccurs="0" maxOccurs="unbounded"/> 
       <xs:element name="STEP_RESTART" type="Restart_Attributes" minOccurs="0" maxOccurs="unbounded"/> 
       <xs:element name="STEP_REDIRECT" type="Redirect_Attributes" minOccurs="0" maxOccurs="unbounded"/> 
       <xs:element name="STEP_SUBGOAL" type="Subgoal_Attributes" minOccurs="0" maxOccurs="unbounded"/> 
       <xs:element name="STEP_TIMER" type="Timer_Attributes" minOccurs="0" maxOccurs="unbounded"/> 
       <xs:element name="STEP_SITUATION" type="Situation_Attributes" minOccurs="0" maxOccurs="unbounded"/> 
       <xs:element name="STEP_SOUND" type="Sound_Attributes" minOccurs="0" maxOccurs="unbounded"/> 
      </xs:sequence> 
     <xs:attribute name="ID" type="xs:integer"/> 
     <xs:attribute name="SUCCESS_EVT" type="xs:string"/> 
     <xs:attribute name="DELAY" type="xs:float"/> 
    </xs:complexType> 

当这些元素类型的像这样(它们都继承StepElement但具有不同的属性)

<xs:complexType name="Animation_Attributes"> 
     <xs:complexContent> 
      <xs:extension base="StepElement"> 
       <xs:attribute name="AGENT" type="xs:string" default="$CURRENTBOT"/> 
       <xs:attribute name="SUCCESS_EVT" type="xs:string"/> 
       <xs:attribute name="FAIL_EVT" type="xs:string"/> 
       </xs:extension> 
     </xs:complexContent> 
</xs:complexType> 

这里是StepElement怎么看起来像

<xs:complexType name="StepElement"> 
     <xs:simpleContent> 
      <xs:extension base="xs:string"> 
       <xs:attribute name="ID" type="xs:integer"/> 
       <xs:attribute name="ENGLISH" type="xs:string"/> 
      </xs:extension> 
     </xs:simpleContent> 

现在,我有这样的问题,当我分析这个模式,使JAXB生成的getter方法表达类是这个

public List<StepElement> getSTEPANIMATIONAndSTEPEXPECTREPLYAndSTEPRESTART() 

我在做一些错误是导致这种情况发生,还是有来调整方法名的解决方案架构的结构?

回答

1

您可以使用JAXB绑定文件来自定义生成的方法名称。这是Oracle documentation on it

+0

我研究了定制JAXB绑定的文档,但没有提到有关定制方法名称的任何信息:/。 –

+0

下面是一个例子。 http://stackoverflow.com/questions/4502229/how-do-you-customize-how-jaxb-generates-plural-method-names – austin

+0

谢谢。它完美的作品。 –