fireBand fireBand - 1 month ago 8x
Java Question

XStream- not include some values

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?



Try using the @XStreamOmitField annotation.

Take a look at the documentation here:

The below is from the documentation:

class RendezvousMessage {

  private int messageType;

  private List<String> content;

  @XStreamConverter(value=BooleanConverter.class, booleans={false}, strings={"yes", "no"})
  private boolean important;

  private Calendar created = new GregorianCalendar();

  public RendezvousMessage(int messageType, boolean important, String... content) {
    this.messageType = messageType;
    this.important = important;
    this.content = Arrays.asList(content);