该解决方案不是很直观,但我设法弄清楚了。首先,我必须声明一个代表响应标签的类。此类还包含回收服务列表的容器。这是该类的外观:
@XStreamAlias("response")
public class QueryResponse {
@XStreamAlias("row")
private RecycleServices services;
public RecycleServices getServices() {
return services;
}
public void setServices(RecycleServices services) {
this.services = services;
}
}
RecycleServices 类是这里真正的技巧,它包装了 RecycleService 类的隐式列表。
@XStreamAlias("row")
public class RecycleServices {
@XStreamImplicit(itemFieldName = "row")
private List<RecycleService> services = new ArrayList<RecycleService>();
public List<RecycleService> getServices() {
return services;
}
public void setServices(List<RecycleService> services) {
this.services = services;
}
}
RecycleService 类只是每个回收服务行的直接表示,与这个问题的答案并不真正相关。我对此感到有些沮丧,我希望这可以帮助那里的人。