1 package hudson.util; 2 3 import com.thoughtworks.xstream.alias.CannotResolveClassException; 4 import com.thoughtworks.xstream.converters.UnmarshallingContext; 5 import com.thoughtworks.xstream.converters.collections.CollectionConverter; 6 import com.thoughtworks.xstream.io.HierarchicalStreamReader; 7 import com.thoughtworks.xstream.mapper.Mapper; 8 9 import java.util.Collection ; 10 11 20 public class RobustCollectionConverter extends CollectionConverter { 21 public RobustCollectionConverter(Mapper mapper) { 22 super(mapper); 23 } 24 25 protected void populateCollection(HierarchicalStreamReader reader, UnmarshallingContext context, Collection collection) { 26 while (reader.hasMoreChildren()) { 27 reader.moveDown(); 28 try { 29 Object item = readItem(reader, context, collection); 30 collection.add(item); 31 } catch (CannotResolveClassException e) { 32 System.err.println("failed to locate class: "+e); 33 } 34 reader.moveUp(); 35 } 36 } 37 38 } 39 | Popular Tags |