Enum Class Registry

java.lang.Object
java.lang.Enum<Registry>
org.sm.smtools.application.util.Registry
All Implemented Interfaces:
Serializable, Comparable<Registry>, Constable

public enum Registry extends Enum<Registry>
The Registry class provides a mechanism for accessing (persistent) global variables.

The Registry class is actually a singleton instance, and a local reference to it should be obtained as follows:

   Registry registry = Registry.kINSTANCE;
 
The registry contains serialisable objects that can be stored and retrieved via a String key using the addObject(String,Object) and getObject(String) methods.
Version:
26/06/2018
Author:
Sven Maerivoet
  • Enum Constant Details

    • kINSTANCE

      public static final Registry kINSTANCE
      The singleton instance.
  • Method Details

    • values

      public static Registry[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static Registry valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • clear

      public void clear()
      Clears the registry.
    • addObject

      public void addObject(String name, Object object)
      Adds an object to the registry.
      Parameters:
      name - the name of the object
      object - a reference to the object
    • getObject

      public Object getObject(String name)
      Returns an object from the registry.
      Parameters:
      name - the name of the object
      Returns:
      a reference to the object
    • load

      public void load(String filename) throws RegistryException
      Loads all objects in the registry from a file using deserialisation.
      Parameters:
      filename - the name of the file to load the registry from
      Throws:
      RegistryException - if an error occurred during the deserialisation process
    • save

      public void save(String filename) throws RegistryException
      Saves all objects in the registry to a file using serialisation.

      Note that care should be taken that all the objects are serialisable.

      Parameters:
      filename - the name of the file to save the registry to
      Throws:
      RegistryException - if an error occurred during the serialisation process