xstream解析xml轉換java物件,過濾掉不需要的節點
阿新 • • 發佈:2019-02-07
public class ETLXstream extends XStream {
protected MapperWrapper wrapMapper(MapperWrapper next) {
return new MapperWrapper(next) {
@Override
public boolean shouldSerializeMember(@SuppressWarnings(“rawtypes”) Class definedIn,
String fieldName) {
// TODO Auto-generated method stub
//不能識別的節點
if(definedIn == Object.class){
return false;
}
if(fieldName.equals(“fileName”)){
return false;
}
return super.shouldSerializeMember(definedIn, fieldName);
}
};
}
}