I want to include objects from 3 different classes in one xml.
I am planning to created another class to hold a list of these objects.
I need only subset of values from these objects.
Is there a way to omit few values while generating xml from XStream?
Thanks.
Try using the @XStreamOmitField annotation.
Take a look at the documentation here: http://x-stream.github.io/annotations-tutorial.html#OmitField
The below is from the documentation:
@XStreamAlias("message")
class RendezvousMessage {
@XStreamOmitField
private int messageType;
@XStreamImplicit(itemFieldName="part")
private List<String> content;
@XStreamConverter(value=BooleanConverter.class, booleans={false}, strings={"yes", "no"})
private boolean important;
@XStreamConverter(SingleValueCalendarConverter.class)
private Calendar created = new GregorianCalendar();
public RendezvousMessage(int messageType, boolean important, String... content) {
this.messageType = messageType;
this.important = important;
this.content = Arrays.asList(content);
}
}