if (isSimplifyingXML()) {
xstream.omitField(AbstractConnectedContained.class, "links");
}
// handle styled text correctly
xstream.registerConverter(new Converter() {
public boolean canConvert(@SuppressWarnings("rawtypes") Class type) {
return type.equals(StyledText.class);
}
public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) {
StyledText st = (StyledText) source;
if (st.getStyle() != null) {
writer.addAttribute("style", st.getStyle());
}
writer.setValue(st.getText());
}
public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {
String style = reader.getAttribute("style");
String text = reader.getValue();
return new StyledText(text, style);
}
});
// this makes it so that if the type is not specified in the xml, we
// assume a string.
xstream.registerConverter(new StringConverter() {
@Override
public boolean canConvert(@SuppressWarnings("rawtypes") Class type) {
return super.canConvert(type) || type.equals(Object.class);
}
}, 10);
// this compacts the representation of a hint map, which is
// otherwise excessive
xstream.registerConverter(new Converter() {
public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) {
HintMap map = (HintMap) source;
for (Iterator<Entry<String, Float>> iterator = map.entrySet().iterator(); iterator.hasNext();) {
Entry<String, Float> entry = iterator.next();