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
Custom ReflectionConverter
that 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.
Field Summary |
protected com.thoughtworks.xstream.mapper.Mapper |
mapper
|
protected com.thoughtworks.xstream.converters.reflection.ReflectionProvider |
reflectionProvider
|
protected com.thoughtworks.xstream.converters.reflection.SerializationMethodInvoker |
serializationMethodInvoker
|
Constructor Summary |
RobustReflectionConverter(com.thoughtworks.xstream.mapper.Mapper mapper,
com.thoughtworks.xstream.converters.reflection.ReflectionProvider reflectionProvider)
|
Method Summary |
static void |
addErrorInContext(com.thoughtworks.xstream.converters.UnmarshallingContext context,
Throwable e)
|
boolean |
canConvert(Class type)
|
protected void |
doMarshal(Object source,
com.thoughtworks.xstream.io.HierarchicalStreamWriter writer,
com.thoughtworks.xstream.converters.MarshallingContext context)
|
Object |
doUnmarshal(Object result,
com.thoughtworks.xstream.io.HierarchicalStreamReader reader,
com.thoughtworks.xstream.converters.UnmarshallingContext context)
|
protected Object |
instantiateNewInstance(com.thoughtworks.xstream.io.HierarchicalStreamReader reader,
com.thoughtworks.xstream.converters.UnmarshallingContext context)
|
void |
marshal(Object original,
com.thoughtworks.xstream.io.HierarchicalStreamWriter writer,
com.thoughtworks.xstream.converters.MarshallingContext context)
|
protected void |
marshallField(com.thoughtworks.xstream.converters.MarshallingContext context,
Object newObj,
Field field)
|
Object |
unmarshal(com.thoughtworks.xstream.io.HierarchicalStreamReader reader,
com.thoughtworks.xstream.converters.UnmarshallingContext context)
|
protected Object |
unmarshalField(com.thoughtworks.xstream.converters.UnmarshallingContext context,
Object result,
Class type,
Field field)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
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.converters.reflection.SerializationMethodInvoker serializationMethodInvoker
RobustReflectionConverter
public RobustReflectionConverter(com.thoughtworks.xstream.mapper.Mapper mapper,
com.thoughtworks.xstream.converters.reflection.ReflectionProvider reflectionProvider)
canConvert
public boolean canConvert(Class type)
- Specified by:
canConvert
in interface com.thoughtworks.xstream.converters.ConverterMatcher
marshal
public void marshal(Object original,
com.thoughtworks.xstream.io.HierarchicalStreamWriter writer,
com.thoughtworks.xstream.converters.MarshallingContext context)
- Specified by:
marshal
in interface com.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:
unmarshal
in interface com.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)
Copyright © 2004-2013. All Rights Reserved.