我使用CXF从WSDL生成类,但我不知道如何访问以下字段:
<s:complexType name="text-with-layout-type" mixed="true">
<s:sequence>
<s:any minOccurs="0" maxOccurs="unbounded"/>
</s:sequence>
<s:attribute name="L" type="s:string"/>
</s:complexType>
结果类是:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "text-with-layout-type", propOrder = {
"content"
})
public class TextWithLayoutType {
@XmlMixed
@XmlAnyElement(lax = true)
protected List<Object> content;
@XmlAttribute(name = "L")
protected String l;
/**
* Gets the value of the content property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the content property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getContent().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link Object }
* {@link String }
*
*
*/
public List<Object> getContent() {
if (content == null) {
content = new ArrayList<Object>();
}
return this.content;
}
/**
* Gets the value of the l property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getL() {
return l;
}
/**
* Sets the value of the l property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setL(String value) {
this.l = value;
}
}
如果我尝试使用
获取数据,我有一个Object类型.getTextWithLayout().get(0).getContent()
那么如何读取对象中的数据?
由于
答案 0 :(得分:0)
您的复杂类型“text-with-layout-type”包含“any”标记。这意味着JAXB需要能够处理任何类型的数据,因此它将数据键入为Object。
使用代码,您需要利用getClass()或instanceof来确定类型。如果你有一个特定的方式想要看看这个属性,那么请通过对问题的更新告诉我,我们可以讨论替代映射来启用这种行为。