Class Registry

java.lang.Object
org.simpleframework.xml.convert.Registry

public class Registry extends Object
The Registry represents an object that is used to register bindings between a class and a converter implementation. Converter instances created by this registry are lazily created and cached so that they are instantiated only once. This ensures that the overhead of serialization is reduced.
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final RegistryBinder
    This is used to bind converter types to serializable types.
    private final Cache<Converter>
    This is used to cache the converters based on object types.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructor for the Registry object.
  • Method Summary

    Modifier and Type
    Method
    Description
    bind(Class type, Class converter)
    This is used to register a binding between a type and the converter used to serialize and deserialize it.
    bind(Class type, Converter converter)
    This is used to register a binding between a type and the converter used to serialize and deserialize it.
    private Converter
    create(Class type)
    This is used to acquire a Converter instance from the registry.
    lookup(Class type)
    This is used to acquire a Converter instance from the registry.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • cache

      private final Cache<Converter> cache
      This is used to cache the converters based on object types.
    • binder

      private final RegistryBinder binder
      This is used to bind converter types to serializable types.
  • Constructor Details

    • Registry

      public Registry()
      Constructor for the Registry object. This is used to create a registry between classes and the converters that should be used to serialize and deserialize the instances. All converters are instantiated once and cached for reuse.
  • Method Details

    • lookup

      public Converter lookup(Class type) throws Exception
      This is used to acquire a Converter instance from the registry. All instances are cache to reduce the overhead of lookups during the serialization process. Converters are lazily instantiated and so are only created if demanded.
      Parameters:
      type - this is the type to find the converter for
      Returns:
      this returns the converter instance for the type
      Throws:
      Exception
    • create

      private Converter create(Class type) throws Exception
      This is used to acquire a Converter instance from the registry. All instances are cached to reduce the overhead of lookups during the serialization process. Converters are lazily instantiated and so are only created if demanded.
      Parameters:
      type - this is the type to find the converter for
      Returns:
      this returns the converter instance for the type
      Throws:
      Exception
    • bind

      public Registry bind(Class type, Class converter) throws Exception
      This is used to register a binding between a type and the converter used to serialize and deserialize it. During the serialization process the converters are retrieved and used to convert the object members to XML.
      Parameters:
      type - this is the object type to bind to a converter
      converter - this is the converter class to be used
      Returns:
      this will return this registry instance to use
      Throws:
      Exception
    • bind

      public Registry bind(Class type, Converter converter) throws Exception
      This is used to register a binding between a type and the converter used to serialize and deserialize it. During the serialization process the converters are retrieved and used to convert the object properties to XML.
      Parameters:
      type - this is the object type to bind to a converter
      converter - this is the converter instance to be used
      Returns:
      this will return this registry instance to use
      Throws:
      Exception