Package hudson.util
Class RobustReflectionConverter
- java.lang.Object
-
- hudson.util.RobustReflectionConverter
-
- All Implemented Interfaces:
com.thoughtworks.xstream.converters.Converter,com.thoughtworks.xstream.converters.ConverterMatcher
public class RobustReflectionConverter extends Object implements com.thoughtworks.xstream.converters.Converter
CustomReflectionConverterthat handle errors more gracefully.- If the field is missing, the value is ignored instead of causing an error. This makes evolution easy.
- If the type found in XML is no longer available, the element is skipped instead of causing an error.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classRobustReflectionConverter.DuplicateFieldException
-
Field Summary
Fields Modifier and Type Field Description protected com.thoughtworks.xstream.mapper.Mappermapperprotected com.thoughtworks.xstream.converters.reflection.ReflectionProviderreflectionProviderprotected com.thoughtworks.xstream.core.util.SerializationMembersserializationMethodInvoker
-
Constructor Summary
Constructors Constructor Description RobustReflectionConverter(com.thoughtworks.xstream.mapper.Mapper mapper, com.thoughtworks.xstream.converters.reflection.ReflectionProvider reflectionProvider)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static voidaddErrorInContext(com.thoughtworks.xstream.converters.UnmarshallingContext context, Throwable e)booleancanConvert(Class type)protected voiddoMarshal(Object source, com.thoughtworks.xstream.io.HierarchicalStreamWriter writer, com.thoughtworks.xstream.converters.MarshallingContext context)ObjectdoUnmarshal(Object result, com.thoughtworks.xstream.io.HierarchicalStreamReader reader, com.thoughtworks.xstream.converters.UnmarshallingContext context)protected ObjectinstantiateNewInstance(com.thoughtworks.xstream.io.HierarchicalStreamReader reader, com.thoughtworks.xstream.converters.UnmarshallingContext context)voidmarshal(Object original, com.thoughtworks.xstream.io.HierarchicalStreamWriter writer, com.thoughtworks.xstream.converters.MarshallingContext context)protected voidmarshallField(com.thoughtworks.xstream.converters.MarshallingContext context, Object newObj, Field field)Objectunmarshal(com.thoughtworks.xstream.io.HierarchicalStreamReader reader, com.thoughtworks.xstream.converters.UnmarshallingContext context)protected ObjectunmarshalField(com.thoughtworks.xstream.converters.UnmarshallingContext context, Object result, Class type, Field field)
-
-
-
Field Detail
-
reflectionProvider
protected final com.thoughtworks.xstream.converters.reflection.ReflectionProvider reflectionProvider
-
mapper
protected final com.thoughtworks.xstream.mapper.Mapper mapper
-
serializationMethodInvoker
protected transient com.thoughtworks.xstream.core.util.SerializationMembers serializationMethodInvoker
-
-
Method Detail
-
canConvert
public boolean canConvert(Class type)
- Specified by:
canConvertin interfacecom.thoughtworks.xstream.converters.ConverterMatcher
-
marshal
public void marshal(Object original, com.thoughtworks.xstream.io.HierarchicalStreamWriter writer, com.thoughtworks.xstream.converters.MarshallingContext context)
- Specified by:
marshalin interfacecom.thoughtworks.xstream.converters.Converter
-
doMarshal
protected void doMarshal(Object source, com.thoughtworks.xstream.io.HierarchicalStreamWriter writer, com.thoughtworks.xstream.converters.MarshallingContext context)
-
marshallField
protected void marshallField(com.thoughtworks.xstream.converters.MarshallingContext context, Object newObj, Field field)
-
unmarshal
public Object unmarshal(com.thoughtworks.xstream.io.HierarchicalStreamReader reader, com.thoughtworks.xstream.converters.UnmarshallingContext context)
- Specified by:
unmarshalin interfacecom.thoughtworks.xstream.converters.Converter
-
doUnmarshal
public Object doUnmarshal(Object result, com.thoughtworks.xstream.io.HierarchicalStreamReader reader, com.thoughtworks.xstream.converters.UnmarshallingContext context)
-
addErrorInContext
public static void addErrorInContext(com.thoughtworks.xstream.converters.UnmarshallingContext context, Throwable e)
-
unmarshalField
protected Object unmarshalField(com.thoughtworks.xstream.converters.UnmarshallingContext context, Object result, Class type, Field field)
-
instantiateNewInstance
protected Object instantiateNewInstance(com.thoughtworks.xstream.io.HierarchicalStreamReader reader, com.thoughtworks.xstream.converters.UnmarshallingContext context)
-
-