Class PolymorphicReflectionConverter

  • All Implemented Interfaces:
    com.thoughtworks.xstream.converters.Converter, com.thoughtworks.xstream.converters.ConverterMatcher, com.thoughtworks.xstream.core.Caching

    public class PolymorphicReflectionConverter
    extends com.thoughtworks.xstream.converters.reflection.ReflectionConverter
    A subtype of reflection converter that is capable of handling polymorphic fields (when the declared field type is an interface or a parent class and its value is an instance of an implementation or a child class).

    When marshalling, the converter writes additional resolves-to attribute that contains the name of the serialized class. When unmarshalling, the AbstractReflectionConverter.instantiateNewInstance(HierarchicalStreamReader, UnmarshallingContext) method reads the attribute and creates an instance of the correct class.

    • Nested Class Summary

      • Nested classes/interfaces inherited from class com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter

        com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.DuplicateFieldException, com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.UnknownFieldException
    • Field Summary

      • Fields inherited from class com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter

        mapper, reflectionProvider, serializationMembers, serializationMethodInvoker
    • Constructor Summary

      Constructors 
      Constructor Description
      PolymorphicReflectionConverter​(com.thoughtworks.xstream.mapper.Mapper mapper, com.thoughtworks.xstream.converters.reflection.ReflectionProvider reflectionProvider)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void marshal​(Object original, com.thoughtworks.xstream.io.HierarchicalStreamWriter writer, com.thoughtworks.xstream.converters.MarshallingContext context)  
      • Methods inherited from class com.thoughtworks.xstream.converters.reflection.ReflectionConverter

        canConvert
      • Methods inherited from class com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter

        canAccess, doMarshal, doUnmarshal, flushCache, instantiateNewInstance, marshallField, readResolve, shouldUnmarshalField, shouldUnmarshalTransientFields, unmarshal, unmarshallField
    • Constructor Detail

      • PolymorphicReflectionConverter

        public PolymorphicReflectionConverter​(com.thoughtworks.xstream.mapper.Mapper mapper,
                                              com.thoughtworks.xstream.converters.reflection.ReflectionProvider reflectionProvider)
    • Method Detail

      • 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
        Overrides:
        marshal in class com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter