Class NullValueConverter

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

    public class NullValueConverter
    extends java.lang.Object
    implements com.thoughtworks.xstream.converters.Converter
    A type converter for delegating types. Background: In the IVML object model, delegating types are used to resolve class dependencies while defining IVML operations as constants. These delegating types are singleton instances and if serialized to an XML file, the type identity of the object constants defined in the IVML object model are not unique anymore. In this class, map the delegating type to a unique name and back to the actual singleton instance.
    Author:
    Aike Sass
    • Constructor Summary

      Constructors 
      Constructor Description
      NullValueConverter()
      Creates a singleton type converter.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean canConvert​(java.lang.Class cls)
      Determines whether this converter instance handles the given class.
      void marshal​(java.lang.Object object, com.thoughtworks.xstream.io.HierarchicalStreamWriter writer, com.thoughtworks.xstream.converters.MarshallingContext context)
      Marshals a given object to the given writer in the specified marshaling context.
      java.lang.Object unmarshal​(com.thoughtworks.xstream.io.HierarchicalStreamReader reader, com.thoughtworks.xstream.converters.UnmarshallingContext context)
      Unmarshals the current object to be read from the given reader in the specified unmarshaling context.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • NullValueConverter

        public NullValueConverter()
        Creates a singleton type converter.
    • Method Detail

      • canConvert

        public boolean canConvert​(java.lang.Class cls)
        Determines whether this converter instance handles the given class.
        Specified by:
        canConvert in interface com.thoughtworks.xstream.converters.ConverterMatcher
        Parameters:
        cls - the class to be tested
        Returns:
        true if this instance handles class (this is only the case if it is a NullValue class), false else
      • marshal

        public void marshal​(java.lang.Object object,
                            com.thoughtworks.xstream.io.HierarchicalStreamWriter writer,
                            com.thoughtworks.xstream.converters.MarshallingContext context)
        Marshals a given object to the given writer in the specified marshaling context. This method translates a NullValue type singleton to a name.
        Specified by:
        marshal in interface com.thoughtworks.xstream.converters.Converter
        Parameters:
        object - the object to be marshaled
        writer - the output stream writer
        context - the marshaling context
      • unmarshal

        public java.lang.Object unmarshal​(com.thoughtworks.xstream.io.HierarchicalStreamReader reader,
                                          com.thoughtworks.xstream.converters.UnmarshallingContext context)
        Unmarshals the current object to be read from the given reader in the specified unmarshaling context. This method translates the name back to the singleton instance.
        Specified by:
        unmarshal in interface com.thoughtworks.xstream.converters.Converter
        Parameters:
        reader - the input stream writer
        context - the marshaling context
        Returns:
        the unmarshaled object