Class PackageState


  • public class PackageState
    extends Object
    The package state class is used by the package manager to keep track of the activation level of the installed or errornous packages.

    This is an internal class used by the PackageManager.

    Author:
    Thomas Morgner
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int STATE_CONFIGURED
      A constant defining that the package has been loaded and configured.
      static int STATE_ERROR
      A constant defining that the package produced an error and is not available.
      static int STATE_INITIALIZED
      A constant defining that the package was initialized and is ready to use.
      static int STATE_NEW
      A constant defining that the package is new.
    • Constructor Summary

      Constructors 
      Constructor Description
      PackageState​(Module module)
      Creates a new package state for the given module.
      PackageState​(Module module, int state)
      Creates a new package state for the given module.
    • Field Detail

      • STATE_NEW

        public static final int STATE_NEW
        A constant defining that the package is new.
        See Also:
        Constant Field Values
      • STATE_CONFIGURED

        public static final int STATE_CONFIGURED
        A constant defining that the package has been loaded and configured.
        See Also:
        Constant Field Values
      • STATE_INITIALIZED

        public static final int STATE_INITIALIZED
        A constant defining that the package was initialized and is ready to use.
        See Also:
        Constant Field Values
      • STATE_ERROR

        public static final int STATE_ERROR
        A constant defining that the package produced an error and is not available.
        See Also:
        Constant Field Values
    • Constructor Detail

      • PackageState

        public PackageState​(Module module)
        Creates a new package state for the given module. The module state will be initialized to STATE_NEW.
        Parameters:
        module - the module.
      • PackageState

        public PackageState​(Module module,
                            int state)
        Creates a new package state for the given module. The module state will be initialized to the given initial state.
        Parameters:
        module - the module.
        state - the initial state
    • Method Detail

      • configure

        public boolean configure​(SubSystem subSystem)
        Configures the module and raises the state to STATE_CONFIGURED if the module is not yet configured.
        Parameters:
        subSystem - the sub-system.
        Returns:
        true, if the module was configured, false otherwise.
      • getModule

        public Module getModule()
        Returns the module managed by this state implementation.
        Returns:
        the module.
      • getState

        public int getState()
        Returns the current state of the module. This method returns either STATE_NEW, STATE_CONFIGURED, STATE_INITIALIZED or STATE_ERROR.
        Returns:
        the module state.
      • initialize

        public boolean initialize​(SubSystem subSystem)
        Initializes the contained module and raises the set of the module to STATE_INITIALIZED, if the module was not yet initialized. In case of an error, the module state will be set to STATE_ERROR and the module will not be available.
        Parameters:
        subSystem - the sub-system.
        Returns:
        true, if the module was successfully initialized, false otherwise.
      • equals

        public boolean equals​(Object o)
        Compares this object with the given other object for equality.
        Overrides:
        equals in class Object
        Parameters:
        o - the other object to be compared
        Returns:
        true, if the other object is also a PackageState containing the same module, false otherwise.
        See Also:
        Object.equals(Object)
      • hashCode

        public int hashCode()
        Computes a hashcode for this package state.
        Overrides:
        hashCode in class Object
        Returns:
        the hashcode.
        See Also:
        Object.hashCode()
      • markError

        public void markError()
        Marks this package state as invalid.