Good morning,
I have an object with many variables, three of them are an Integer and 2
dates. I am using xstream to create an output xml, but instead of display
the integer I want an String depending also on the dates, so in a "normal"
case i would create an static method (displayStatus(statusId, date1,
date2);)
how should i do this? Do I need to create a new variable (String status)
and add @XStreamOmitField to statusId or there is a "cleaner" posibility?
This is the code as I have it now, I would like to replace the underlined
code by the dates on fromDate and arcDate. is that possible?
"
@XStreamConverter(
StatusConverter.class)
private Integer statusId;
private Date fromDate;
private Date arcDate;
....
public class StatusConverter implements Converter {
@Override
public void marshal(Object o, HierarchicalStreamWriter
hierarchicalStreamWriter, MarshallingContext marshallingContext) {
Integer statusId = (Integer) o;
hierarchicalStreamWriter.setValue(PropertyFormatter.displayStatus(statusId,
*new Date(), new Date()*));
}
@Override
public Object unmarshal(HierarchicalStreamReader
hierarchicalStreamReader, UnmarshallingContext unmarshallingContext) {
return hierarchicalStreamReader.getValue();
}
@Override
public boolean canConvert(Class aClass) {
return aClass.equals(Integer.class);
}
}
"
Thank you in advance.