开发者

Save List as Strings with Java XML Annotations

I need to save some variables in a simple class using Java's XML Annotations: http://download.oracle.com/javase/6/docs/api/javax/xml/bind/annotation/package-summary.html

Currently the class is pretty simple and looks like this:

@XmlRootElement
public class Chart {

@XmlElement
public String url;
@XmlElement
public String values;
@XmlElement
public String projectOrFilterName;
@XmlElement
public String countComplains;

public Chart(String url, String values, String projectOrFilterName, String countComplains) {
    this.url = url;
    this.values = values;
    this.projectOrFilterName = projectOrFilterName;
    this.countComplains = countComplains;
}
}

Now I need to save the data of a list as string variables with annotations like the existing ones. Im giving the constructor some kind of a list, let's say

List<Object>

The question is, how to extract all the variables out of it, and save their toString() representations with the given XML Annotations. If that's simpler one could assume, I get a List of String开发者_如何学运维s.

Can somebody please help me with this?


Who could have known, it would be that simple ;-)

@XmlElement
public List<String> data;

That's just, what I needed. The java script part, interpreting the xml creates an array out of the list's elements and everything is fine. Thanks for your time thinking over my question!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜