Although I really do not think that Xstream is really suitable for this task, it seems possible.
You can implement your own converter similar to one of these . If you look at the Converter interface, you will see that you can easily skip an element without writing anything to HierarchicalStreamWriter.
public class ParamConverter implements Converter{
boolean canConvert(Class type){
return Param.class.equals(type);
}
public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context){
Param param = (Param)source;
if (NAME_TO_SKIP.equals(param.getName()){
return;
}
}
}
To register the converter just call xStram.registerConverter(new ParamConverter());.
, , .