Class JavaBeanConverter

  • All Implemented Interfaces:
    Converter, ConverterMatcher

    public class JavaBeanConverter
    extends java.lang.Object
    implements Converter
    Can convert any bean with a public default constructor. The BeanProvider used as default is based on BeanInfo. Indexed properties are currently not supported.
    • Field Detail

      • mapper

        protected final Mapper mapper
      • type

        private final java.lang.Class type
      • classAttributeIdentifier

        private java.lang.String classAttributeIdentifier
        Deprecated.
        As of 1.3, no necessity for field anymore.
    • Method Detail

      • canConvert

        public boolean canConvert​(java.lang.Class type)
        Checks if the bean provider can instantiate this type. If you need less strict checks, subclass JavaBeanConverter
        Specified by:
        canConvert in interface ConverterMatcher
        Parameters:
        type - the Class representing the object type to be converted
      • marshal

        public void marshal​(java.lang.Object source,
                            HierarchicalStreamWriter writer,
                            MarshallingContext context)
        Description copied from interface: Converter
        Convert an object to textual data.
        Specified by:
        marshal in interface Converter
        Parameters:
        source - The object to be marshalled.
        writer - A stream to write to.
        context - A context that allows nested objects to be processed by XStream.
      • instantiateNewInstance

        private java.lang.Object instantiateNewInstance​(UnmarshallingContext context)
      • determineType

        private java.lang.Class determineType​(HierarchicalStreamReader reader,
                                              java.lang.Object result,
                                              java.lang.String fieldName)